Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XPath selection inconsistencies

From: "Anthony Jones" <Ant@------------.--->
To: 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
>




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent