I am getting some unexpect results from an XPath
predicate. I am trying to load the unique values of
an element into a variable. The XML file is grouped
by this element. I want to treat the absence of the
element as a value as well (the "null" value if you
will). However, I can't get the XPath predicate to
filter out multiple "null" values.
I am including below a data file, stylesheet, expected
output and observed output. If you can see anything
wrong, I would most appreciate your assistance.
Regards,
Dave
XML File:
---------
<a>
<b>
<c>123</c>
<d>000</d>
</b>
<b>
<c>123</c>
<d>000</d>
</b>
<b>
<d>000</d>
</b>
<b>
<d>000</d>
</b>
<b>
<c>456</c>
<d>000</d>
</b>
<b>
<c>456</c>
<d>000</d>
</b>
<b>
<c>789</c>
<d>000</d>
</b>
</a>
XSL File:
---------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="text"/>
<xsl:template match="a">
<xsl:variable name="unique-cs"
select="/a/b[(not(boolean(preceding-sibling::b)) or
(not(boolean(c)) and preceding-sibling::b/c) or
(boolean(c) and not(c=preceding-sibling::b/c)))]"/>
<xsl:for-each select="$unique-cs">
<xsl:value-of select="c"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Expected output:
----------------
123
456
789
Observed output:
----------------
123
456
789
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com