This tutorial was created by Richard Bomstein.
As an overview of the process, here is a diagram showing the steps.
The following is an example of a simple XML document.
<?xml version="1.0"?>
<greeting>
Hello, World!
</greeting>
• The first line (above) defines the XML version ("1.0") this document is based on.
• The second line, <greeting>, looks like a start tag in HTML. In XML we call <greeting> an element.
• Tags and elements both have to close with a closing (/) indicator. In the fourth line, note how </greeting> has a closing (/) indicator.
• XML stands for extensible markup language; you can extend and invent new elements and markup languages in XML. In HTML you live with the tags that already exist.
• Keep this in mind: The <greeting> element (above) is called the document’s root. It appears first after the version statement and it contains all document content.
Next we look at a stylesheet, the traffic cop that tells the code how to build an HTML document. This stylesheet example is from Doug Tidwell's book "XSLT".
Below I provide comments (<!
<!
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!
<xsl:output method="html">
<!
<xsl:template match="/">
<xsl:apply-templates select="greeting "
</xsl:template>
<!
<xsl:template match="greeting ">
<html>
<body>
<h1>
<!-- The XSL:value-of element tells the code to print out the text inside the greeting element and to place this text inside the h1 tags in the output document.-->
</xsl:value-of select=".">
</h1
</body>
</html>
</xsl:template>
<!
</xsl:stylesheet>
Now we’ll see how a command from the DOS prompt can be used to generate the HTML document.
This DOS command transforms an XML document into an HTML document. Name the XML document and the XSLT stylesheet in the command (Saxon is a processor that transforms an XML document).
Here's the DOS command:
C:\> saxon greeting.xml greeting.xsl
After you run the command, this is the generated HTML document.
<html>
<body>
<h1>
Hello, World!
</h1
</body>
</html>
And this is how the HTML document displays in a browser.
Hello, World!
{SUBMIT()}{SUBMIT}
