Re: [xslt] "|" operator



Hi,

Phil Shafer wrote:
> I have another odd xslt question:
>
> What's the difference between 'select=". | one"'
> and 'select="(.) | one"'?  The latter does what
> I thought the former should have done.

I would also expect the two to behave identically, and believe that
the difference is a bug.

<snip>
>
> Here is my test input:
>
> <top>
>   <one/>
>   <two/>
>   <three/>
> </top>
<snip>
> The problem is that ". | one" selects only <top>, not <one>.  But
> if I wrap it in parens (test2) or use a variable (test3), it works
> correctly.  Any insight appreciated.
>

The problem is not actually within the libxslt package, but rather
stems from within libxml2, in particular xpath.c and pattern.c.  This
can be seen using the test program "testXPath", which produces the
following:

[bill bbxp work]$ ./testXPath -i bug.xml "(.)|one"
Object is a Node Set :
Set contains 2 nodes:
1  ELEMENT top
2  ELEMENT one
[bill bbxp work]$ ./testXPath -i bug.xml ".|one"
Object is a Node Set :
Set contains 1 nodes:
1  ELEMENT top
[bill bbxp work]$ ./testXPath -i bug.xml "one|."
Object is a Node Set :
Set contains 2 nodes:
1  ELEMENT top
2  ELEMENT one

(since '|' should be commutative, clearly there is a problem).

I spent a little time with the debugger, but the logic path quickly
got very deep into xpath.c and pattern.c, and I couldn't afford the
time to go more deeply into it. If any others would like to pursue it,
suggestions would be welcome. In the meantime, please open a bug
report so we can make sure it gets fixed in due course.

> Thanks,
>  Phil

Regards,
Bill



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]