Subject: Re: [xsl] flattening and re-ordering nested notes From: Walter Lee Davis <waltd@xxxxxxxxxxxx> Date: Mon, 18 Aug 2008 13:37:35 -0400 |
Put in the effort to create an example input and required output and someone might post the code to turn that input into that output...
Thanks in advance if you can help:
http://pastie.org/254986
So the sample input is:
[snip] Better than nothing, but both can be shortened down to:
Input:
<publication> <document> <div> <note id="note1"> <note id="note2"/> </note> </div> </document> </publication>
Output:
<publication> <document> <div/> <note id="note1"/> <note id="note2"/> </document> </publication>
...which demonstrates the same problem, but with all unrelated information removed. This sort of small, complete example is what you should be aiming for when posting a question to a mailing list.
Here's a transform that should do what you need:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:template match="@*|node()" mode="#all"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
<xsl:template match="note"/>
<xsl:template match="document"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> <xsl:apply-templates select="//note" mode="notes"/> </xsl:template>
</xsl:stylesheet>
If you are stuck with 1.0 it will take a bit more effort because it doesn't have mode="#all" (you just have to copy the identity template and put it in the mode="notes")
-- Andrew Welch
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] flattening and re-orderin, Andrew Welch | Thread | Re: [xsl] flattening and re-orderin, Walter Lee Davis |
Re: [xsl] copy of specific elements, henry human | Date | Re: [xsl] flattening and re-orderin, Walter Lee Davis |
Month |