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

Selecting element using attribute not working #4

Closed
svadla-oc opened this issue Dec 31, 2019 · 8 comments
Closed

Selecting element using attribute not working #4

svadla-oc opened this issue Dec 31, 2019 · 8 comments
Assignees

Comments

@svadla-oc
Copy link

When I try to select an xml element using an attribute, I get a blank string as result.
To reproduce:
Evaluate the expression: "/data/a[@id='1']" against the attached test.xml file.

test.xml.zip

@MartijnR
Copy link
Member

This is quite mysterious. Thank you. Will figure this out!

@svadla-oc
Copy link
Author

Thank you!

@MartijnR
Copy link
Member

MartijnR commented Jan 2, 2020

The XPath evaluator was not 'bound' correctly to the XMLDoc.

@svadla-oc
Copy link
Author

Martijn - Thanks for fixing the issue. The previously reported test is working now. However, a more complex expression like the one below doesn't seem to be working correctly against the attached ODM file. It seems like the tool doesn't like mixed-case attribute names.

Expression: "/ODM/ClinicalData/SubjectData/StudyEventData[@StudyEventOID='SE_BASELINE']/FormData[@Formoid='F_DEMOGRAPHICS']/ItemGroupData[@ItemGroupOID='IG_DEMOG_GROUP2']/ItemData[@ItemOID='I_DEMOG_DIAGNOSED']/@value"

odm.xml.zip

@svadla-oc svadla-oc reopened this Jan 3, 2020
@MartijnR
Copy link
Member

MartijnR commented Jan 3, 2020

Probably something to do with XML parsing.

No, it's not. The JSDOM built-in XPath evaluator has this problem: jsdom/jsdom#2530. However, we're not using that one. So this may still be an issue with how the new evaluator overwrites the 'native' one.

It looks like the issue is with Enketo's XPath evaluator. I wonder if this is an undiscovered bug (and that our mixed use of the native XPath evaluator has failed to discover this so far.

  • check enketo-xpathjs - No problem

@MartijnR
Copy link
Member

MartijnR commented Jan 7, 2020

Any custom ODK and OC functions are no longer working. So it's reverting to the JSDOM xpath evaluator, and not Enketo's.

@MartijnR
Copy link
Member

MartijnR commented Jan 7, 2020

  • try different DOMParser - not dom-parser
  • try XMLDom - works
  • fix OC XPath extensions
  • fix capitalized attributes (because those are not working - check new DOM Parser)

@MartijnR
Copy link
Member

MartijnR commented Jan 7, 2020

Trying to do this in a minimal nodeJS environment (without running in a headless browser) is a little trickier than I thought. It's fixed now. Hopefully, that was the last such issue... Thankfully, the fix actually made the app simpler.

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

2 participants