xsl-list
[Top] [All Lists]

Re: [xsl] flattening and re-ordering nested notes

2008-08-18 14:43:27

On Aug 18, 2008, at 4:45 PM, Andrew Welch wrote:

I wrote:

<xsl:template match="document">
       <xsl:copy>
               <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
       <xsl:apply-templates select="//note" mode="notes"/>
</xsl:template>

you have:

<xsl:template match="document">
       <xsl:copy>
               <xsl:apply-templates select="@*|node()"/>
<xsl:apply-templates select="//note[not (@type='margin' or
@type='sourcenote')]" mode="notes"/>
       </xsl:copy>
</xsl:template>

The apply-templates for notes has moved back inside xsl:copy - it
needs to be outside for the <note>'s to be output after <document>.


If you look back to my pastie, you'll see that I did want the notes inside the document, just after any other elements (divs, mostly) and all at the same level as any other content within the document.

Here's what I ended up with, and it is working:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
<xsl:template match="@*|node()">
        <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
</xsl:template>
<xsl:template match="note" mode="notes">
        <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
</xsl:template>
<xsl:template match="note[(_at_)type !='margin' and @type != 'sourcenote']"/>

<xsl:template match="document">
        <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
<xsl:apply-templates select="//note[(_at_)type !='margin' and @type != 'sourcenote']" mode="notes"/>
        </xsl:copy>
</xsl:template>

</xsl:stylesheet>


Thanks again very much for your help, you saved the day.

Walter

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