Publishing with XML - Herong's Tutorial Examples - v4.02, by Dr. Herong Yang
Introduction to XSL Templates?
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:
<xsl:template match="pattern"> replacement_content </xsl:template>
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.
For more tutorials on XSL templates, please see my other book: Herong's Tutorial Notes On XML Technologies.
Table of Contents
Ideas on Publishing Books using XML
Overview of hyPub - A Simple XML Publishing Tool
Writing Book Contents in XHTML Source Files
►Transforming Book Source Files with XSL Technology
What Is XSL (eXtensible Style Language)?
►Introduction to XSL Templates?
xalan - XSL Transformation Processing Engine
How XSL Technology Is Used in hyPub?
Designing Web Page Layouts with Tables
Controlling Web Page Appearance with CSS
Sharing HTML Codes with JavaScript Files
Generating Web Pages with hyPub
Formatting Printable Documents with XSL-FO