Brilliant, works perfectly, thank you so much David.
As usual, I got an excellent, quick response. This is very much
appreciated and helps so much in learning.
Lech
On Thu, Apr 3, 2008 at 4:47 PM, David Carlisle
<davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
> or is it better to use saxon:assign for that?
It's never better to use saxon:assign, assigning to variable references
in this way completely breaks the processing model of xslt.
> My initial approach was to simply use <xsl:number/>
what was wrong with that approach?
It would seem that you just want
xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="group">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="number"><xsl:number/></xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="item">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="number"><xsl:number count="group|item"
level="multiple" format="1-1" /></xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
$ saxon num.xml num.xsl
<?xml version="1.0" encoding="utf-8"?><top>
<group number="1">
<item number="1-1">test</item>
<item number="1-2">test</item>
<item number="1-3">test</item>
<item number="1-4">test</item>
</group>
<group number="2">
<item number="2-1">test</item>
<otheritem>test</otheritem>
<item number="2-2">test</item>
<item number="2-3">test</item>
<item number="2-4">test</item>
</group>
</top>
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--