This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Is "A != B" equivalent to "not(A = B)"?
- From: "Michael S." <mjs at beebo dot org>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Sat, 27 Apr 2002 18:11:32 +1000
- Subject: [xsl] Is "A != B" equivalent to "not(A = B)"?
- Reply-to: xsl-list at lists dot mulberrytech dot com
I've got a stylesheet that produces different results depending on
whether I use "A != B" or "not(A = B)"? Is this supposed to happen?
Can someone explain why? It's not very intuitive.
This is my XML document:
<root>
<p>"Hallo, <cast>Eeyore</cast>!" said <cast>Pooh</cast>. "This is
<cast>Tigger</cast>."</p>
<p>"What is?" said <cast>Eeyore</cast>.</p>
<p>"This," explained <cast>Pooh</cast> and <cast>Piglet</cast> together,
and <cast>Tigger</cast> smiled his
happiest smile and said nothing.</p>
</root>
The stylesheet that follows is supposed to pick out the cast members:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="/">
<root>
<xsl:apply-templates select="//cast[text() != following::cast/text()]"/>
</root>
</xsl:template>
<xsl:template match="cast">
<p><xsl:value-of select="."/></p>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
This actually "works" in xsltproc--I get the output I was expecting:
<?xml version="1.0"?>
<root><p>Eeyore</p>
<p>Pooh</p>
<p>Piglet</p>
<p>Tigger</p>
</root>
However, saxon, xalan and sablotron give:
<?xml version="1.0" encoding="utf-8"?><root><p>Eeyore</p>
<p>Pooh</p>
<p>Tigger</p>
<p>Eeyore</p>
<p>Pooh</p>
<p>Piglet</p>
</root>
That is, there are duplicates, which I wasn't expecting--but since three
out of four processors give this result, I figure it must be the correct
result.
However, if the XPath expression line is changed to:
<xsl:apply-templates select="//cast[not(text() =
following::cast/text())]"/>
All four processors give the same result, the result given by xsltproc,
above. What's going on?
Michael
--
http://beebo.org
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list