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

Namespace decl nodes can be returned by xpath expressions #61

Open
jbowtie opened this issue Nov 20, 2013 · 2 comments
Open

Namespace decl nodes can be returned by xpath expressions #61

jbowtie opened this issue Nov 20, 2013 · 2 comments

Comments

@jbowtie
Copy link
Contributor

jbowtie commented Nov 20, 2013

In my testing I've noticed that an XPath expression can return an namespace declaration node ("foo/namespace::bar", for example).

The generic XmlNode.Content() will return the URL - unfortunately there doesn't seem to be a way to access the prefix. The obvious hack of getting the parent node and searching for the declaration fails because namespace declarations are on their own axis and don't actually have parents.

I don't know what the right solution here is, but we'll possibly want a new type that derives from Xml.Node but is aware it wraps an C.xmlNsPtr

Thoughts?

@mdayaram
Copy link
Contributor

Sorry for the delay on feedback for this, slipped through the cracks.

Anyways, I'm having a hard time wrapping my head around it all. Can you provide an example program that exploits the issue?

@jbowtie
Copy link
Contributor Author

jbowtie commented Jan 14, 2014

This is pretty much an edge case - most people don't construct XPath expressions to select namespace nodes - but needed for correctness when implementing XSLT or XQuery on top of gokogiri.

For example, the XSLT 1.0 spec requires xsl:copy to handle namespace nodes returned from an XPath by outputting the namespace declaration (with the same prefix and URI) to the destination. I've never seen this done outside a contrived example, but you never know.

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