xsl-list
[Top] [All Lists]

RE: XSL resources - Flat to hierarchy - Common ancestors

2004-07-27 01:14:03
2. Transforming 'flat' structures to hierarchies:
....

Wrap the first apply-templates into a variable, use your processors
node-
set()
function (see your processors documentation on how to implment this)
to
convert
the result into a node-set and then apply-templates or for-each
through
the
resulting node-set using <xsl:number/> to accomplish the task

I'm supposed to be doing something else, but I just had to try this out
:)
Having 'learnt' XSL by cut and paste, I think I'm still at the stage
where I need subtitles.
I added xmlns:msxsl="urn:schemas-microsoft-com:xslt" to my
xsl:stylesheet declaration, and my first template now looks like this:

<xsl:template match="/">
  <xsl:variable name="menus">
        <xsl:apply-templates select="Menus"/>
  </xsl:variable>       
  <xsl:for-each select="msxsl:node-set($menus)">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:attribute name="TOC">
        <xsl:number level="multiple" format="1.1"/>
      </xsl:attribute>  
    </xsl:copy>
  </xsl:for-each>  
</xsl:template>

Obviously, it doesn't work, otherwise I wouldn't be posting. I guess
what I don't understand is whether my for-each is for each node in the
nodeset.  You suggested mayb using an apply-templates, but I don't
really understand how to do an apply templates which won't eat my other
menus upstream (ok, I'll be honest, I just don't understand
apply-templates ;)

Ben