At 2010-01-25 10:11 -0600, Roger L. Cauvin wrote:
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>
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.
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.
Correct ... because xmlns is reserved for namespaces, you cannot
create a non-namespace node (i.e. an attribute node) with it.
Using XSLT 1.0, is there a way of generating the xsl:stylesheet element that
needs to be in B.xsl?
That is the use case for namespace aliasing.
I hope this helps.
. . . . . . . . . . Ken
--
UBL and Code List training: Copenhagen, Denmark 2010-02-08/10
XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30
Vote for your XML training: http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
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>
--~--