[xslt] xsl:element namespace query
- From: "Richard Jinks" <cyberthymia yahoo co uk>
- To: <xslt gnome org>
- Subject: [xslt] xsl:element namespace query
- Date: Thu, 23 May 2002 10:56:27 +0100
Hi
Whilst playing with my XSLT test files, I came across another odd example
which falls into one of the fuzzy "implementation specific" parts of the
XSLT spec. The following example concerns the way libxslt outputs namespaces
with <xsl:element ... namespace="..."/>.
--
Stylesheet - "54-namespaces.xsl"
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<AAA>
<xsl:element name="BBB"
namespace="http://zvon.org/xslt">111</xsl:element>
<xsl:element name="{//el}" namespace="{//ns}">
<xsl:value-of select="//val"/>
</xsl:element>
<xsl:element name="qqq:{//el}" namespace="{//ns}">
<xsl:value-of select="//val"/>
</xsl:element>
</AAA>
</xsl:template>
</xsl:stylesheet>
--
XML File - "54-namespaces.xml"
<?xml version="1.0"?>
<AAA author="nicmila@idoox.com">
<ns>http://zvon.org/xslt</ns>
<el>XXX</el>
<attr>ww:eee</attr>
<val>555</val>
</AAA>
--
xsltproc results:
C:\libxml\libxslt-1.0.17.win32\util> xsltproc 54-namespaces.xsl
54-namespaces.xml
<?xml version="1.0"?>
<AAA xmlns:ns1="http://zvon.org/xslt">
<ns1:BBB>111</ns1:BBB>
<ns1:XXX>555</ns1:XXX>
<ns1:XXX>555</ns1:XXX>
</AAA>
--
Saxon 6.5.1 results
C:\libxml\libxslt-1.0.17.win32\util>saxon 54-namespaces.xml
54-namespaces.xsl
<?xml version="1.0" encoding="utf-8"?>
<AAA>
<BBB xmlns="http://zvon.org/xslt">111</BBB>
<XXX xmlns="http://zvon.org/xslt">555</XXX>
<qqq:XXX xmlns:qqq="http://zvon.org/xslt">555</qqq:XXX>
</AAA>
--
MSXSL4 results
C:\libxml\libxslt-1.0.17.win32\util>msxsl 54-namespaces.xml
54-namespaces.xsl
<?xml version="1.0" encoding="UTF-16"?>
<AAA>
<BBB xmlns="http://zvon.org/xslt">111</BBB>
<XXX xmlns="http://zvon.org/xslt">555</XXX>
<qqq:XXX xmlns:qqq="http://zvon.org/xslt">555</qqq:XXX>
</AAA>
My query stems from not expecting libxslt to be this clever and merge the
namespaces together into one namespace declaration on the parent AAA
element. I was expecting the more literal "simple" output (as with Saxon and
MSXSL) with the namespace declaration sat on the elements they were declared
with in the stylesheet.
Now I know that what libxslt outputs isn't wrong in that the children
elements of AAA are in the correct namespace, and it is still working inside
the XSLT spec - it just isn't what I'd expected. I'm a touch concerned that
it is losing some information by overriding the prefix "qqq:" specified for
the third element, but as the XSLT spec says that the XSLT processor is
allowed to do this, I don't have much cause to complain.
Is there an easy way of making libxslt handle outputting namespace nodes in
the same manner as the other processors, or would I need to modify lots of
code to make it work?
On a related node, if I did have to modify the code would you be interested
in reflecting the change back into libxslt, or are you happy with the way it
works / have a reason for preferring things as they are?
Thanks,
Richard
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]