If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Friday, October 26, 2012

Indenting your XSLT output

Ever wondered why the output from your XSLT is not indented even if you use @indent="yes"?
You will need to use extension functions and below are examples how to do it for Xalan and Saxon. Remark: For this to work with Saxon you will need the professional edition.

Saxon:
<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:saxon="http://saxon.sf.net/"
                extension-element-prefixes="saxon">

    <xsl:output method="xml" saxon:indent-spaces="4" indent="yes"/>


Xalan:
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xslt="http://xml.apache.org/xslt">

    <xsl:output method="xml" xslt:indent-amount="4" indent="yes"/>


No comments:

Post a Comment