Breaking well-formed constraints

By default, the XSLT processor must output a well-formed XML document. This is not a serious constraint, but in fact the reality is that the stylesheet itself, including the mixture of XSLT elements and output elements, must be well-formed too. This is a more serious problem. For example, a list of alternating names and telephone numbers may need to be converted into a number of paragraphs, each containing a name and following number:

<name>J Smith</name>
<number>123</number>
<name>P Jones</name>
<number>321</number>

The obvious way to do this is to output a new Paragraph element at the start of each name and end the paragraph after the following number, but this would make the stylesheet itself invalid because ...

Get XSL companion, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.