Hi,
All right I neglected the example. Here is one:
Input doc:
[dongfang@granada xslt-examples]$ cat position-fun.xml
<?xml version='1.0'?>
<warehouse>
<item name="foo">
<country>Argentina</country>
</item>
<item name="bar">
<country>Brazil</country>
</item>
<item name="baz">
<country>China</country>
</item>
1st stylesheet:
[dongfang@granada xslt-examples]$ cat position-fun21.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl
utput method="xml" indent="yes"/>
<xsl:template match='warehouse'>
<position-experiment>
<first-try>
<xsl:apply-templates select='item/country | text()'/>
</first-try>
</position-experiment>
</xsl:template>
<xsl:template match='country[1]'>
<first-country>
(with "first", we mean: <xsl:value-of select="position()"/>)
<xsl:copy-of select='.'/>
</first-country>
</xsl:template>
<xsl:template name="notfirst" match='country'>
<xsl:copy-of select='.'/>
</xsl:template>
</xsl:stylesheet>
Output:
[dongfang@granada xslt-examples]$ xsltproc position-fun21.xsl
position-fun.xml
<?xml version="1.0"?>
<position-experiment>
<first-try>
<first-country>
(with "first", we mean: 2)
<country>Argentina</country></first-country>
<first-country>
(with "first", we mean: 4)
<country>Brazil</country></first-country>
<first-country>
(with "first", we mean: 6)
<country>China</country></first-country>
</first-try>
</position-experiment>
2nd stylesheet: Only difference is addition of child:: in match exp
[dongfang@granada xslt-examples]$ cat position-fun22.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl
utput method="xml" indent="yes"/>
<xsl:template match='warehouse'>
<position-experiment>
<first-try>
<xsl:apply-templates select='item/country | text()'/>
</first-try>
</position-experiment>
</xsl:template>
<xsl:template match='child::country[1]'>
<first-country>
(with "first", we mean: <xsl:value-of select="position()"/>)
<xsl:copy-of select='.'/>
</first-country>
</xsl:template>
<xsl:template name="notfirst" match='country'>
<xsl:copy-of select='.'/>
</xsl:template>
</xsl:stylesheet>
Output:
[dongfang@granada xslt-examples]$ xsltproc position-fun22.xsl
position-fun.xml
<?xml version="1.0"?>
<position-experiment>
<first-try>
<country>Argentina</country>
<country>Brazil</country>
<country>China</country>
</first-try>
</position-experiment>
[dongfang@granada xslt-examples]$
Some difference there.
As I get it, they should have been identical??
Soren