An Introduction to XSLT - Discussion of the Output
(Page 4 of 6 )
I have to admit at this stage, I've not been 100% truthful; the example we've just worked through does not output an HTML document. It outputs an XHTML document, which is evident from the / that closes empty tags. XHTML is based on XML and HTML, and is like a blessed marriage between the two. Because XML syntax is stricter than HTML, and this strictness is part of its strength, this is one of the features that XHTML has taken on. In HTML there are many tags that operate on their own, how often have you ever seen an </IMG> tag for example? The answer should be 'never'. Because any opened tags must subsequently be closed in XHTML (as in XML), you need to add a forward slash at the end of an element that has no closing tag. This is why our line-break tags ended with forward slashes.
What we've looked at in the course of this article is merely a tiny part of XSLT as a whole, there are many, many more aspects and applications of the language and in all honesty, we have but scratched the surface. For example, in addition to matching templates to element patterns, you can also match attributes, ID's and processing instructions. Additionally, in the same way that we matched the root element with a / as in:
<xsl:template match="/">
You can also use the pipe symbol | to specify or, and the /* symbol to specify any.
Next: Page Masters >>
More XML Articles
More By Dan Wellman