[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Need help OR'ing in XPATH.
No, this is absolutely *not* recommended. If you use /text(), your code will Fair enough!! But Mike, I was concerned about a scenario where there might be other child nodes as stated in my example.. and I was not actually talking about the case where there are comments in the text nodes. like <chapter> <owner>aaa <id>222</id> </owner> </chapter> selecting owner in the above example would give you aaa and 222.. so to select just aaa, you WILL have to say owner/text()..Now Let me put the question back to you. What would you do if the xml was.. <chapter> <owner>aaa <!-- second-->bbb <id>222</id> </owner> </chapter> and you dont want the value of id to be in the output??? clearly your selecting owner would fail as it will be aaabbb and 222 and not just the text value of owner.. I agree that even owner/text() would fail in this case, as it will be just aaa and not aaabbb as we would think as aaa would be owner/text()[1] and bbb would be owner/text()[2] This is very similar to the case like .. <owner> aaa <id>111</id> bbb </owner> Your introduction of a comment node in the text and my introduction of an <id> node to me is not much different only that the comment nodes are ignored. and id node wont be. So The point you picked Mike , is definitely something to be careful about when you see it. because people will no doubt miss the point that the comment node is actually a node.Nevertheless, it is important for them to know what to do when they have a situation like.. <owner> aa<!---next text -->a <id>222</id> </owner> when both your suggestion and my suggestion will fail. mine <xsl:a-t select="book[owner/text()='aaa' or chapter/owner/text()='aaa']"/> will fail because owner/text() is aa and yours <xsl:a-t select="book[owner='aaa' or chapter/owner='aaa']"/> will fail because owner is aaa222 so <owner>aa<!--three stars-->a</owner> is not entirely true in all cases. and so .. No, this is absolutely *not* recommended is also not true in all the cases, especially the case i started off discussiong about, where there could be a child node. that is why i said.."you may not have this problem". The question again passes on to you to suggest on the best way for a case like <owner> aa<!---next text -->a <id>222</id> </owner> Vasu From: "Michael Kay" <mike@xxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: RE: Need help OR'ing in XPATH. Date: Wed, 22 Mar 2006 12:49:57 -0000 _________________________________________________________________ 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
|