Re: [xsl] xPath question

Subject: Re: [xsl] xPath question
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 8 Jul 2004 14:11:39 +0100
> But this query only seems only to work, if "id" = "BMAT".

It should generate an error, as your HygHeadDT is a result tree fragment
and you can not use an Xpath on a result tree fragment.

You have to use yoru systems node-set() extension function and then do

x:node-set($HygHeadDT)/Header/item


It sounds as if your stylesheet was running in which case either it is
not conformant (which system is it) or it isn't implementing XSLT 1.0.

Saxon 6.x implements the defunct XSLt 1.1 draft if your stylesheet
says version="1.1" (as does jd.xslt and perhaps some other systems)
node-set() wouldn't be needed in 1.1.

node-set would also not be needed in xslt2 draft (as implemented in
saxon 7 and 8) but the rest of this answer doesn't apply to xslt 2.
(Your code wouldn't work there eiether, but for different reasons)

If you use a an infix operator with node set arguments then XSLT 1
does an implied existential quantification: the expression is true
if it is true for _any_ element in teh node set. this means that you
almost never want to use != with a node set argument.

id != x:node-set($HygHeadDT)/Header/item

is true if any id is not equal to any of the item elements.
So in particular if there are two item elements with different values,
this expression will always be true as id will always be  != to at least
one item.

You want

not(id = x:node-set($HygHeadDT)/Header/item)

which is true if is is not equal to any of the items.



David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread