Thank you very much Christian! (my mistake for confusing equality and inequality in consideration of your previous response) Kind regards Jan
-----Original Message----- From: Christian Grün christian.gruen@gmail.com Sent: Wednesday, May 26, 2021 13:28 To: ydyxeb@post.cz Cc: BaseX basex-talk@mailman.uni-konstanz.de Subject: Re: [basex-talk] BUG node comparison
Hi Jan,
However, I still don't understand, why the -w parameter should do the trick. I would expect the parsing is done once on the document load and $rootElement variable is just holding a document's node. Then string value of either $rootElement and parent::* should be identical for identical nodes. Do I miss something?
Yes, the parsing is done only once, and $rootElement will contain the root element of this document. Let’s assume we have this input document:
<a> <b> <c/> </b> </a>
If -w is omitted, the whitespaces (4 text nodes, in the example) will be dropped, and we’ll be left with the plain element structure:
<a><b><c/></b></a>
Let’s now assume we have this query:
//c[.. != /a]
The path returns the element named "c" if the string value of its parent differs from the string value of "a": • If the whitespaces of the document are preserved, the comparison will be successful, because "a" has the string value "\n \n \n \n", whereas "b" has the string value "\n \n ". • If whitespaces are dropped, the comparison will return false, because the string values of both elements will be the empty string.
Does this make sense to you? Christian