xsl-list
[Top] [All Lists]

Re: Outputing a node whose value appears only once

2005-07-18 21:14:02
At 2005-07-18 21:00 -0700, Mukul Gandhi wrote:
I am trying to eliminate duplicates with the following
logic..
...
   <xsl:for-each select="(a/* | c/*)[not((. =
preceding-sibling::a) | (. = preceding-sibling::c) |
(. = following-sibling::a) | (. =
following-sibling::a))]">
...
Saxon 8.4 is giving error -
Error on line 7 of
file:/C:/xml/xsleg/xslt/example1.xsl:
  XPTY0004: Required item type of first operand of '|'
is node(); supplied value
 has item
  type xs:boolean

Whereas Xalan-J 2.6.0 gives following error -
Error at xsl:for-each on line 7 of
file:///C:/xml/xsleg/xslt/example1.xsl:
  The value is not a node-set

Can anyone tell where is the problem?

The error messages are unambiguous and say it all ... you are trying to use the union operator with an operand that is not a node set.

And how I can solve it?

You are using "|" as "or" and that isn't part of the XPath syntax for boolean operators ... "|" is *only* for the union of node sets.

If I've guessed your intent correctly you probably want:

<xsl:for-each select="(a/* | c/*)[not((. = preceding-sibling::a) or (. = preceding-sibling::c) or (. = following-sibling::a) or (. = following-sibling::a))]">

This is a *very* common misconception by my XSLT students who are trying to use "or" in my in-class exercises and type "|" because of their programming background.

I hope this helps.

. . . . . . Ken

--
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--