xsl-list
[Top] [All Lists]

RE: Problem with generating sequence ids.

2005-07-06 06:09:27
Hi,

I want the xslt code to get the result as
<A1 sequence="1" id="001000000000000">
         <B1 sequence="3" id="001003000000000"/>
         <B2 sequence="1" id="001001000000000">
                  <C1 sequence="4" id="001001004000000"></C1>
                  <C2 sequence="11" id="001001011000000">
                           <D1 sequence="01" id="001001011001000"/>
                  </C2>
         </B2>
</A1>

Steps to generate id value :
[snip]

Unfortenately I didn't have time to read you explanation how the IDs should be 
generated, I only compared the input and desired output. Hope it's what you 
need.

<xsl:template match="*">
  <xsl:copy>
        <xsl:copy-of select="@*"/>
        <xsl:attribute name="id">
                <xsl:for-each select="(ancestor-or-self::*)">
                        <xsl:number value="@sequence" format="001"/>
                </xsl:for-each>
                <xsl:value-of select="substring('00000000000000', 
count(ancestor-or-self::*) * 3)"/>
        </xsl:attribute>
        <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

Cheers,

Jarno

--
Nu Energy Collective: Logic dec 2004

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>