The first few lines are boilerplate that you can just copy into
all of your XSLT files. The first line defines this file as an
XML file. The second line denotes the version of the XSLT standard
we are using, and the third pulls in the xmlns namespace. (All XSLT
functions are defined like
<xmlns:funcname ...>, so we have
to tell it where the
<xmlns:> namespace is defined.)
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
There is a single template in this file, beginning with the following line:
Each template in the XSLT file operates on a certain portion of the XML file.
The "match" part tells the XSLT parser what
part of the XML file that this template operates on (i.e. a certain tag, or group
of tags). The pattern
match="/" means that this
template will be run on the root of the XML document. In other words, this template
controls the overall structure of the output HTML stream.
The contents of this template are copied directly to the output HTML stream, with
the exception of the following tag:
This XSLT instruction tells the XSLT processor to keep applying templates to any
other tags found inside the XML file. Without this, it would stop processing
after matching the root node. We'll see more about that in coming articles.
For now,
it actually does nothing with the
<article> tag. If you run
xsltproc on this,
you'll see that the
<article> tag actually vanishes (because we haven't told the XSLT
processor to do anything with it). Its content is rolled up into the
<body> tag,
and styled accordingly. We'll see how to make it do something useful later on.
Also note that in the
<head> section of the HTML stream, we've linked to
the CSS stylesheet:
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
This lets the browser know where to look for the styling information.
Which leads into the next section ...