XSLT: how can proper XML indentation levels be preserved?

Discussion in 'XML' started by Neil Zanella, Jul 7, 2003.

  1. Neil Zanella

    Neil Zanella Guest

    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
     
    Neil Zanella, Jul 7, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oleg Ogurok
    Replies:
    1
    Views:
    422
    Teemu Keiski
    Jun 23, 2004
  2. LP
    Replies:
    19
    Views:
    2,615
    Brian Bischof
    Feb 25, 2005
  3. Alan Silver
    Replies:
    6
    Views:
    2,911
    Alan Silver
    Aug 9, 2005
  4. John Salerno
    Replies:
    11
    Views:
    773
    Dave Hansen
    May 10, 2006
  5. Jesse B.
    Replies:
    2
    Views:
    224
    Josh Cheek
    Mar 27, 2010
Loading...

Share This Page