xsl-list
[Top] [All Lists]

Re: [xsl] Obtaining a specific context position()

2009-11-08 17:59:22
Hi David,
That worked just fine.
I misunderstood the nature of XSLT variables and was under the impression that once initialized their value could not be changed. Clearly, I need to re-read that section of the book.

I am actually generating a series of id's and need the value of the id to be constant across files. My reading of gererate-id() was that the id could change each time the file was processed. and that it was not recommended for use in hyperlinks between different HTML files. (Michael's book on XSLT and XPath).

Thanks,
Mark

--------------------------------------------------
From: "David Carlisle" <davidc(_at_)nag(_dot_)co(_dot_)uk>
Sent: Sunday, November 08, 2009 2:35 PM
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: Re: [xsl] Obtaining a specific context position()


the value returned by position() is unrelated to the position of the node
in the source tree, it is just a function of the context selected by the
current xpath (for example if you select a node with . then it has
position()=1 whevever it appears in the source)

It's not clear really what you want for the subdiv version, in your
posted sample it was the same value as in the heading, in which case you
can just save it in a variable and use it twice.


<xsl:variable name="h" select="position()"/>

              <Heading>
                 <xsl:value-of select="$h"/> <!-- first call -->
               </Heading>

<xsl:for-each-group select="current-group()" group-by="SubDiv1"> <xsl:sort select="current-grouping-key()" collation="{$sorting-collation}"/>

                   <SubDiv1>
                 <xsl:value-of select="$h"/> <!-- second call -->

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>