|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Namespaces and the identity transform
Hi James,
> How can I design an identity transform that applies the default
> namespace to the output? I prefer not to have to restructure my
> input, and I want all output nodes to use the strict xhtml
> namespace. I substituted the above identity transform with the
> following and this seems to produce the correct output, but is this
> the most efficient way of doing it?
>
> <xsl:template match="*">
> <xsl:element name="{name()}">
> <xsl:apply-templates select="@*|node()"/>
> </xsl:element>
> </xsl:template>
>
> <xsl:template match="@*">
> <xsl:attribute name="{name()}">
> <xsl:value-of select="."/>
> </xsl:attribute>
> </xsl:template>
If this is the only processing that you're doing, you don't have to
worry about having a separate template for the attributes; you can
just do:
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>
Note that I've used local-name() rather than name(); that's just in
case someone includes a prefix on the elements in your source
document.
Cheers,
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








