[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: position
Thanks Ken, this works. I hadn't thought of using <xsl:number/>. The output, though, starts with '0', so the first note is numbered '0' but I solved this by putting the lot into a variable and upping it by 1. Thanks for you help, Mick -----Oorspronkelijk bericht----- Van: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] Namens G. Ken Holman Verzonden: 14 februari 2004 14:47 Aan: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Onderwerp: Re: position At 2004-02-14 14:02 +0100, m.vanrootseler@xxxxxxxxx wrote: >I'm having trouble using position() in the following situation. >... > <xsl:for-each select="//note"> > <xsl:value-of select="position()"/> In the above you are setting the current node list to all of the notes, and then using that for your count ... which works because of how you set the current node list. ><xsl:template match="line"> > <xsl:apply-templates/> Above you are setting the current node list to the children of line, not to anything related to note. ><xsl:template match="w"> > <xsl:text> </xsl:text> > <xsl:apply-templates/> > <xsl:if test="note"> > <span >style="vertical-align:super;font-size:7pt">*</span> ><!-- --------------------------------------------------------^ position >should go here --> Not "position" but the count of notes goes there ... remember that position() is *always* based on the current node list, and based on your template rules your current node list is not comprised solely of <note> elements. >Instead of the asterisk in the <span>, I'd like to put the value of the >position of the <note> there, The facility to count items in the source node tree is <xsl:number>: <xsl:number count="note" level="any"/> >just like I did in the root template >(where it works as it should), "it works" because of how you prepared your current node list. It is also working in your other match, but you haven't prepared the current node list accordingly, so you cannot use position() because it is based solely on the current node list. I hope this helps. ............................ Ken -- Public courses: upcoming world tour of hands-on XSL training events Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 Hong Kong: 2004-05-17 Germany: 2004-05-24 England: 2004-06-07 World-wide on-site corporate, government & user group XML training! 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 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list 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
|