|
[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Unwanted Prefixes in Output
Subject: Re: Unwanted Prefixes in Output
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Wed, 21 Sep 2005 05:47:55 -0400
|
Hi,
Alan wrote:
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>
I think you want something like:
<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>
This way you you can put everything in the atom namespace and just
simplay copy over existiing atom namespaced elements.
is that what you are thinking?
best,
-Rob
And the "xmlns:foo" only appears on "foo" namespace elements.
This is pretty close to "namespace normal".
Can it get any better?

|
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
| RSS 2.0 |
|
| Atom 0.3 |
|
|