Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - [xsl] Truncated text string, relative to child node [Thread Next] RE: [xsl] Truncated text string, relative to child nodeTo: Date: 7/1/2008 10:19:00 PM > 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/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
