Re: Problem with "preceding" and "following" axis steps

Till Gerken <[email protected]> Sun, 15 Nov 2020 21:26:05 +0100
Newsgroups gmane.text.xml.saxon.help
Message-ID <CAF1ExvRiQOSjK9JQxzBNjuWVCsTjMacSbMJGXz6f1w2R1F3Qiw@mail.gmail.com>
On Sun, Nov 15, 2020 at 8:45 PM Martin Honnen <[email protected]> wrote:

> On 15.11.2020 16:54, Till Gerken wrote:
>
> > My issue is with the statement "<xsl:value-of
> > select="text()[following::QUOT.START and preceding::QUOT.END]"/>"
> >
> > libxslt only returns the word between QUOT.START and QUOT.END, in the
> > example above that would be "medical device". (my desired result)
> >
> > Saxon-JS however returns the text of the entire TXT tag. (not my desired
> > result)
> >
> > Is there an error in my XSLT or did I come across an
> > implementation-specific behavior of Saxon-JS? In case of the latter,
> > what would be the right way to extract only the piece between QUOT.START
> > and QUOT.END?
>
> I haven't tested but it seems in the context of XPath 3 I would use
>
>    <xsl:value-of select="let $s := QUOT.START, $e := QUOT.END return
> text()[$s &lt;&lt; . and . >> $e]"/>
>
> In general, it seems using preceding-sibling instead of preceding e.g.
>
>    text()[preceding-sibling::node()[1][self::QUOT.START] and
> following-sibling::node()[1][self::QUOT.END]]"/>
>
>   is cheaper and more adequate for the sample you have posted and the
> verbal description "piece between QUOT.START and QUOT.END"
>

Thanks everyone for the quick replies! The suggestion above indeed fixes
the problem.

As noted, it is correct that the document contains several ITEM instances
with QUOT.START/QUOT.END. I was trying to process each of these
individually and assumed that "preceding" and "following" were restricted
to the TXT instance that was being selected. If they operate on the
document's scope, the result is of course different - there are many
QUOT.START/QUOT.END sequences in the document.

Thanks for your help!

>
>

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help