[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Position() in apply-templates
Hi David,
There is no conflict between what the references tell you To quote the example from Jeni Tennison's post <xsl:template match="/"> <xsl:apply-templates select="r/a"> <xsl:sort data-type="number" select="@at"/> <xsl:with-param name="p" select="position()"/> </xsl:apply-templates> </xsl:template> What you read in Michael Kay's book is that the nodes in the select of the apply-templates "r/a" are selected, ordered according to the sort statement(s) and then numbered. The position() inside the template that will eventually pick up the nodes will have that number as its value <xsl:template match="r/a"> <xsl:value-of select="position()"/> <= here is where the numbering of the nodes plays </xsl:template> What Jeni Tennison says is that the position() inside the body of the apply-templates eg here: <xsl:with-param name="p" select="position()"/> will get its value from the context of the template, not from the node numbering in the select. apply-templates will not change the context, for-each on the other hand will create a new context I hope that helps Geert At 23:18 1/04/2014, you wrote: Can someone clarify the meaning of "position()" in apply-templates.
|
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
|