|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: how to get position()
Vinoth Palaniappan wrote: > If i calculate the expression "position() -1" as > <xsl:for-each select="child::*"> > <xsl:variable name="test_var" select="position() - > 1"></xsl:variable> > <xsl:apply-templates> select="."></xsl:apply-templates> > </xsl:for-each> > I get the series i want(0, 1, 2..) but i'm unable to use the > variable as > <xsl:template match="nv_pair"> > <xsl:number level="single" count="nv_pair" from="nv_pair"/> > <xsl:copy-of select="$test_var"/> > </xsl:template> > because i get an error that the variable is "out-of-context". How can i > bring that variable within the scope(context). You can pass it as a parameter to the template that you are calling, but there's no need to even do that. Instead of the for-each, do this: <xsl:apply-templates select="*"/> And then you can use position() within the templates that match. For example, instead of the xsl:copy-of, use <xsl:value-of select="position() -1"/> - Mike ____________________________________________________________________________ mike j. brown | xml/xslt: http://skew.org/xml/ denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/ 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








