Copyright © 1998 W3C (MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply.
This document is a Proposed Recommendation of the World Wide Web Consortium and is currently undergoing review by the Members of the World Wide Web Consortium.
Review comments on this specification should be sent by 11 Feb, 1999 to <email@example.com>. An archive of public comments is available. W3C Members may send their formal comments, visible only to W3C staff, to <firstname.lastname@example.org>.
This specification is a revision of the public working draft dated 1998-10-01. The Working Group anticipates no further substantial changes to this specification and encourages active implementation to test this specification during the Proposed Recommendation review period. The Working Group expects additional mechanisms for linking style sheets to XML document to be defined in a future specification.
Publication as a Proposed Recommendation does not imply endorsement by the W3C membership. This is still a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite W3C Drafts as other than "work in progress." Refer to the technical reports page for the status of drafts.
This work is part of the W3C XML Activity.
This document allows a stylesheet to be associated with an XML
document by including one or more processing instructions with a
xml-stylesheet in the document's prolog.
Stylesheets can be associated with an XML[XML10] document by using a processing instruction whose
xml-stylesheet. This processing instruction
follows the behaviour of the HTML 4.0
xml-stylesheet processing instruction is parsed
in the same way as a start-tag, with the exception that entities
other than predefined entities must not be referenced.
The following grammar is given using the same notation as the grammar in the XML Recommendation[XML10]. Symbols in the grammar that are not defined here are defined in the XML Recommendation.
|||StylesheetPI||::=||'<?xml-stylesheet' (S PseudoAtt)* S? '?>'|
|||PseudoAtt||::=||Name S? '=' S? PseudoAttValue|
|||PseudoAttValue||::=||'"' ([^"<&] | CharRef | PredefEntityRef)* '"'|
|| "'" ([^'<&] | CharRef | PredefEntityRef)* "'"|
|||PredefEntityRef||::=||'&' | '<' | '>' | '"' | '''|
In PseudoAttValue, a CharRef or a PredefEntityRef is interpreted in the same manner as in a normal XML attribute value. The actual value of the pseudo-attribute is the value after each reference is replaced by the character it references. This replacement is not performed automatically by an XML processor.
xml-stylesheet processing instruction is
allowed anywhere in the prolog of an XML document. The syntax of
XML constrains where processing instructions are allowed in the
xml-stylesheet processing instruction is
subject to these constraints in the same way as any other
The following pseudo attributes are defined
href CDATA #REQUIRED type CDATA #REQUIRED title CDATA #IMPLIED media CDATA #IMPLIED charset CDATA #IMPLIED alternate (yes|no) "no"
The semantics of the pseudo-attributes are exactly as with
<LINK REL="stylesheet"> in HTML 4.0, with the
exception of the
alternate pseudo-attribute. If
alternate="yes" is specified, then the processing
instruction has the semantics of
stylesheet"> instead of
HTTP [RFC2068], section 188.8.131.52, allows
stylesheets to be associated with XML documents by means of the
Link header. Any links specified by HTTP
Link headers are considered to occur before the links
specified by the
instructions. This is the same as in HTML 4.0 (see section 14.6).
Here are some examples from HTML 4.0 with the corresponding processing instruction:
<LINK href="mystyle.css" rel="stylesheet" type="text/css"> <?xml-stylesheet href="mystyle.css" type="text/css"?> <LINK href="mystyle.css" title="Compact" rel="stylesheet" type="text/css"> <?xml-stylesheet href="mystyle.css" title="Compact" type="text/css"?> <LINK href="mystyle.css" title="Medium" rel="alternate stylesheet" type="text/css"> <?xml-stylesheet alternate="yes" href="mystyle.css" title="Medium" type="text/css"?>
xml-stylesheet processing instructions are
also allowed with exactly the same semantics as with
REL="stylesheet". For example,
<LINK rel="alternate stylesheet" title="compact" href="small-base.css" type="text/css"> <LINK rel="alternate stylesheet" title="compact" href="small-extras.css" type="text/css"> <LINK rel="alternate stylesheet" title="big print" href="bigprint.css" type="text/css"> <LINK rel="stylesheet" href="common.css" type="text/css">
would be equivalent to:
<?xml-stylesheet alternate="yes" title="compact" href="small-base.css" type="text/css"?> <?xml-stylesheet alternate="yes" title="compact" href="small-extras.css" type="text/css"?> <?xml-stylesheet alternate="yes" title="big print" href="bigprint.css" type="text/css"?> <?xml-stylesheet href="common.css" type="text/css"?>
Use of a processing instruction avoids polluting the main document structure with application specific processing information. This is what processing instructions are designed for.
There was an urgent requirement for a specification for stylesheet linking that could be completed in time for the next release from major browser vendors. Only by choosing a simple mechanism closely based on a proven existing mechanism could the specification be completed in time to meet this requirement.
The mechanism chosen for this version of the specification is not a constraint on the additional mechanisms planned for future versions; there is no constraint that these use processing instructions, nor even that they include the linking information in the source document.