Subject: Re: [xsl] namespaces and copying trees From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 8 Aug 2001 17:55:01 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] namespaces and copying trees, Joern Clausen | Thread | RE: [xsl] namespaces and copying tr, Michael Kay |
Re: [xsl] Preceding Ancestors, Jeni Tennison | Date | Re: [xsl] cross-ref, Jeni Tennison |
Month |