|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: position() returns doubled result - what do i miss
On Mon, 31 Mar 2003, jian wrote:
> i have :
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <root>
> <item>item1</item>
> <item>item2</item>
> <item>item3</item>
> <item>item4</item>
> <item>item5</item>
> <item>item6</item>
> <item>item7</item>
> <item>item8</item>
> <item>item9</item>
> </root>
>
>
>
> to which i apply:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
>
> <xsl:output method="html" version="4.01" encoding="UTF-8"/>
>
> <xsl:template match="/">
// here is your error, should be
<xsl:apply-templates select="root/item"/>
> <xsl:apply-templates match="root/item"/>
> </xsl:template>
>
> <xsl:template match="item">
// replaced this with:
<xsl:template match="//item">
> <xsl:value-of select="position()"/>
> <xsl:value-of select="."/>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
XSLT:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" version="4.01" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates select="root/item"/>
</xsl:template>
<xsl:template match="//item">
<p>
<xsl:value-of select="position()"/>
<xsl:value-of select="."/></p>
</xsl:template>
</xsl:stylesheet>
<p>1item1</p>
<p>2item2</p>
<p>3item3</p>
<p>4item4</p>
<p>5item5</p>
<p>6item6</p>
<p>7item7</p>
<p>8item8</p>
<p>9item9</p>
Cheers,
Jarkko
****************************************************************
Jarkko Moilanen "Erehtyminen on inhimillista,
Researcher mutta todella suuret mokat
jm60697@xxxxxx vaativat tietokoneen käyttöä."
www.uta.fi/~jm60697
GSM: +358 50 3766 927
****************************************************************
* ITCM | Information Technology and Crisis Management
* http://www.itcm.org
****************************************************************
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
|

Cart








