Re: Problem with "preceding" and "following" axis steps
Martin Honnen <[email protected]> Sun, 15 Nov 2020 18:24:38 +0100
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Organization | Liberty Development |
| Message-ID | <[email protected]> |
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 << . 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" As for the difference between libxslt and Saxon-JS, can you post a minimal but complete input sample and XSLT? It is not clear to me whether there might be any more preceding or following elements of the type you check for. And it is not clear whether you have simply run into the XSLT 1 and XSLT 2/3 difference of xsl:value-of in 1 returning only one item while 2/3 return all items.