Subject: Re: [xsl] Unwanted Prefixes in Output From: Robert Koberg <rob@xxxxxxxxxx> Date: Wed, 21 Sep 2005 05:47:55 -0400 |
Probably common problem with namespace emissions. Tried to cut it down to the basics.
I'd like to omit "xmlns:foo" namespace declaration where it will not be referenced, like under atom:updated.
Should note that the saved documents can contain any namespace, so I can't add xmlns:foo declaration to my stylesheet, but I'd like to have my namespaces namespace normal.
http://www.flightlab.com/~joe/sgml/sanity.txt
Cheers.
I'm talking to myself now. :^)
I found that this removes unnecessary namespace declarations...
<xsl:template match="atom:*" mode="copy-entry"> <xsl:element name="atom:{local-name(.)}"> <xsl:copy-of select="@*"/> <xsl:apply-templates select="node()" mode="copy-entry"/> </xsl:element> </xsl:template>
<xsl:template match="atom:*" mode="copy-entry"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates mode="copy-entry"/> </xsl:copy> </xsl:template>
<xsl:template match="*" mode="copy-entry"> <xsl:element name="{local-name()}" namespace="http://the-atom-namespace"> <xsl:apply-templates select="@*"/> <xsl:apply-templates mode="copy-entry"/> </xsl:element> </xsl:template>
<xsl:template match="@*"> <xsl:attribute name="{local-name()}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:template>
best, -Rob
And the "xmlns:foo" only appears on "foo" namespace elements.
This is pretty close to "namespace normal".
Can it get any better?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Unwanted Prefixes in Outp, Alan | Thread | Re: [xsl] Unwanted Prefixes in Outp, Alan |
Re: [xsl] Passing an XSLT variable , Joris Gillis | Date | Re: [xsl] Retrieve External String , David Carlisle |
Month |