HTML and CSS Reference
In-Depth Information
The XSL template
The XSL template
element associates each
output with an input.
The match="/" attribute
defines the entire
Table 12-22 General Form of the template Element
General form:
<xsl:template match="pattern" language="language">
... (other stylesheet code)
The pattern indicates the XML element or node. A pattern of "/" indicates that the entire
document will be displayed. The template element needs an end element.
<xsl:template match="/">
... (other stylesheet code)
To Start Creating an XSL Style Sheet
This XSL style sheet will display the items in order by item description, using the <item-description>
tag element in the XML file. Table 12-23 shows the code for the processing instruction, an XML declaration, a
stylesheet element, and a template element in an XSL style sheet.
Table 12-23 Code for Creating an XSL Style Sheet
<?xml version=”1.0” encoding=”utf-8” standalone=”yes” ?>
<xsl:transform version=”1.0” xmlns:xsl=””>
<xsl:template match=”/”>
Line 1 is the XML declaration that identifies this as an XML document using XML version 1.0. Line 2 is the
XSL stylesheet element used to define the namespace, xsl, for the remaining elements. Line 3 defines the template
pattern, using a “/” to indicate that the template applies to the entire XML document. The following step begins
creating an XSL style sheet.
If necessary, activate
the Notepad++
saved filename
in tab
Click File on the
style sheet transform
element to define
menu bar, and
then New to start
a new Notepad++
"/" indicates
template applies
to all elements in
start of template
With your USB drive
plugged into your
computer, click File on the
menu bar, and then click
Save As. If necessary, navigate to the Chapter12\ChapterFiles folder.
Figure 12-24
chapter12-1products_solution.xsl in the File name text box and then click the Save button.
Enter the code shown in Table 12-23 to start the XSL style sheet, and then press the
e n t e r key once after line 3 (Figure 12-24).
What happens if more than one XSL style sheet is linked to an XML document?
If more than one XSL style sheet is linked to an XML document, the first XSL style sheet the browser reads is used and
the others are ignored.
Can an XSL style sheet and Cascading Style Sheet both be linked to an XML document?
If an XSL style sheet and a Cascading Style Sheet are both linked to an XML document, the XSL style sheet is used and
the Cascading Style Sheet is ignored.
Search WWH ::

Custom Search