Subject: RE: [xsl] Need help OR'ing in XPATH. From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx> Date: Thu, 23 Mar 2006 04:26:27 +0000 |
No, this is absolutely *not* recommended. If you use /text(), your code will
be sensitive to the presence of comments within the text, and it's very
unusual that you should want comments to make any difference.
<chapter> <owner>aaa <!-- second-->bbb <id>222</id> </owner> </chapter>
<owner> aaa <id>111</id> bbb </owner>
when both your suggestion and my suggestion will fail. mine <xsl:a-t select="book[owner/text()='aaa' or chapter/owner/text()='aaa']"/>
<xsl:a-t select="book[owner='aaa' or chapter/owner='aaa']"/>
<owner>aa<!--three stars-->a</owner>
then owner='aaa' will succeed, but owner/text() will fail.
No, this is absolutely *not* recommended
From: "Michael Kay" <mike@xxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: RE: [xsl] Need help OR'ing in XPATH. Date: Wed, 22 Mar 2006 12:49:57 -0000
> not that it will happen to you but its a best practice to > refer a text value > of a node by text(). > > <xsl:a-t select="book[owner/text()='aaa' or > chapter/owner/text()='aaa']"/> >
No, this is absolutely *not* recommended. If you use /text(), your code will
be sensitive to the presence of comments within the text, and it's very
unusual that you should want comments to make any difference.
owner='aaa' compares the string value of the owner element against the string 'aaa'. If the owner element is
<owner>aa<!--three stars-->a</owner>
then owner='aaa' will succeed, but owner/text() will fail.
Michael Kay http://www.saxonica.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Need help OR'ing in XPATH, Glen Mazza | Thread | RE: [xsl] Need help OR'ing in XPATH, Michael Kay |
Re: [xsl] A new Sudoku xslt impleme, Dimitre Novatchev | Date | Re: [xsl] A new Sudoku xslt impleme, Mukul Gandhi |
Month |