OZONE Asylum
Forums
CSS - DOM - XHTML - XML - XSL - XSLT
XPath confusion
This page's ID:
31796
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
All righty, I've worked with XPaths before, but it's been mostly trivial stuff, simple queries to return a single node based on various conditions (and all in C# before). I'm working on something a little more complicated now (and in C++ using libxml2), and I'm getting results that are making my head hurt. I need to pull out a node (and all its children and contents) and canonicalize it. I've got the following XML (not the complete doc, but enough for this example): [code]<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:SignedInfo> <ds:subnode>blah</ds:subnode> </ds:SignedInfo> </ds:Signature> </wsse:Security> </S:Header> <S:Body wsu:Id="Body-1-2cb7c7df3ee732dfa7f9a020ad2a5cd6" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> </S:Body> </S:Envelope>[/code] Using this XPath: (//. | //@* | //namespace::*)[ancestor-or-self::ds:SignedInfo] If I iterate through the nodeset returned from the xpath query, I get the following: [code]returned: 11 nodes Node: SignedInfo Node: subnode Node: text Node: http://www.w3.org/XML/1998/namespace Node: http://schemas.xmlsoap.org/soap/envelope/ Node: http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd Node: http://www.w3.org/2000/09/xmldsig# Node: http://www.w3.org/XML/1998/namespace Node: http://schemas.xmlsoap.org/soap/envelope/ Node: http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd Node: http://www.w3.org/2000/09/xmldsig#[/code] Am I missing something in the XPath? Is //namespace::* not filtered by "ancestor-or-self::ds:SignedInfo"? I think I have a solution that works, but I'd still like to understand what's going on a little better. LF -- Any sufficiently advanced bug is indistinguishable from a feature.
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »