- Transforming XML with XSLT
- Beginning an XSLT Style Sheet
- Creating the Root Template
- Outputting HTML Code
- Outputting a Node's Content
Beginning an XSLT Style Sheet
Every XSLT style sheet is an XML document in itself and therefore should begin with a standard XML declaration. Once that's out of the way, you must define the namespace for the style sheet.
To begin an XSLT style sheet:
-
Type <?xml version="1.0"?> to indicate that the XSLT style sheet is an XML document.
-
Next, type <xsl:stylesheet xmlns:xsl= "http://www.w3.org/1999/XSL/ Transform" version="1.0"> to specify the namespace for the style sheet and declare its prefix (xsl).
-
Leave a few empty lines where you will create the style sheet
-
Type </xsl:stylesheet> to complete the style sheet.
The header for a style sheet is almost always the same. You can just copy and paste this information from one style sheet to the next.
Tips
-
There is no space in xsl:stylesheet. (It's not xsl:style sheet). Nevertheless, I do use two words to refer to style sheets when talking about them in this book (as is the convention).
-
If you use Internet Explorer 5 for XSLT processing, you'll probably have to use the following namespace declaration: <xsl:stylesheet xmlns:xsl= "http://www.w3.org/TR/WD-xsl">.