xsl-list
[Top] [All Lists]

[xsl] RE: Setting Namespace on Generated xsl:stylesheet Element

2010-01-26 09:13:24
To generate the xsl:stylesheet element in B.xsl, I have the
following excerpt in A.xsl:

<xsl:element name="xsl:stylesheet">
<xsl:namespace name="atom">http://www.w3.org/2005/Atom</xsl:namespace>
<xsl:attribute name="version">1.0</xsl:attribute>
...
</xsl:element>

You don't need to be that elaborate, just use namespace alias:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xslo="dummy">

<xsl:namespace-alias stylesheet-prefix="xslo" result-prefix="xsl"/>

<xsl:template ....
   <xslo:stylesheet version="1.0"
                    xmlns:atom="http://www.w3.org/2005/Atom";>
   .....
   </xslo:stylesheet>
</xsl:template>

This uses a non-XSLT namespace in the template rule but the
XSLT namespace in the result tree.

Thanks, Ken.  This solution worked flawlessly for me.

Stylistically, I prefer to use <xsl:element> to generate elements, but I can
definitely live with this solution.

--
Roger L. Cauvin
@rcauvin (Twitter)
cauvin.blogspot.com (blog)



--~------------------------------------------------------------------
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>