| 
 
Subject: Re: [xsl] Namespaces and the identity transform From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 29 Oct 2002 18:19:27 +0000  | 
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
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] Namespaces and the identity t, James Carlyle | Thread | Re: [xsl] Namespaces and the identi, David Carlisle | 
| Re: [xsl] Encoding/Entities problem, Paulo \(Shape.Tech\) | Date | Re: [xsl] Namespaces and the identi, David Carlisle | 
| Month |