[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Strange Parameter Behavior
Thanks to all who responded. Tripped up yet again by the wily nuances of
XPath :) There were two things at work here:
1. For some reason, I figured if I specified the first matching c element, it would select only one node: <xsl:param name="param-id" select="/a/b/c[1]/@id"/> But in fact it returns a node-set with the first c in every b of every a. 2. Which explains the results: param-id: 3 prev: 6 next: 4 Since $param-id actually refers to a node-set, the equality operator behaves a little differently. In this case, the $param-id node-set contains: <c id="3"/> <c id="8"/> <c id="12"/> As such, the first part of the XPath in question matches a node-set as well, containing the above 3 nodes: //c[@id = $param-id] But since the first c has no preceding c, the entire XPath matches only the 2 nodes with preceding c's: //c[@id = $param-id]/preceding::c[1]/@id <c id="6"/> <c id="10"/> So the value-of must implicitly return just the first of these 2 matches, which is <c id="6"/> The correct solution in my case is either of: <xsl:param name="param-id" select="(/a/b/c)[1]/@id"/> <xsl:param name="param-id" select="/a[1]/b[1]/c[1]/@id"/> As suggested by a couple of you. Again, thanks. I hope I'm close; something just clicked and I hope it wasn't my hip :) Mike From: "Michael Peet" <mjpeet@xxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Strange Parameter Behavior Date: Thu, 09 May 2002 17:01:41 -0400 _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|