Automatic Indenting

The <xsl:output> element supports an attribute called indent, which you can set to “yes” or “no”, and which indicates to the XSLT processor whether you want the result document indented. Usually, indenting the result document doesn’t matter very much, because that document is targeted to an application that doesn’t care about indenting, as in the XML-to-XML and -HTML examples you’ve seen. However, there are times when you’d like to view the result document as straight text, and in such cases, indenting that document to show its hierarchical structure can help.

How an XSLT processor uses the indent variable varies by processor, because it’s not specified by W3C, so you have to experiment to get the results you want. Say, for ...

Get Inside XSLT 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.