[xsl] problems with xsl:copy instruction

Subject: [xsl] problems with xsl:copy instruction
From: Rahil <qamar_rahil@xxxxxxxxxxx>
Date: Thu, 26 May 2005 15:28:19 +0100
Hi

My understanding of how the <xsl:copy> and <xsl:copy-of> commands is weak and so am having trouble figuring out the exact problem.

I want to copy all the contents of an output(held in memory), say interim.xml, as is except when a condition is encountered in which case the <xsl:call-template> is invoked.

My code so far is such :
---------------------------------------------------------------

<xsl:template match="/">
<TopConcept name="{TopConcept/@name}">
<xsl:apply-templates select="TopConcept"/>
</TopConcept>
</xsl:template>
<xsl:template match="TopConcept">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:for-each select="/*/*/O/Class[text()=$notPresent]">
<xsl:apply-templates select="/*/*/O/Class[text()=$notPresent]"/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="@*"/>
</xsl:copy>
</xsl:template>


<xsl:template match="Class"/>

-------------------------------------------

The output Im getting at the moment is

<TopConcept name="Headache">
  <TopConcept xmlns:saxon="http://saxon.sf.net/"; name="Heading">
   <!-- followed by all the output from the template 'Class'-->
</TopConcept>
</TopConcept>

------------------------------------

I dont know why the copy statement is writing out the <TopConcept> again. Also my <xsl:apply-templates select="@*"/> isnt recursing.

Could someone please let me know where the problem lies. I need to get the final output properly formatted and ready for a presentation Im giving tomorrow so really need this sorted out soon.

Appreciate all help
Rahil

Current Thread