xsl-list
[Top] [All Lists]

RE: Using <xsl:number>

2004-06-08 23:35:03
Hi,

What I want to do is add a sort-order property to each
Scope tag, which identifies its relative position at
each level of the heirarchy among its peers only. 
That is to say, the sort-order tag should be added
like this:

<Data>
      <Scope id="1" sort-order="1">
              <Scope id="2" sort-order="1"/>
              <Scope id="3" sort-order="2"/>
      </Scope>
      <Scope id="4" sort-order="2">
              <Scope id="5" sort-order="1">
                      <Scope id="6" sort-order="1"/>
                      <Scope id="7" sort-order="2"/>
              </Scope>
              <Scope id="8" sort-order="2">
                      <Scope id="9" sort-order="1">
                              <Scope id="10" sort-order="1"/>
                              <Scope id="11" sort-order="2"/>
                      </Scope>
                      <Scope id="12" sort-order="2"/>
              </Scope>
      </Scope>
      <Scope id="13" sort-order="3"/>
</Data>

  <xsl:template match="Scope">
    <xsl:copy>
      <xsl:attribute name="sort-order">
        <xsl:number />
      </xsl:attribute>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

If you want to specify the attributes in xsl:number, they're

  <xsl:number level="single" count="Scope" from="Scope"/>

Cheers,

Jarno - Velvet Acid Christ: The Dead (Alive mix by Funker Vogt))


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