XSLT with not nestable tags



I have an XML document which contains both structure (section) tags and display tags (columns):



<document>
<new-column/>
<section1>
text
</section1>
<section2>
text
<new-column/>
text
</section2>
</document>


I am writing an XSLT to display this as HTML, and the logical way would be to use a div tag to display the text in separate columns, so I'd have to convert new-column into div. However, the div requires a closing < /div> tag, with all the comprising elements in between, but then the document would not be well-formed, with < section> and < new-column> being wrongly nested. One solution would be to add closing < /section> tags like this:



<document>
<new-column>
<section1>
text
</section1>
<section2>
text
</section2>
<new-column/>
<new-column>
<section2>
text
</section2>
<new-column/>
</document>


However, I was wondering if anyone has a better idea, such as adding text to a div section on the fly, or perhaps using a different solution for multiple column (and multiple pages) display. TIA


No comments:

Post a Comment