XSLT: how can proper XML indentation levels be preserved?

N

Neil Zanella

Hello,

I would like to know whether it is possible to get an XSLT processor to output
tags with the proper indentation. For instance, given the following standard
example I get the output given below:

$ cat hello.xml
<?xml version="1.0"?>
<greeting>
Hello, World!
</greeting>

$ cat hello.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:eek:utput method="html" />
<xsl:template match="/">
<xsl:apply-templates select="greeting" />
</xsl:template>
<xsl:template match="greeting">
<html>
<body>
<h1>
<xsl:value-of select="." />
</h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

$ xsltproc hello.xsl hello.xml
<html><body><h1>
Hello, World!
</h1></body></html>

.... but this is my first time running an XSLT processor and I was expecting:

<html>
<body>
<h1>
Hello, World!
</h1>
</body>
</html>

Is there anything I can do about this to fix it?

Thanks,

Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top