Subject: Re: [xsl] Move XML elements to one place using XSLT 2.0 From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Thu, 18 Mar 2010 11:05:04 +0000 |
On 18 March 2010 10:12, Jacobus Reyneke <jacobusreyneke@xxxxxxxxx> wrote: > Good day, > > This is a low priority request, but if someone has the time, please have a look. > > I have an XML document that outputs to XSL-FO using XSL 2.0. All was > well and happy until I tried to move all my notes in the XML file into > an Appendix (they currently appear structurally in the same place on > input and output). It's now a whole bottle or red wine later, but I > still don't have the answer (pleeshh helpsh me) > > I'm trying to change this: > <root> > <a> > <note>aaaa</note> > <b> > <note>bbbbb</note> > </b> > <c> > <note>cccc</note> > </c> > </a> > </root> > > Into: > <root> > <a> > <b> > </b> > <c> > </c> > </a> > <note>aaaa</note> > <note>bbbbb</note> > <note>cccc</note> > </root> > > Here comes the difficult part: How can I change the following style > sheet to do the re-shuffling without touching the first three > templates. Currently input and output structure is the same. Now I > need to grab the 'notes' and put them in one place but without > affecting the rest of my xslt. > > <xsl:template match="a"> > ........ > </xsl:template> > <xsl:template match="b"> > ........ > </xsl:template> > <xsl:template match="c"> > ........ > </xsl:template> > <xsl:template match="note"> > ........ > </xsl:template> you need: <xsl:template match="note"/> and: <xsl:template match="root"> <xsl:apply-templates/> <xsl:copy-of select="//note"/> </xsl:template> If you need to process note elements rather than just copy them, then apply-templates to them using a mode, and add that mode to your existing note matching template. cheers -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Move XML elements to one , Christian Roth | Thread | Re: [xsl] Move XML elements to one , Jacobus Reyneke |
Re: [xsl] Move XML elements to one , Christian Roth | Date | Re: [xsl] Move XML elements to one , Jacobus Reyneke |
Month |