[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: flattening and re-ordering nested notes

Subject: Re: flattening and re-ordering nested notes
From: Walter Lee Davis <waltd@xxxxxxxxxxxx>
Date: Mon, 18 Aug 2008 17:42:58 -0400
Re:  flattening and re-ordering nested notes
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[@type !='margin' and @type != 'sourcenote']"/>


<xsl:template match="document">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:apply-templates select="//note[@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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.