[xslt] Bug with the document("") function



Hi,

I have found a bug in 4xslt and it looks like 50% of this bug is also
affecting libxslt :-)

Here is the part which is common to both processors:

<quote>

2) The whitespaces have been striped which is not conform to the XSLT
recommendation that says:

Note that a zero-length URI reference is a reference to the document
relative to which the URI reference is being resolved; thus document("")
refers to the root node of the stylesheet; the tree representation of
the stylesheet is exactly the same as if the XML document containing the
stylesheet was the initial source document.

(here the tree is not "exactly the same as if the XML document
containing the stylesheet was the initial source document").

I think that this has been discussed on the xsl-list and that the
conclusion was that processors might need to parse the stylesheet again
when document("") is used. If I remember correctly, Mike Kay said that
there is no performance gain in using document("") over an external
document since the stylesheet was being reparsed anyway.

</quote>

A simple test case to show this is:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:vdv="http://eric.van-der-vlist.com/tmpns"; version="1.0">
 <xsl:template match="/">
  <xsl:copy-of select="document('')/xsl:transform"/>
 </xsl:template>
</xsl:transform>

which gives:

<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:vdv="http://eric.van-der-vlist.com/tmpns";
version="1.0"><xsl:template match="/"><xsl:copy-of
select="document('')/xsl:transform"/></xsl:template></xsl:transform>

instead of:

<?xml version="1.0" encoding="utf-8"?><xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:vdv="http://eric.van-der-vlist.com/tmpns"; version="1.0">
 <xsl:template match="/">
  <xsl:copy-of select="document('')/xsl:transform"/>
 </xsl:template>
</xsl:transform>

(with Saxon for instance)

I guess this won't be an issue in 99.99% of the cases but since it's a
non conformance I have thought that it needed to be reported.

Hope this helps.

Eric
-- 
See you in San Diego.
                               http://conferences.oreillynet.com/os2002/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org
------------------------------------------------------------------------




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]