Re: [xsl] Copying parent nodes with different selection of their content

Subject: Re: [xsl] Copying parent nodes with different selection of their content
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 25 Apr 2007 16:09:18 +0100
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0">
   
    <xsl:output indent="yes" />
   
    <xsl:variable name="copy-me">
        <Header>
            <Meta />
        </Header>
        <Body>
            <Document>
                <Preceding-1 />
                <Preceding-2 />
                <Make-Toute-Seul-1 />
                <Make-Toute-Seul-2 />
                <Make-Toute-Seul-3 />
                <Following-1 />
                <Following-2 />
            </Document>
        </Body>
    </xsl:variable>
   
   
    <xsl:template match="/">
      <xsl:apply-templates select="$copy-me/*"/>
    </xsl:template>
    
    <xsl:template match="Body">
      <xsl:variable name="x" select="Document/*[starts-with(name(),'Make-Toute-Seul-')]"/>
      <xsl:copy>
	<xsl:for-each select="$x">
	  <Document>
	    <xsl:copy-of select="(../* except $x)|."/>
	  </Document>
	</xsl:for-each>
      </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

Current Thread