Re: [xsl] applying templates to a variable for endnotes

Subject: Re: [xsl] applying templates to a variable for endnotes
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Thu, 25 Jul 2002 23:06:03 +0200
Cindy Mazza wrote:
That gives me the text, but without any styles applied.


Ah, now I get the problem:
    <xsl:variable name="div1notes">
       <xsl:element name="div2">
         <xsl:attribute name="id"><xsl:value-of select="$div1id"/>.notes</xsl:attribute>
             <xsl:element name="head">
                <xsl:text>Notes</xsl:text>
             </xsl:element>
             <xsl:for-each select="descendant::note">
               <xsl:number count="note" level="any" from="div1"/><xsl:text>. </xsl:text>
               <xsl:copy-of select="."/>
             </xsl:for-each>
       </xsl:element>
    </xsl:variable>
    <xsl:apply-templates select="$div1notes"/>

The variable "div1notes" is a RTF, you can't apply templates to it (check the spec for details). You can either apply templates during *building* the variable content and copy the variable into the result stream: <xsl:template match="note" mode="endnote"> <xsl:number count="note" level="any" from="div1"/><xsl:text>. </xsl:text> <xsl:apply-templates> </xsl:template > ...

     <xsl:variable name="div1notes">
        <div id="{$div1id}.notes>
           <!-- do whatever you do with "head" here -->
           <xsl:apply-templates select="descendant::note" mode="endnote"/>
        <div>
     </xsl:variable>
   ...
   <xsl:copy-of select="$div1notes"/>

The other possibility is to use an extension function which
converts the RTF to a node set. The details are processor
dependent, look into the documentation of your processor.
If you use MSXML, you'll have to resort to some embedded
script, check the archives of this list.

     <xsl:variable name="div1notes">
          ...
     </xsl:variable>

<xsl:apply-templates select="nn:node-set($div1notes)"/>

J.Pietschmann


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread