Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type=xml-external #107

Closed
MartijnR opened this issue Apr 4, 2017 · 5 comments
Closed

Add type=xml-external #107

MartijnR opened this issue Apr 4, 2017 · 5 comments

Comments

@MartijnR
Copy link
Contributor

MartijnR commented Apr 4, 2017

We have the convenience types select_one_from_file name.xml and select_multiple_from_file name.xml and a convenience function pulldata that all 3 automagically add an <instance> to the model.

This issue, for discussion, is to explicitly only add an instance, e.g.

type name
xml-external mydata

produces:

<instance id="mydata" src="jr://file/mydata.xml" />`

This would cater to complex calculations that query external data without restrictions, for example:

type name calculation
integer rooms
calculate c count(instance('mydata')/house[rooms = current()/../rooms ])

Note that this might make select_one_from_file and select_multiple_from_file redundant (which is totally fine) , as you could feasibly use type=xml-external and type=select_one to produce the same XForm output.

Updated: type now named xml-external

@MartijnR MartijnR changed the title Add type=data-xml Add type=xml-data Dec 7, 2017
@MartijnR
Copy link
Contributor Author

MartijnR commented Dec 7, 2017

I changed the above type to xml-data (and the idea is that in the future csv-data may be added).

Is anybody opposed to, or excited about, a PR that adds this feature?

lindsay-stevens added a commit to lindsay-stevens/pyxform that referenced this issue Dec 19, 2017
- As mentioned in XLSForm#107
- Similar to select_one_from_file or pulldata, except instance only
- Included some tidy-up of the common instance generating functions
- Lots of tests
@lognaturel
Copy link
Contributor

This is nice! There are a couple of things that come to mind that perhaps could be handled separately but that may affect the type name.

  1. Generating the XML from the choices sheet. I understand you are probably imagining servers would generate the files but I think it is useful to be able to generate them in the form-building process as well. I'm imagining this would be just like for selects but instead of writing an internal instance an external instance would be generated. For example, if I have a file reference called mydata and a list_name mydata in the choices sheet then mydata.xml would be generated accordingly. If mydata isn't in the choices sheet then the behavior is as in Feature/external instance #107 #169. One slight complication I see is that there might need to be a new mechanism introduced to specify which columns to include. selects use the choice_filter.

  2. Generating and using internal instances in addition to external ones. There are small, static data sets that are useful to do XPath queries on. In that case, it's more convenient for them to be in the form file rather than as separate attachments. It's currently possible to fake this with a dummy select and a choice_filter that forces extra columns to be included in the internal secondary instance but it would be great for this to be a first-class citizen (see what I mean at https://docs.google.com/spreadsheets/d/1mQGVWaJA4QQp3jtddMdcRSDjc1O-j_bB79GUnlj5k10/edit#gid=0). This would be most convenient in combination with 1) above.

For those two reasons, I'd like to propose that the type for this feature be xml-external so that we can then add xml-internal and eventually csv-external.

@MartijnR
Copy link
Contributor Author

MartijnR commented Dec 22, 2017

Yes, that sounds perfect to me to change the type to xml-external instead of xml-data for this issue/PR in order to be prepared for future features. Thanks!

@lindsay-stevens
Copy link
Contributor

The name change from xml-data to xml-external is in 6f1d80a.

For the xml-internal, I think it's possible to abuse choice_filter with just true() since the value is plonked into an XPath predicate, although I agree it's not quite as nice as having an item type for that sort of thing. I looked into how/why there's an instance generated for choices with a choice_filter but not otherwise, and noted it here: https://github.com/XLSForm/pyxform/pull/169/files#diff-642ca628a5111f8d9ff1314acb61ceadR122 - perhaps the backwards compatibility concern isn't relevant anymore since that commit was 6 years ago.

lindsay-stevens added a commit that referenced this issue Jan 4, 2018
@dcbriccetti
Copy link

Change title of this issue to use xml-external instead of xml-data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants