Snippets‎ > ‎XSLT Examples‎ > ‎

Hello World XSLT Example for AltovaXML and/or Saxon-B

BY MARKUS SPRUNCK


You need a running installation of AltovaXML and/or Saxon-B

// Snippet #1 'data.xml'
<?xml version="1.0" encoding="ISO-8859-1"?>
<messages>
    <message>
        <text>Hello </text>
    </message>
    <message>
        <text>World!</text>
    </message>
</messages>
// Snippet #2 'hello.xslt'
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
    <xsl:output indent="yes" method="html"/>
    <xsl:template match="/">
        <html>
        <body>
        <h1>
            <xsl:for-each select=".//message">
                <xsl:value-of select="./text"/>
            </xsl:for-each>
            </h1>
        </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

Run the transformation with Saxon-B:

java -jar saxon9.jar -o:hello-from-saxon.html data.xml hello.xslt

Run the transformation with AltovaXML:

AltovaXML.exe -xslt1 hello.xslt /in data.xml /out hello-from-altova.html

Expected Result

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

Sponsored Link