View Single Post
  #4 (permalink)  
Old March 15th, 2011, 10:56 AM
Martin Honnen Martin Honnen is offline
Friend of Wrox
Points: 6,673, Level: 34
Points: 6,673, Level: 34 Points: 6,673, Level: 34 Points: 6,673, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,242
Thanks: 0
Thanked 244 Times in 243 Posts
Default

Did you use the code as posted? When I use the stylesheet
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  
<xsl:template match="@* | node()" name="identity">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="work/prelim/tools | work/prelim/parts">
  <xsl:copy-of select="../following-sibling::main/planning"/>
  <xsl:call-template name="identity"/>
</xsl:template>

<xsl:template match="work[prelim/tools | prelim/parts]/main/planning"/>

</xsl:stylesheet>
against the input
Code:
    <work>
        <prelim>
            <code>ABC</code>
            <source>DEF</source>
            <tools>Includes codes for a table</tools>
        </prelim>
        <main>
            <planning>Text for Planning</planning>
            <p>blah blah blah</p>
        </main>
    </work>
with Saxon 6.5.5 the output is
Code:
<?xml version="1.0" encoding="utf-8"?><work>
        <prelim>
            <code>ABC</code>
            <source>DEF</source>
            <planning>Text for Planning</planning><tools>Includes codes for a table</tools>
        </prelim>
        <main>

            <p>blah blah blah</p>
        </main>
    </work>
So that way the element "planning" is removed from the "main" element.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Reply With Quote