[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Split element with mixed content
Apparently MK and I were a bit on the same track, applying his notes to
what I came up in my prev posts, see below, it may help you understand
my solution, and, likely, optimize it:
Michael Kay wrote: 0: for simplicity, assume an empty element <split/> at the split point. I assumed a matching for text, done with contains(., 'yourtexthere') 1: generate the first element, by copying any node that precedes <split/> or I assumed HTML where the P element cannot be a child of itself, and used ancestor::p to have a starting point. 2. generate the second element, by copying any node that follows <split/> or I didn't do this, I used instead two modes to differentiate between 'before' and 'after'. My solution is probably more resource intensive. In addition, in the midst of it all, you have the split of the text itself. I did it by using a predicate for testing if it is the right string and then use either the before or after bit. "Copy" here is in the sense of doing an <xsl:copy> and a recursive Indeed. In my case: the text node and node comparison against that node.
I assumed the marker to be text()[contains(., 'yourstring')] If there are multiple split points, do the above to split into two, then ah, didn't think of that. If you need that, you'll have to modify my code a bit. After you have something, I reckon it is best to put it into some function, it will be worthwile if you can simply use it with copy-of or something and you can more easily reuse functions then templates (imho). Cheers, -- Abel Braaksma
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|