xsl-list
[Top] [All Lists]

RE: Quick way to change element names

2006-01-19 16:05:09
From: Woods, Christopher

My first attempt was to try this:

<xsl:for-each select="*"><xsl:element
name="{concat('xhtml:',name())}"><xsl:apply-templates/></xsl:element>


This is not doing what you think its doing.  A namespace prefix is not just
a string, and xmlns="blah" is not just another attribute.  You are probably
doing some unnecessary work.

Check this to learn how to output elements with a namespace prefix:

http://www.dpawson.co.uk/xsl/sect2/N5536.html#d6476e1204

Read the rest of the page to learn how to handle your requirements in a more
graceful fashion.  For example, declaring a default namespace for your
document would place all nodes in the document in that namespace.

If, having done some reading, you determine your original course is correct,
a variant of the identity template will accomplish it:

<xsl:template match="*">
  <xsl:element name="local-name()" namespace="{$xhtml.namespace.uri}">
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>



HTH,


-----------------------------------
Mike Haarman,
XSL Developer,
Internet Broadcasting Systems, Inc.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>