[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Outputing a node whose value appears only once

Subject: Re: [xsl] Outputing a node whose value appears only once
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 19 Jul 2005 00:14:02 -0400

At 2005-07-18 21:00 -0700, Mukul Gandhi wrote:
I am trying to eliminate duplicates with the following
   <xsl:for-each select="(a/* | c/*)[not((. =
preceding-sibling::a) | (. = preceding-sibling::c) |
(. = following-sibling::a) | (. =
Saxon 8.4 is giving error -
Error on line 7 of
  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
  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@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