[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: namespaces and copying trees

Subject: Re: namespaces and copying trees
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 8 Aug 2001 17:55:01 +0100
Re:  namespaces and copying trees
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.