The following string gets encoded in my source XML using toggles, and I want it changed to nodes with formatting information. (This is XLIFF to WordprocessingML.)
"Text, bold text, bold and italics text, bold text, plain text."
Source XML:
<text>
Text
<format id="1" type="bold" />
bold text,
<format id="2" type="italics" />
bold and italics text,
<endformat id="2" />
bold text,
<endformat id="1" />
plain text.
</text>
I need:
<run>
<format></format>
<text>Text, </text>
</run>
<run>
<format><b/></format>
<text>bold text, </run>
</run>
<run>
<format><b/><i/></format>
<text>bold and italics text, </run>
</run>
<run>
<format><b/></format>
<text>bold text, </run>
</run>
<run>
<format></format>
<text>plain text.</run>
</run>
If I were using a procedural language, I'd keep a running record of what formatting is active and write out the <format>
element accordingly.
But how do I do it in XSL?