|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: One pass or two?
At 99/08/25 16:32 +0100, DPawson@xxxxxxxxxxx wrote:
Sorry Ken, I'm not explaining very well: Sorry, Dave, I must not be answering very well. :{)} source document has an element <q> which ... but it is available from the input at all times during the run. For what you need, you need only go over the source tree twice, once for the table of contents and once for the body (or, of course, any other times you may wish to visit the source tree). Each time around you use generate-id(.) in a different construct of the result tree, but because it is one run of the XSLT engine the value returned for a given node is guaranteed to be the same. As soon as you finish the run that guarantee is gone ... the next time around you must treat the value created by generate-id(.) as brand new, even if it coincidentally happens to be what it was before. Note that the value generated for the result tree comes from the node in the source tree ... you aren't asking anything about the result tree. I hope the example below helps. ........... Ken T:\dave>type test.xml <?xml version="1.0"?> <test> <q>blah 1</q> <q>blah 2</q> </test> T:\dave>type test.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"> <xsl:output indent="yes"/> <xsl:template match="/"> <!--root rule--> <H4>Toc</H4> <xsl:for-each select="//q"> <p><a href="" select="."/></a></p> </xsl:for-each> <body> <xsl:apply-templates/> </body> </xsl:template> <xsl:template match="q"> <p><a name="{generate-id(.)}"><xsl:value-of select="."/></a></p> </xsl:template> </xsl:stylesheet> T:\dave>call xsl test.xml test.xsl test.htm T:\dave>type test.htm <H4>Toc</H4> <p> <a href="" 1</a> </p> <p> <a href="" 2</a> </p> <body> <p> <a name="N3">blah 1</a> </p> <p> <a name="N6">blah 2</a> </p> </body> T:\dave> --
G. Ken
Holman
mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights
Ltd.
http://www.cranesoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0
+1(613)489-0999 (Fax:-0995)
Website: XSL/XML/DSSSL/SGML services, training, libraries,
products.
Practical Transformation Using XSLT and
XPath ISBN 1-894049-01-2
Next instructor-led
training:
MT'99 1999-12-05/06
|
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








