This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: namespaces and copying trees
- To: Joern Clausen <joern at TechFak dot Uni-Bielefeld dot DE>
- Subject: Re: [xsl] namespaces and copying trees
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Wed, 8 Aug 2001 17:55:01 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <20010808180100.N29687@kiefer.TechFak.Uni-Bielefeld.DE>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Joern,
> Now I want (among other things) to generate an HTML version of this
> file, without the metadata. How can I exclude everything in the
> "foo" namespace?
Use an identity template to copy everything:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
And then have another template that matches anything in the namespace
you want to exclude, and either does nothing at all:
<xsl:template match="foo:*|@foo:*" />
Or, if elements in this namespace can have other information that you
*do* want nested inside them, carries on processing the contents:
<xsl:template match="foo:*|@foo:*">
<xsl:apply-templates />
</xsl:template>
If you care that the result will contain a namespace declaration for
the foo namespace, then you need to create the elements using
xsl:element instead:
<xsl:template match="*">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:apply-templates select="@*|node()" />
</xsl:element>
</xsl:template>
You may need to play around with priorities so that the above template
for elements not in the foo namespace has a higher priority than the
identity template I gave at the beginning of the email, while
retaining a lower priority than the template for elements/attributes
in the foo namespace.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list