Associating Style Sheets with XML documents 1.0 (Second Edition) code { font-family: monospace; }
div.constraint, div.issue, div.note, div.notice { margin-left: 2em; }
ol.enumar { list-style-type: decimal; } ol.enumla { list-style-type: lower-alpha; } ol.enumlr { list-style-type: lower-roman; } ol.enumua { list-style-type: upper-alpha; } ol.enumur { list-style-type: upper-roman; }
div.exampleInner pre { margin-left: 1em; margin-top: 0em; margin-bottom: 0em} div.exampleOuter {border: 4px double gray; margin: 0em; padding: 0em} div.exampleInner { background-color: #d5dee3; border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; border-bottom-width: 4px; border-bottom-style: double; border-bottom-color: #d3d3d3; padding: 4px; margin: 0em } div.exampleWrapper { margin: 4px } div.exampleHeader { font-weight: bold; margin: 4px} This version: http://www.w3.org/TR/2010/REC-xml-stylesheet-20101028 Latest version: http://www.w3.org/TR/xml-stylesheet Previous versions: http://www.w3.org/TR/2010/PER-xml-stylesheet-20100909 Editors: James Clark (First Edition) <[email protected]> Simon Pieters (Second Edition), Opera Software <[email protected]> Henry S. Thompson (Second Edition), University of Edinburgh <[email protected]> Please refer to the errata See also translations This document is also available in these non-normative formats: XML Copyright W3C ® MIT ERCIM Keio liability trademark document use This document allows style sheets to be associated with an XML document by including one or more processing instructions with a target of xml-stylesheet This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index This document is a product of the XML Core Working Group W3C XML Activity http://www.w3.org/2003/03/Translations/byTechnology?technology=xml-stylesheet This second edition incorporates all known errata as of the publication date, clarifies several areas left unspecified in the earlier edition, and has been restructured to allow other specifications to reuse the rules for parsing pseudo-attributes from a string. A more detailed description of the changes from the first edition is in B Changes since the first edition edition of 29 June 1999 Comments on this document may be sent to [email protected] archives http://www.w3.org/1999/06/REC-xml-stylesheet-19990629/errata This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. 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. W3C maintains a public list of any patent disclosures Essential Claim(s) section 6 of the W3C Patent Policy 1 Introduction Conformance requirements Pseudo-attributes The xml-stylesheet processing instruction A References Changes since the first edition (This section is non-normative.) Authors might have particular intentions as to how user agents are to present the information contained in their XML documents. This specification provides a non-intrusive mechanism, using a processing instruction, to provide links to one or more style sheets, i.e. resources specifying the desired rendering in a designated language. User agents will use these resources to control presentation of XML. Consider an XHTML document with style sheet associations using the link <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Example with link elements</title> <link rel="stylesheet" href="common.css"/> <link rel="stylesheet" href="default.css" title="Default style"/> <link rel="alternate stylesheet" href="alt.css" title="Alternative style"/> <link rel="stylesheet" href="single-col.css" media="all and (max-width: 30em)"/> </head> <body> ... </body> </html> This document could be written as follows, using xml-stylesheet processing instructions <?xml-stylesheet href="common.css"?> <?xml-stylesheet href="default.css" title="Default style"?> <?xml-stylesheet alternate="yes" href="alt.css" title="Alternative style"?> <?xml-stylesheet href="single-col.css" media="all and (max-width: 30em)"?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Example with xml-stylesheet processing instructions</title> </head> <body> ... </body> </html> All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative. The key words must must not should should not may [RFC2119] The following conformance classes are defined by this specification: Documents A document is considered to be a conforming document if it satisfies all must xml-stylesheet processing instructions 4 The xml-stylesheet processing instruction xml-stylesheet processors XML defines an application XML processor Definition xml-stylesheet processor processing instructions [XML] An xml-stylesheet processor xml-stylesheet processor must xml-stylesheet processors xml-stylesheet processors Applications An xml-stylesheet processor may may Definition application A detailed specification of how applications xml-stylesheet processing instructions It is however expected that specifications governing the use of stylesheet languages will reference this specification in describing how applications may identify stylesheets for use. Such specifications are expected to specify interpretations for the values (or absense of value) of those pseudo-attributes pseudo-attributes' 4 The xml-stylesheet processing instruction This specification is defined with reference to the vocabulary for XML provided by the XML Information Set. [INFOSET] The productions in this specification use the same notation as used in the XML specification. Tokens in the grammar that are not defined in this specification are defined in the XML specification. [XML] [ Definition rules for parsing pseudo-attributes from a string [ Definition parsing result pseudo-attributes If the given string is not matched by the PseudoAtts parsing result PseudoAtts ::= PseudoAtt S PseudoAtt S PseudoAtt ::= Name S S PseudoAttValue PseudoAttValue ::= ('"' ([^"<&] | CharRef PredefEntityRef CharRef PredefEntityRef PredefEntityRef ::= "&" | "<" | ">" | """ | "'" [ Definition PseudoAtt PseudoAtts pseudo-attribute pseudo-attribute name value [ Definition Name PseudoAtt name pseudo-attribute [ Definition PseudoAttValue PseudoAtt value pseudo-attribute Each CharRef [XML] Each PredefEntityRef PseudoAttValue & < > " ' The first and last character (the start and end quotes) are removed. The parsing result Legal Character well-formedness contraint CharRef [XML] The parsing result pseudo-attribute name If the parsing result pseudo-attributes PseudoAtts [ Definition potential xml-stylesheet processing instruction xml-stylesheet For potential xml-stylesheet processing instructions xml-stylesheet processors must application parsing result rules for parsing pseudo-attributes from a string For potential xml-stylesheet processing instructions xml-stylesheet processors may application parsing result rules for parsing pseudo-attributes from a string Definition application ignored Note: Since non-validating XML processors are not required to read parameter entities or the external subset, it is possible that processing instructions that appear in parameter entities or the external subset will not be present in the document type declaration information item's [children] property. [XML] [ Definition potential xml-stylesheet processing instruction xml-stylesheet processing instruction parsing result rules for parsing pseudo-attributes from a string Documents must not xml-stylesheet xml-stylesheet processing instructions Documents should not xml-stylesheet processing instructions An xml-stylesheet processing instruction StyleSheetPI ::= "<?xml-stylesheet" ( ( S PseudoAtts Char Char Documents may pseudo-attributes xml-stylesheet processing instructions href Gives the address of the referenced style sheet. Documents must pseudo-attribute must value [RFC3987] Note: It is possible to associate a style sheet that is in the same document as the xml-stylesheet processing instruction href pseudo-attribute For details on how this is managed in XSLT, see 3.11 Embedded Stylesheet Modules [XSLT] type Gives an advisory media type for the referenced style sheet. If specified, documents must value media-type [RFC2616] Note: Syntactic text/xsl application/xslt+xml The value title Gives the title of the referenced style sheet in a style sheet set. No constraints beyond those of the PseudoAttValue value media Gives the media for which the referenced style sheet applies. If specified, documents must value media_query_list [MQ] charset Gives an advisory character encoding for the referenced style sheet. If specified, documents must value must [IANACHARSET] The value alternate If the value yes must title pseudo-attribute value must value yes no Documents must not pseudo-attributes xml-stylesheet processing instructions Any links to style sheets that are specified externally to the document (e.g. Link [RFC2068] xml-stylesheet processing instructions application References are normative unless marked "non-normative". Character Sets XML Information Set Media Queries (non-normative) Hypertext Transfer Protocol — HTTP/1.1 Key words for use in RFCs to Indicate Requirement Levels Hypertext Transfer Protocol — HTTP/1.1 Internationalized Resource Identifiers (IRIs) Extensible Markup Language (non-normative) XSL Transformations (XSLT) Version 2.0 This appendix is non-normative The first edition of this specification was admirably brief, but at the same time left many details unstated. This second edition aims to fill the gaps left in the first edition, while restructuring the presentation to provide for independent citation and re-use of the pseudo-attribute construct. Neither the syntax nor the semantics of the xml-stylesheet xml-stylesheet The following list identifies the major changes which have been made: Provided definitions for a number of terms used but not defined in the first edition; Added a conformance section, distinguishing between processor and document conformance, all of which was implicit in the first edition; Identified a number of error cases, which were implicit in the first edition's appeal to the parallel with element start tag processing, and specified expected processor behaviour; In recognition of deployed processor behaviour, allowed xml-stylesheet Added a number of references, but removed the explicit dependence on the HTML 4.0 specification by adding descriptions of the meanings of each of the pseudo-attributes consistent with their HTML 4.0 use but brought up-to-date; Removed the (non-normative) Rationale section, as it contained a number of out-of-date assumptions; Made the type existing erratum