Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XPath selection inconsistencies >Thread Next - Re: XPath selection inconsistencies Re: XPath selection inconsistenciesTo: NULL Date: 9/1/2006 10:41:00 AM "J" <jason.jones@s...> wrote in message news:1157068267.861452.252640@m...... > Has anyone seen something like this before? > > I am using MSXML 4 with VB6. I have XML similar in structure to: > > <xml> > <a> > ... > <b> > ... > <c> > ... > <d>1234</d> > </c> > </b> > </a> > <a> > ... > </a> > ... > </xml> > > And attempt to select a node with an XPath query of the form (I'll call > it 'form 1'): > "a/b[c/d='1234']" > > When the xml has been freshly loaded into the DOMDocument40 (from disk) > this query executes fine. However, when certain processes, which remove > nodes and replace them with exactly the same structure, but slightly > different values (ie, "...<d>5678</d>..."), are performed first, the > query (form 1, with updated values) returns without finding a node. > > A reasonable workaround has been found, by simply changing the XPath > query to what I will call 'form 2': > "a/b[c/d[text()='5678']]" > > I am aware of the semantic differences of the two forms- that is, I > presume that I know all of them: I know that the text() function will > refer to the textnode(s?) that is an immediate child of the current > context (in this case, the 'd' element), while the other (form1) will > be a combination of the textnodes of the current context, and > (recursively) all its child elements. > These differences should not be an issue with the XML in question, > because the 'd' node will never have anything more than a single > textnode (no elements) child. > > So I am looking for the reason that these two XPath forms are behaving > differently. Because this behavior has been found in one situation in > a large enterprise application, I need to know if there is going to be > risk of failure in the large number of other 'Form 1' XPath queries. > > Unfortunately, I have been unable to reproduce the behavior on a > smaller scale (the a/b/c/d example, for instance), and there is an > overwhelming amount of code (the 'certain processes' mentioned above) > that could be creating the MSXML state that causes Form1 to fail. > > So I am looking for brainstorms. Perhaps this will ring a bell with > someone with more experience with MSXML than I have. > > Has anyone seen anything similar before? > > Thanks, > Can you post some VB6 code for a repro? > J > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
