Re: [xsl] copy part of the original document

Subject: Re: [xsl] copy part of the original document
From: Joerg Pietschmann <j3322ptm@xxxxxxxx>
Date: Tue, 31 Dec 2002 14:10:40 +0100
On Monday 30 December 2002 22:52, you wrote:
> I want to copy the whole document, as it is, except when the heading of a
> section has an attribute (name="Entwurf"). Then this section and all its
> children should not be copied.
...
> I have tried it with something like:
> <xsl:template match="section[heading/@name='Entwurf']">
>   <xsl:copy-of select="..">
>         <xsl:apply-templates
> select="*|@*|processing-instruction()|text()"/> </xsl:copy-of>
> </xsl:template>
...
> But the parser (4xslt) says, "Illegal child 'xsl:apply-templates' within
> element 'xsl:copy-of'"

You are on the right track: use the generic copy-through template
and override it for the elements you want to change.
Unfortunately, you missed some fine points.
The xsl:copy-of element copies the whole selected node set into
the output. The element does not take any children, this caused
the error message you got. Also, you told the porcesso to copy the
whole tree starting from the parent of the section, which is not
what you stated above as your goal.
If you want to omit the whole section having a heading with a
name attribute value of "Entwurf", simply write an *empty* template:
 <xsl:template match="section[heading/@name='Entwurf']"/>
Yes, that's all.

J.Pietschmann

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread