[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Counting and Rearranging Nodes
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@xxxxxxxx> 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:
|
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
|