[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: context position incorrect

Subject: Re: context position incorrect
From: "Randall Parker" <randall@xxxxxxx>
Date: Tue, 27 Jun 2000 20:33:06 -0700
position last
Steve,

I believe that it is working correctly. The positions reported are the positions in the parsed tree. That tree contains all the elements, not just the elements your XSLT rules specify to be outputted. So the 
positions are the positions relative to all the elements rather than just relative to the outputted elements. 

If you really seek to achieve what you expected then I think it is possible. See the third line I added below to your match on "item".

<xsl:template match="item">
	*<xsl:value-of select="@a"/>*
           <xsl:number count="."/>
	position = <xsl:value-of select="position()"/>
	last = <xsl:value-of select="last()"/>
</xsl:template>

On Wed, 28 Jun 2000 10:24:00 +1000, Steve Brown wrote:

>Hi,
>am having a problem with the position function and am hoping its my lack of
>knowledge rather than Xalan. The XSL below:
>
><?xml version="1.0"?>
><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>version="1.0">
>
><xsl:template match="list">
>	<xsl:apply-templates select="item[@include='yes']"/>
></xsl:template>
>
><xsl:template match="item">
>	*<xsl:value-of select="@a"/>*
>	position = <xsl:value-of select="position()"/>
>	last = <xsl:value-of select="last()"/>
></xsl:template>
>
></xsl:stylesheet>
>
>
>is run on this XML:
>
>
><?xml version="1.0"?>
><list>
>	<item a="1" include="yes"/>
>	<item a="2" include="no"/>
>	<item a="3" include="no"/>
>	<item a="4" include="no"/>
>	<item a="5" include="yes"/>
>	<item a="6" include="yes"/>
>	<item a="7" include="yes"/>
></list>
>
>to give:
>
>        *1*
>        position = 1
>        last = 4
>        *5*
>        position = 5
>        last = 4
>        *6*
>        position = 6
>        last = 4
>        *7*
>        position = 7
>        last = 4
>
>I thought it would give:
>
>        *1*
>        position = 1
>        last = 4
>        *5*
>        position = 2
>        last = 4
>        *6*
>        position = 3
>        last = 4
>        *7*
>        position = 4
>        last = 4
>
>Any ideas?
>Thanks,
>Steve.
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.