The stylesheet for an XML document is specified with the processing instruction xml-stylesheet in the prolog of the XML document. For instance, the recipe stylesheet has been associated to the recipe XML document with the following processing instruction:
<?xml-stylesheet type="text/css" href="recipe.css" title="List" alternate="no"?>
The pseudo-attribute type specifies the MIME media type for CSS. The pseudo-attribute href is the URL where the stylesheet can be found, while title gives a name to the stylesheet. Finally, alternate has value no if the stylesheet is the default one, or it has value yes if the stylesheet is an alternate stylesheet.
In fact, more than one stylesheet can be associated with the same XML document by adding different xml-stylesheet processing instructions. Usually, the XML document is loaded with a default stylesheet and the web browser gives the user the possibility to choose an alternative stylesheet. The stylesheets are identified by the name given with the title pseudo-attribute. If you are using Mozilla Firefox, you can alternate different stylesheets with the menu option View/Page Style. As an example, we associated 4 different stylesheets to the recipe XML document as follows:
<?xml-stylesheet type="text/css" href="recipe.css" title="Default" alternate="no"?> <?xml-stylesheet type="text/css" href="recipe2.css" title="Pretty" alternate="yes"?> <?xml-stylesheet type="text/css" href="recipe3.css" title="Float left" alternate="yes"?> <?xml-stylesheet type="text/css" href="recipe4.css" title="Float right" alternate="yes"?>
The default stylesheet is named Default and the alternative ones are called Pretty, Float left, and Float right. You can try to alternate the stylesheets associated to the recipe document if your browser allows you to do this.