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

XPath queries do not work with namespaces and fixed encoding property #17

Merged
merged 10 commits into from Jun 8, 2014

Conversation

rhodgkins
Copy link
Contributor

Hello (again!)

I noticed that any XPath queries containing namespaces //ns1:tagname would fail with the error:

XPath error : Undefined namespace prefix
XPath error : Invalid expression

I've added a test case for this issue and the Travis build file to ensure the tests on my fork pass :)
https://travis-ci.org/rhodgkins/Ono/builds/26876794

@rhodgkins
Copy link
Contributor Author

The fix registers any namespaces on the ONOXMLElement that is being queried. Any unprefixed namespaces (such as xmlns="http://www.w3.org/2005/Atom" in the atom.xml example) are ignored.
https://travis-ci.org/rhodgkins/Ono/builds/26877560

The only other issue I think might still exist is if there are any namespaces that are declared in nested elements - for example:

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <entry xmlns:nested="http://purl.org/dc/elements/1.1/">
    <nested:title>Atom-Powered Robots Run Amok</nested:title>
    <dc:language>en-us</dc:language>
  </entry>
</feed>

The nested namespace wouldn't be picked up if querying the root node for //nested:title. I'm not really sure if this is an actual use case or if its even possible to register all the namespaces without traversing the whole tree?

@rhodgkins
Copy link
Contributor Author

Also fixed rhodgkins#1

@rhodgkins rhodgkins changed the title XPath queries do not work with namespaces XPath queries do not work with namespaces and fixed encoding property Jun 7, 2014
mattt added a commit that referenced this pull request Jun 8, 2014
XPath queries do not work with namespaces and fixed encoding property
@mattt mattt merged commit 4df3780 into mattt:master Jun 8, 2014
@mattt
Copy link
Owner

mattt commented Jun 8, 2014

Thanks so much for your help on this, @rhodgkins. This is excellent work. I'll tag a new release now.

@rhodgkins
Copy link
Contributor Author

No problem @mattt, thanks for the great working creating this in the first place!

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

Successfully merging this pull request may close these issues.

None yet

2 participants