On Thu, 9 Aug 2001, Tom Bradford wrote:
> I've attached the 3 documents that I'm using to test. Note, that there
> isn't anything special about them. The processor fails consistently,
> and not just with the starts-with - 'Lay' thing, it happens in many
> other starts-with queries as well.
>
> Here are the ApplyXPath command lines I'm using to test (outside of our
> environment):
>
> java ApplyXPath b80a8d0c.xml "/disc[starts-with(track, 'Lay')]" <--
> Doesn't work
> java ApplyXPath d011aa05.xml "/disc[starts-with(track, 'Lay')]" <--
> Doesn't work
> java ApplyXPath 78126e09.xml "/disc[starts-with(track, 'Lay')]" <-- Does
> work
>
> Regular '=' queries work fine.
>
> Any ideas? I can only assume a bug in starts-with, but after looking at
> the code, I can't see where it might be.
No, the xpath is fine. In 78126e09.xml, the first <track> has text that
starts with Lay. In the other files, the <track> element with Lay is after
the first.
If you say starts-with(track, "string"), it first selects all the track
elements, which results in a nodeset. Because the first argument of
starts-with is a string, the nodeset is converted to a string. A nodeset
is converted to a string by taking the string value of the first node in
it. So it only ever converts the first <track> element to a string.
Try "/disc/track[starts-with( . , 'Lay')]"
Best,
Erwin Bolwidt