Re: [xsl] xsl:copy-of issue

Subject: Re: [xsl] xsl:copy-of issue
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Thu, 14 Jan 2010 01:13:38 +0100
On 14.01.2010 00:53, a kusa wrote:
Hi

I have a CALS table in my input thatI am trying to copy into my result
tree except for some attributes. I have tried 'except' but it just is
not working!

Here is my XSL snippet:

	<xsl:template match="table">
		<table id="{generate-id()}">
			<xsl:copy-of select="@* except(@type) |node()/>
					</table>
	</xsl:template>

You are copying <table>'s attributes except @type, and then everything else (the tgroup element and its *unaltered* content). <emphasis> and its @type attribute will be part of the content that will be copied verbatim, and therefore it's still there in the output.


What you probably intended to use is a catch-all template like this:

  <xsl:template match="@* | *">
    <xsl:copy>
      <xsl:apply-templates select="@* except @type | * | text()" />
    </xsl:copy>
  </xsl:template>

Gerrit

Current Thread