I'm trying to parse element contents and split them on a delimiter, while keeping all elements in the parent. I don't need -- don't want -- to find the delimiter inside the child elements.
<data>
<parse-field>Some text <an-element /> more text; cheap win? ;
<another-element>with delimiter;!</another-element>; final text</parse-field>
</data>
Should become
<data>
<parsed-field>
<field>Some text <an-element /> more text</field>
<field>cheap win?</field>
<field><another-element>with limiter;!</another-element></field>
<field>final text</field>
</parsed-field>
</data>
I've got a hacked-together solution that examines all "parse-field/text()" and replaces the delimiter with <token />
, then a second pass to pick out the pieces around the<token>
s, but it's... hacked. And unpleasant. I'm wondering if there's a better way.
I'm using XSLT-2.0, open to XSLT-1.0 solutions. SAXON processor.