This section provides some basics about how to define XSL templates to Transform XHTML files.
XSL Template: A unit of XSL statements that defines the replacement content for elements in the XML source files
that matches the specified pattern. An XSL template has the following structure:
where "pattern" is a pattern used to match element names in the source XML file,
and "replace_content" is the output to be inserted in the same place where
the matching elements are.
If an element in the source XML file is matched, the entire
element will be replaced, starting from "<" of the starting tag to ">" of the ending
tag. By this definition, the replacement includes the element name, all attributes,
text content, and all sub-elements.
For example, if we have the following element in the source XML file:
<p a="v">
Some text with a <c>child element</c>.
</p>
and the following template in the XSL file:
<xsl:template match="p">
Replacement text for the element "p" in the source XML file.
</xsl:template>
the output will be:
Replacement text for the element "p" in the source XML file.
because the tags, attribute, text content, and child element are all replaced by the
text specified in the template statement.