I'm attempting to create an ordered list every time the Sequence attribute of a Para element has been set to 'Begin'. The list should continue until it reaches a paragraph with the Sequence attribute set to 'End'. The problem arises because the
are not being properly matched within the XSL document. I have tried various combinations of
, CData, and CDATA sections.
This can be a real painI've run into similar situations, where you need to be able to wrap a tag around an expression but the tag start and tag end are generated programmatically (and hence appear "unbalanced" to the XSL document). The simplest solution (and it isn't terribly simple), is to recognize that you need to abstract your structure out one level. What you have is this:
The problem with this code is that you're actually subverting the intrinsic structure of the code, flattening the hierarchy too much. There is no clean way to write an XPath query that will satisfy this.
However, if you recognized that each of these items exist in groups, then you could revamp your structure a bit:
Then the XSL transform becomes much simpler:
This actually brings up a good point to remember about XSLin general, whenever you have an order issue involved (or, as in this example, you seem to have unbalanced elements), this is typically an indication that your hierarchy is too flat. By deepening the hierarchy, encapsulating it if you will, you can usually solve such problems.