|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








