typeThe type of the style sheet (
text/css, for example)
hrefThe location of the style sheet
These two attributes are both required in order to wire a style sheet to an XML document. Following is an example of how to use the
xml-stylesheet processing instruction with the
<?xml-stylesheet type="text/css" href="talltales.css"?>
In this example, the
type attribute is used to specify that the type of the style sheet is
text/css, which means that the style sheet is a CSS style sheet. The style sheet file is then referenced in the
href attribute, which in this case points to the file
By the Way
It is necessary to specify the type of a style sheet in the xml-stylesheet processing instruction because there are other types of style sheets, such as XSLT and XSL-FO style sheets, which you learn about in upcoming lessons.
External style sheets represent the only way to use CSS directly with XML documents without the assistance of any other technology. I say this because it is possible to incorporate style sheets into the formatting of XML documents a little differently when you are also using XSLT. More specifically, with XSLT you are actually translating an XML document into an HTML document for display purposes. Knowing this, it is possible to use inline styles directly with HTML elements in order to apply styles to XML content indirectly. You can also use external style sheets with HTML documents that are translated from XML. You learn how to carry out both of these style approaches in Tutorial 11, "Getting Started with XSL."