I am using Saxon 9, I also use Oxygen 12.1 on a Windows XP machine.
I have some mixed content such as this:
Code:
<AAA>Some Text
<BBB>
<CCC>1</CCC>
<CCC>2</CCC>
</BBB>
More Text
<BBB>
<CCC>3</CCC>
<CCC>4</CCC>
<CCC>5</CCC>
</BBB>
End of Text
</AAA>
At the end of the day, I'm going to turn this into 6 text strings to be sent to other parts of my XSLT scripts.
The lines will look like:
Some Text1More Text3End of Text
Some Text1More Text4End of Text
Some Text1More Text5End of Text
Some Text2More Text3End of Text
Some Text3More Text4End of Text
Some Text3More Text5End of Text
There will be 0 or more BBB element structures and There may or may not be text before, in between or after the BBB nodes.
My thought is to write a recursive template that would take the AAA structure and if there are no BBB structures, just dump the text node.
If there are BBB structures, get the CCC values for one of the BBB structures, say the left most one, and concat the surrounding text with the selected CCC value and any remaining BBB structures and resend to the template. Then when we bounce back to the first recursion, bump the CCC value to the next value, concat with the text and send it through again. Eventually I will have processed all CCC values for all BBB elements and dumped each text string to a temporary result so I can do something with it later.
My problem, except for maybe doing this the most difficult way possible, is that I don't know how to tell what order the text nodes are with the BBB nodes. So, how can I tell that 'Some Text' preceeds a BBB structure and that 'End of Text' succeeds a BBB structure? I can put just the text nodes in order using text()[1], text()[2], or text()[3] and I can put the BBB nodes in order using ./BBB[1] and ./BBB[2], but how do I get the text() and BBB nodes in the right order with each other?
Also, if you know a better way to do this, I'm all ears (or all eyes in this case)
Thanks,
- m