You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
92<br />
<strong>XML</strong> Demystifi ed<br />
You really want this sorted in numerical order. You can fix this problem by using<br />
the data-type attribute of the element. Set the data-type attribute to<br />
number and XSLT places the numbers in numerical order, as we show here:<br />
<br />
<br />
Writing an XSL can become time-consuming, especially if you have to define styles<br />
for many elements in an <strong>XML</strong> source document. A common problem you might run<br />
into is replicating lines of code when you want to repeat a style element in the XSL<br />
stylesheet.<br />
You can avoid replicating code by creating a template. A template associates a<br />
block of code with a name. You use the name in your XSL stylesheet whenever you<br />
want the block of code to appear in the XSL stylesheet.<br />
You create the template using the element. Let’s suppose that an<br />
<strong>XML</strong> source document describes a telephone number using the areacode element,<br />
exchange element, and number element. You’ll need to reference each of these<br />
every time you want to extract a telephone number.<br />
Instead of repeating these, you can create a template and then call the template<br />
whenever you want to extract elements of the phone number. Here’s how to create<br />
a template. The value of the match attribute is the name of the template.<br />
<br />
()<br />
-<br />
<br />
<br />
You call the template by using the element in the XSL<br />
stylesheet, as we show here. The value of the select attribute is the name of the<br />
template that you want to use.<br />
<br />
<br />
<br />
Looking Ahead<br />
You use the Extensible Stylesheet Language (XSL) to describe how an <strong>XML</strong><br />
document is to be transformed by the Extensible Stylesheet Language Transformation<br />
(XSLT) processor into a result document. Transformation is the process of converting