By the Way
You can also use the general file extension .xml or the more specific extension .xslt for your XSLT style sheets. The extension really doesn't matter so long as you reference the style sheet properly from the XML document to which it applies.
-
type
The type of the style sheet (text/xsl, for example) -
HRef
The location of the style sheet
By the Way
You may notice that this discussion focuses on XSL style sheets in general, as opposed to XSLT style sheets. That's because XSLT style sheets are really just a specific kind of XSL style sheet, and from the perspective of an XML document there is no difference between the two. So, when it comes to associating an XSLT style sheet with an XML document, you simply reference it as an XSL style sheet.
These two attributes should be somewhat familiar to you from the discussion of CSS because they are also used to wire CSS to XML documents. The difference in their usage with XSL is revealed in their valuesthe type
attribute must be set to text/xsl
for XSL style sheets, whereas the HRef
attribute must be set to the name of the XSL style sheet. These two attributes are both required in order to wire an XSL style sheet to an XML document. Following is an example of how to use the xml-stylesheet
processing instruction with an XSL style sheet:
<?xml-stylesheet type="text/xsl" href="contacts.xsl"?>
In this example, the type
attribute is used to specify that the type of the style sheet is text/xsl
, which means that the style sheet is an XSL style sheet. The style sheet file is then referenced in the HRef
attribute, which in this case points to the file contacts.xsl
.