[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Need help OR'ing in XPATH.
You were pretty much there..
try this,, <xsl:a-t select="book[owner='aaa' or chapter/owner='aaa']"/> not that it will happen to you but its a best practice to refer a text value of a node by text(). In case you have child nodes for owner then u will find yourself troubled. let us assume you had a structure like <book id="1"> <owner>aaa <id>111</id> </owner> <chapter> <owner>aaa <id>222</id> </owner> </chapter> <chapter> <owner>ccc</owner> </chapter> </book> <book id="2"> <owner>bbb</owner> <chapter> <owner>bbb</owner> </chapter> <chapter> <owner>ccc</owner> </chapter> </book> then <xsl:a-t select="book[owner='aaa' or chapter/owner='aaa']"/> will not select any of the nodes in the above XML. as owner will actually give you the text value of the node and the text value of all the children under the node. so you would be wanting to be safe and rewrite the statement as <xsl:a-t select="book[owner/text()='aaa' or chapter/owner/text()='aaa']"/> by above you are asking for the text value of the node called owner. so you would think this makes perfect sence. but since you see that the text value actually is not just 'aaa' but has some whitespaces, the above statement will also fail to cater to your needs. So you would want to be safe and rewrite the above statement as <xsl:a-t select="book[normalize-space(owner/text())='aaa' or normalize-space(chapter/owner/text())='aaa']"/> This will clearly tell what you want. As I said earlier, you may not have the problem with your XML, <xsl:a-t select="book[owner='aaa' or chapter/owner='aaa']"/> will still work..... but as i had pointed to you It WONT work if the owner has a child node .. be it an empty space node like <owner> aaa </owner> or a valid XML element. like <owner> aaa <id>1111</id> </owner> so be safe..... and specify exactly what you want the processor to do. HTH Vasu On 3/22/06, Glen Mazza <grm7793@xxxxxxxxxxx> wrote: _________________________________________________________________ Are you using the latest version of MSN Messenger? Download MSN Messenger 7.5 today! http://join.msn.com/messenger/overview
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|