[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Setting Namespace on Generated xsl:stylesheet Element


Subject: [xsl] Setting Namespace on Generated xsl:stylesheet Element
From: "Roger L. Cauvin" <roger@xxxxxxxxxx>
Date: Mon, 25 Jan 2010 10:11:52 -0600

I'm using a stylesheet (A.xsl) to generate another stylesheet (B.xsl).
B.xsl will process Atom feeds and thus needs to reference the atom
namespace.  Consequently, B.xsl needs a namespace declaration in the
xsl:stylesheet element:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:atom="http://www.w3.org/2005/Atom">

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>

My understanding is that the xsl:namespace element in this excerpt is only
valid in XSLT 2.0.  I tried:

<xsl:attribute name="xmlns:atom">http://www.w3.org/2005/Atom</xsl:attribute>

but Saxon told me:

Error at xsl:attribute on line 22 column 40 of QueryToFeedFilter.xsl:
  XTDE0850: Invalid attribute name: {xmlns:atom}
Failed to compile stylesheet. 1 error detected.

Using XSLT 1.0, is there a way of generating the xsl:stylesheet element that
needs to be in B.xsl?

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


Current Thread
Keywords