Linking Your Style Sheet

Before talking about how you will create XSLT style sheets, it is important to know how to link your style sheet to an XML document instance.

There are two ways you can link your style sheet to the document instance:

  • Statically

  • Dynamically

The first method, linking your style sheet statically, is the easiest. All you do is place a reference in your XML document to the style sheet. The reference is created using the <?xml-stylesheet> directive. The following XML document fragment shows how to create the link:

<?xml version=”1.0” ?> 
<?xml-stylesheet type=”text/xsl” href=”invoice.xsl”?> 

<invoice num=”2317” invoiceDate=”07-09-01”> 
   <!-- style sheet markup goes here --> 
</invoice> 

When the XML processor sees the style sheet ...

Get Special Edition Using XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.