xsl-list
[Top] [All Lists]

RE: [xsl] Saxon output unused namespace declarations

2009-07-23 07:22:17

This isn't specific to Saxon and it's not even specific to XSLT 2.0. XSLT
(both in 1.0 and 2.0) specifies that a literal result element (such as
<out>) is copied from the stylesheet to the result tree with all its
in-scope namespaces, other than any namespaces listed in the
exclude-result-prefixes attribute. The reason for this being the default
behaviour is that the processor in general can't tell which namespaces are
used and which aren't (it's not just prefixes-in-content; there have
actually been some XML vocabulary designs in which the mere presence of a
namespace declaration is used to carry information).

So if you don't want the namespace, exclude it using
exclude-result-prefixes.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

 

-----Original Message-----
From: Weihua JIANG [mailto:weihua(_dot_)jiang(_at_)gmail(_dot_)com] 
Sent: 23 July 2009 10:11
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Saxon output unused namespace declarations

I am using SAXON  9.1.0.6J under Linux for XSLT 2.0.

For following stylesheet:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="2.0" > <xsl:template match="/" 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
  <xsl:param name="p1" select="(xs:anyURI('one.uri'), 
xs:anyURI('eins.uri'))"/>
  <xsl:param name="p2" select="(xs:anyURI('two.uri'), 
xs:anyURI('zwei.uri'))"/> <out>
  <xsl:value-of select="$p1 != $p2"/> should be true </out> 
</xsl:template> </xsl:stylesheet>

Saxon get the output as
<?xml version="1.0" encoding="UTF-8"?><out 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>true should be true </out>

I am wondering why the namespace declaration for xmlns:xs is 
outputted. This namespace declaration is not used by the out element.
So, from my opinion, to make the output as simple as 
possible, the XSLT 2.0 processor shall not output such declaration.

But, since Saxon is the de facto XSLT 2.0 standard 
implementation. I guess this complies with XSLT 2.0 spec. Can 
anyone tell whether there is any statements in XSLT 2.0 spec 
saying something about it?

Thanks
Weihua

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



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