After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 61962 - Weird behavior between strip-space and equality test
Weird behavior between strip-space and equality test
Status: VERIFIED FIXED
Product: libxslt
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2001-10-08 17:27 UTC by vdv
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description vdv 2001-10-08 17:27:16 UTC
strip-case creates sometimes false results while testing for equality
between nodes, for instance:

xml:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<tr><td>pat</td>
</tr>
<tr><td>pat</td>
</tr>
</test>

xslt:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink" exclude-result-prefixes="xlink">
<xsl:strip-space elements="*"/>
	<xsl:template match="/">
		<xsl:apply-templates select="test/tr[1]"/>
	</xsl:template>
	<xsl:template match="tr">
		<nb>
			<xsl:value-of select="count(/test/tr[. = current()])"/>
		</nb>
	</xsl:template>
</xsl:stylesheet>

Result is: 
<?xml version="1.0"?>
<nb>1</nb>

(should be 2)

Version:

Using libxml 20405, libxslt 10004 and libexslt 400
xsltproc was compiled against libxml 20403, libxslt 10004 and libexslt 400
libxslt 10004 was compiled against libxml 20403
libexslt 400 was compiled against libxml 20403

Thanks

Eric
Comment 1 Daniel Veillard 2001-10-08 18:14:57 UTC
Could you explain a bit why you expect 2 ?
It looks to me that 

/test/tr[. = current()]

could at best select 1 node
and hence count can at most be 1, but I may have missed something,

Daniel
Comment 2 vdv 2001-10-08 18:28:03 UTC
When I write ". = current()", "." is the current node in the XPath
step while "current()" is the XSLT context node. Both are a node set
containing a single node and this is a test between two node sets.

Per  http://www.w3.org/TR/xpath#booleans:

"If both objects to be compared are node-sets, then the comparison
will be true if and only if there is a node in the first node-set and
a node in the second node-set such that the result of performing the
comparison on the string-values of the two nodes is true."

Since the 2 tr nodes have the same string value, the result should
then be 2.

libxslt use to get the right result if I supress the strip-case clause
in the style sheet or if I remove the CR between </td> and </tr> thus
my comment of being something weird with strip-case.

PS: this is a highly reduced repro case taken from a real life complex
transformation.
Comment 3 Daniel Veillard 2001-10-09 21:25:44 UTC
Okay, I understood, thanks for the explanations.
I had to rework the way strip-space was handled, it was progressive
as XSLT made progresses thought the document but as you pointed
out XPath expressions could access non-stripped parts of the
document. Stripping now occurs at the beginning of the processing
of a document:

http://cvs.gnome.org/bonsai/cvsquery.cgi?module=libxslt&branch=HEAD&branchtype=match&dir=libxslt&file=&filetype=match&who=veillard&whotype=match&sortby=Date&hours=&date=explicit&mindate=10%2F09%2F01+06%3A37&maxdate=10%2F09%2F01+06%3A39&cvsroot=%2Fcvs%2Fgnome

http://cvs.gnome.org/bonsai/cvsquery.cgi?module=libxslt&branch=HEAD&branchtype=match&dir=libxslt&file=&filetype=match&who=veillard&whotype=match&sortby=Date&hours=&date=explicit&mindate=10%2F09%2F01+07%3A02&maxdate=10%2F09%2F01+07%3A04&cvsroot=%2Fcvs%2Fgnome

  thanks for the report and explanations !

Daniel

Comment 4 Daniel Veillard 2001-10-30 19:13:32 UTC
should be fixed in the last releases,

Daniel