|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to get the preceding-sibling of parameter cont
Hi Deep,
At 01:56 AM 2/14/02, you wrote: <xsl:template name="mytemplate"> <xsl:param name="contextnode"/> <xsl:for-each select="$contextnode"> //How to get the preceding-sibling of context node here following does not work This doesn't work because '$contextnode', a variable reference, is not a valid node test. (A node test is the part of a location step, in an XPath, that comes after the '::', which is part of the axis identifier.) But you have the correct axis. count(preceding-sibling::*[@name='data']) will count those sibling elements preceding the context node that have a @name attribute = 'data'. The node test here is '*' (tests true for any node of the primary node type of the axis, here elements). count(preceding-sibling::mything[@name='data']) will count those 'mything' sibling elements preceding the context node that have a @name attribute = 'data'. The node test here is 'mything' (tests true for any node named 'mything' on the axis). count(preceding-sibling::*[name()=name($contextnode)][@name='data']) will count those sibling elements preceding the context node whose name is the same as that of $contextnode, and that have a @name attribute = 'data'. The node test here is again '*', but you are then filtering the elements by testing their names against the name of $contextnode. I don't know if you actually need the [@name='data'] test, which checks the value of a @name attribute. If that's what you want to do, great. I hope that helps. You might find a good breakdown of how XPath works, like that in Mike Kay's book, to be illuminating. Cheers, Wendell
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
|

Cart








