Sorry about that. Please try this stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/Root">
<Root>
<xsl:for-each select="Item">
<xsl:sort select="Line_No" data-type="number" />
<New_Item>
<xsl:variable name="x" select="substring(Line_No, 1,
1)" /> <xsl:variable name="pow_result">
<xsl:call-template name="pow">
<xsl:with-param name="m" select="10" />
<xsl:with-param name="n" select="string-length(Line_No) - 1"
/>
<xsl:with-param name="result" select="10" />
</xsl:call-template>
</xsl:variable>
<Line_No><xsl:value-of select=" ($x * $pow_result) +
count(preceding::Line_No[substring(., 1, 1) = $x] )+ 1" /></Line_No>
<Line_No_Og><xsl:value-of select=" Line_No" /></Line_No_Og>
<Amount><xsl:value-of select="Amount" /></Amount>
</New_Item>
</xsl:for-each>
</Root>
</xsl:template>
<!-- Template to calculate m to the power n -->
<xsl:template name="pow">
<xsl:param name="m" />
<xsl:param name="n" />
<xsl:param name="result" />
<xsl:choose>
<xsl:when test="$n > 1">
<xsl:call-template name="pow">
<xsl:with-param name="m" select="$m" />
<xsl:with-param name="n" select="$n - 1" />
<xsl:with-param name="result" select="$result * $m" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$result" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Regards,
Mukul
On 6/23/06, rostom aghanian <rostom(_at_)mail(_dot_)com> wrote:
Thanks Gandi. I tried your stylesheet and it is very good with just one
problem: I need the renumbering to begin only for each 100th group; not each
10th group as your stylesheet does. For example:
801 --> 801 (begin 800 group)
802 --> 802
806 --> 803 (notice new Line_No is continuous, wheras original skipped)
814 --> 804 (NOTICE 800 series counting continues as we haven't reached next
100 series yet)
901 --> 901 (notice numbering re-starts at the 1s for a new group (900s))
944 --> 902 (NOTICE 900 series counting continues as we haven't reached next
100 series yet)
1002 --> 1001 (notice numbering re-starts at the 1s for a new group (1000s))
1003 --> 1002 (numbering continues consecutively in the 1000's group)
Thanks in advance.
rostom
--~------------------------------------------------------------------
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>
--~--