RE: [xsl] invalid xpath?

Subject: RE: [xsl] invalid xpath?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 2 Jul 2008 14:59:50 +0100
> A simple question is getting more and more complex! I still 
> don't understand why the original stylesheet (..)[..] thru 
> Saxon drops the newlines as I want, and the modified 
> stylesheet (..) and (..) thru xsltproc/XMLSpy turns them into 
> space characters as I don't want.

It's very unlikely that the original stylesheet does what you want in XSLT
2.0, even though it is legal.

You wrote

test="not(preceding-sibling::*)[starts-with($Arg,'&#x0a;')]"


The first part

not(preceding-sibling::*)

is either true or false.

In XPath 2.0 you can filter any value or sequence with a predicate. So if

[starts-with($Arg,'&#x0a;')]

is true, then the value of the test expression is the same as the value of
[starts-with($Arg,'&#x0a;')], while if the predicate is false, the value of
the test expression is an empty sequence, which is treated as false.

I think it's rather unlikely this is what you intended. My immediate thought
was that the intended expression was

test="not(preceding-sibling::*[starts-with($Arg,'&#x0a;')])"

but since the value of the predicate doesn't depend in any way on the
context node, that seems unlikely as well. So I'm afraid I can't help you
correct your code without knowing what it was intended to do.

Michael Kay
http://www.saxonica.com/

Current Thread