- Associating stylesheets with XML documents
- Status of this document
- Table of Contents
- Appendices
- 1. The xml-stylesheet processing instruction
- xml-stylesheet processing instruction
- A. References
- B. Rationale (Non-Normative)
- Associating Style Sheets with XML documents Version 1.0
- Status of this document
- Table of contents
- Appendices
- 1 The xml-stylesheet processing instruction
- A References
- B Rationale
Associating stylesheets with XML documents
This specification allows a stylesheet to be associated with an XML document by including one or more processing instructions with a target of xml-stylesheet in the document’s prolog.
Status of this document
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 26 May, 1999 to . An archive of public comments is available. W3C Members may send their formal comments, visible only to the W3C Team, to .
This specification should not be taken as a precedent, as XML Processing Instructions are unlikely to be used in any future W3C Recommendations.
This specification is a revision of the public working draft dated 1999-04-07. 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.
Table of Contents
Appendices
1. The xml-stylesheet processing instruction
Stylesheets can be associated with an XML[XML10] document by using a processing instruction whose target is xml-stylesheet . This processing instruction follows the behaviour of the HTML 4.0 [HTML40].
The 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.
xml-stylesheet processing instruction
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.
The 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 prolog; the xml-stylesheet processing instruction is subject to these constraints in the same way as any other processing instruction.
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 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 instead of .
In some cases, a stylesheet might be associated with an XML document by means of some external context. For example, earlier versions of HTTP [RFC2068] (section 19.6.2.4) allowed 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 xml-stylesheet processing 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:
Multiple xml-stylesheet processing instructions are also allowed with exactly the same semantics as with LINK REL=»stylesheet» . For example,
A. References
HTML40 World Wide Web Consortium. HTML 4.0 Specification. W3C Recommendation. See http://www.w3.org/TR/REC-html40 RFC2068 R. Fielding, J. Gettys, J. Mogul, H. Frystyk Nielsen, and T. Berners-Lee. Hypertext Transfer Protocol — HTTP/1.1.. IETF RFC 2068. See http://info.internet.isi.edu/in-notes/rfc/files/rfc2068.txt. XML10 World Wide Web Consortium. Extensible Markup Language (XML) 1.0. W3C Recommendation. See http://www.w3.org/TR/1998/REC-xml-19980210
B. Rationale (Non-Normative)
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.
Associating Style Sheets with XML documents
Version 1.0
This document allows a style sheet to be associated with an XML document by including one or more processing instructions with a target of xml-stylesheet in the document’s prolog.
Status of this document
This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited as a normative reference from other documents. W3C’s role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web.
The list of known errors in this specifications is available at http://www.w3.org/TR/1999/xml-stylesheet-19990629/errata.
Comments on this specification may be sent to . The archive of public comments is available at http://w3.org/Archives/Public/www-xml-stylesheet-comments.
A list of current W3C Recommendations and other technical documents can be found at http://www.w3.org/TR.
The Working Group expects additional mechanisms for linking style sheets to XML document to be defined in a future specification.
The use of XML processing instructions in this specification should not be taken as a precedent. The W3C does not anticipate recommending the use of processing instructions in any future specification. The Rationale explains why they were used in this specification.
This document was produced as part of the W3C XML Activity.
Table of contents
Appendices
1 The xml-stylesheet processing instruction
Style Sheets can be associated with an XML[XML10] document by using a processing instruction whose target is xml-stylesheet . This processing instruction follows the behaviour of the HTML 4.0 [HTML40].
The 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.
xml-stylesheet processing instruction
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.
The xml-stylesheet processing instruction is allowed only in the prolog of an XML document. The syntax of XML constrains where processing instructions are allowed in the prolog; the xml-stylesheet processing instruction is allowed anywhere in the prolog that meets these constraints.
NOTE: If the xml-stylesheet processing instruction occurs in the external DTD subset or in a parameter entity, it is possible that it may not be processed by a non-validating XML processor (see [XML10]).
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 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 instead of .
NOTE: Since the value of the href attribute is a URI reference, it may be a relative URI and it may contain a fragment identifier. In particular the URI reference may contain only a fragment identifier. Such a URI reference is a reference to a part of the document containing the xml-stylesheet processing instruction (see [RFC2396]). The consequence is that the xml-stylesheet processing instruction allows style sheets to be embedded in the same document as the xml-stylesheet processing instruction.
In some cases, style sheets may be linked with an XML document by means external to the document. For example, earlier versions of HTTP [RFC2068] (section 19.6.2.4) allowed style sheets to be associated with XML documents by means of the Link header. Any links to style sheets that are specified externally to the document are considered to occur before the links specified by the xml-stylesheet processing 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:
Multiple xml-stylesheet processing instructions are also allowed with exactly the same semantics as with LINK REL=»stylesheet» . For example,
A References
HTML40 World Wide Web Consortium. HTML 4.0 Specification. W3C Recommendation. See http://www.w3.org/TR/REC-html40 RFC2068 R. Fielding, J. Gettys, J. Mogul, H. Frystyk Nielsen, and T. Berners-Lee. Hypertext Transfer Protocol — HTTP/1.1.. IETF RFC 2068. See http://www.ietf.org/rfc/rfc2068.txt. RFC2396 T. Berners-Lee, R. Fielding, and L. Masinter. Uniform Resource Identifiers (URI): Generic Syntax. IETF RFC 2396. See http://www.ietf.org/rfc/rfc2396.txt. XML10 World Wide Web Consortium. Extensible Markup Language (XML) 1.0. W3C Recommendation. See http://www.w3.org/TR/1998/REC-xml-19980210
B Rationale
There was an urgent requirement for a specification for style sheet 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.
Use of a processing instruction avoids polluting the main document structure with application specific processing information.
The mechanism chosen for this version of the specification is not a constraint on the additional mechanisms planned for future versions. There is no expectation that these will use processing instructions; indeed they may not include the linking information in the source document.