Subject: Re: [xsl] XPath Predicate Nuance From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 06 Oct 2004 20:28:28 -0400 |
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.
T:\ftemp>type nesbitt.xml <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>
T:\ftemp>type nesbitt.xsl <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(preceding-sibling::b) or (not(c) and preceding-sibling::b[1]/c) or (c and not(c=preceding-sibling::b[1]/c)))]"/> <xsl:for-each select="$unique-cs"> <xsl:value-of select="c"/> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>
T:\ftemp>saxon nesbitt.xml nesbitt.xsl 123
456 789
-- Upcoming publicly-subscribed XSL delivery: Helsinki Oct 18-20,2004 World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XPath Predicate Nuance, David P. Nesbitt | Thread | Re: [xsl] XPath Predicate Nuance, David P. Nesbitt |
[xsl] XSLT Doctype and XHTML output, Gary Hegenbart | Date | Re: [xsl] XPath Predicate Nuance, David P. Nesbitt |
Month |