I have an XML file like this:
<a> lorem ipsum text ... lorem ipsum <b> dolor </b> lorem ipsum ...
lorem ipsum </a>
I want to create a string of the five words from <a> right
before the <b> tag, and a string of the five words
immediately after <b>. All I can do is create strings from
the beginning or the end of the <a> tag, but basically I want
the text in the middle, relative to the child <b> node.
In 2.0, assuming the <a> element is the context node, the two sequences are
given by
subsequence(tokenize(b/following-sibling::text(), '\s'), 1, 5)
and
reverse(subsequence(reverse(tokenize(b/preceding-sibling::text(), '\s')), 1,
5))
In 1.0, you'll have to be prepared for something rather more verbose.
Michael Kay
http://www.saxonica.com/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--