0N/A<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
0N/A<html>
0N/A<head>
0N/A<title>Associating Style Sheets with XML documents</title>
0N/A<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-REC">
0N/A<style type="text/css">code { font-family: monospace }</style>
0N/A</head>
0N/A<body>
0N/A<div class="head">
0N/A<a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/WWW/w3c_home" alt="W3C" height="48" width="72"></a>
0N/A<h1>Associating Style Sheets with XML documents<br>Version 1.0</h1>
0N/A<h2>W3C Recommendation 29 June 1999</h2>
0N/A<dl>
0N/A<dt>This version:</dt>
0N/A<dd>
0N/A<a href="http://www.w3.org/1999/06/REC-xml-stylesheet-19990629">http://www.w3.org/1999/06/REC-xml-stylesheet-19990629</a>
0N/A<br>
0N/A</dd>
0N/A<dt>Latest version:</dt>
0N/A<dd>
0N/A<a href="http://www.w3.org/TR/xml-stylesheet">http://www.w3.org/TR/xml-stylesheet</a>
0N/A<br>
0N/A</dd>
0N/A<dt>Previous version:</dt>
0N/A<dd>
0N/A<a href="http://www.w3.org/TR/1999/xml-stylesheet-19990428">http://www.w3.org/TR/1999/xml-stylesheet-19990428</a>
0N/A<br>
0N/A</dd>
0N/A<dt>Editor:</dt>
0N/A<dd>
0N/A
0N/AJames Clark
0N/A<a href="mailto:jjc@jclark.com">&lt;jjc@jclark.com&gt;</a>
0N/A<br>
0N/A</dd>
0N/A</dl>
0N/A<p class="copyright">
0N/A<a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#Copyright">
0N/A Copyright</a> &nbsp;&copy;&nbsp; 1999 <a href="http://www.w3.org">W3C</a>
0N/A (<a href="http://www.lcs.mit.edu">MIT</a>,
0N/A <a href="http://www.inria.fr/">INRIA</a>,
0N/A <a href="http://www.keio.ac.jp/">Keio</a> ), All Rights Reserved. W3C
0N/A <a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#Legal Disclaimer">liability,</a><a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#W3C Trademarks">trademark</a>,
0N/A <a href="http://www.w3.org/Consortium/Legal/copyright-documents.html">document use </a>and
0N/A <a href="http://www.w3.org/Consortium/Legal/copyright-software.html">software licensing </a>rules apply.
0N/A </p>
0N/A<hr title="Separator for header">
0N/A</div>
0N/A<h2>
0N/A<a name="abstract">Abstract</a>
0N/A</h2>
0N/A
0N/A<p>This document allows a style sheet to be associated with an XML
0N/Adocument by including one or more processing instructions with a
0N/Atarget of <code>xml-stylesheet</code> in the document's prolog.</p>
0N/A
0N/A<h2>
0N/A<a name="status">Status of this document</a>
0N/A</h2>
0N/A
0N/A<p>This document has been reviewed by W3C Members and other interested
0N/Aparties and has been endorsed by the Director as a W3C <a href="http://www.w3.org/Consortium/Process/#RecsW3C">Recommendation</a>. It
0N/Ais a stable document and may be used as reference material or cited as
0N/Aa normative reference from other documents. W3C's role in making the
0N/ARecommendation is to draw attention to the specification and to
0N/Apromote its widespread deployment. This enhances the functionality and
0N/Ainteroperability of the Web.</p>
0N/A
0N/A<p>The list of known errors in this specifications is available at
0N/A<a href="http://www.w3.org/1999/06/REC-xml-stylesheet-19990629/errata">http://www.w3.org/TR/1999/xml-stylesheet-19990629/errata</a>.</p>
0N/A
0N/A<p>Comments on this specification may be sent to &lt;<a href="mailto:www-xml-stylesheet-comments@w3.org">www-xml-stylesheet-comments@w3.org</a>&gt;. The archive of public
0N/Acomments is available at <a href="http://www.w3.org/Archives/Public/www-xml-stylesheet-comments">http://w3.org/Archives/Public/www-xml-stylesheet-comments</a>.</p>
0N/A
0N/A<p>A list of current W3C Recommendations and other technical documents
0N/Acan be found at <a href="http://www.w3.org/TR">http://www.w3.org/TR</a>.</p>
0N/A
0N/A<p>The Working Group expects additional mechanisms for linking style
0N/Asheets to XML document to be defined in a future specification.</p>
0N/A
0N/A<p>The use of XML processing instructions in this specification should
0N/Anot be taken as a precedent. The W3C does not anticipate recommending
0N/Athe use of processing instructions in any future specification. The
0N/A<a href="#rationale">Rationale</a> explains why they were used in
0N/Athis specification.</p>
0N/A
0N/A<p>This document was produced as part of the <a href="http://www.w3.org/XML/Activity">W3C XML Activity</a>.</p>
0N/A
0N/A
0N/A<h2>
0N/A<a name="contents">Table of contents</a>
0N/A</h2>1 <a href="#The xml-stylesheet processing instruction">The xml-stylesheet processing instruction</a>
0N/A<br>
0N/A<h3>Appendices</h3>A <a href="#References">References</a>
0N/A<br>B <a href="#rationale">Rationale</a>
0N/A<br>
0N/A<hr>
0N/A
0N/A<h2>
0N/A<a name="The xml-stylesheet processing instruction"></a>1 The <code>xml-stylesheet</code> processing instruction</h2>
0N/A
0N/A<p>Style Sheets can be associated with an XML<a href="#XML">[XML10]</a>
0N/Adocument by using a processing instruction whose target is
0N/A<code>xml-stylesheet</code>. This processing instruction follows the
0N/Abehaviour of the HTML 4.0 <code>&lt;LINK
0N/AREL="stylesheet"&gt;</code><a href="#HTML">[HTML40]</a>.</p>
0N/A
0N/A<p>The <code>xml-stylesheet</code> processing instruction is parsed in
0N/Athe same way as a start-tag, with the exception that entities other
0N/Athan predefined entities must not be referenced.</p>
0N/A
0N/A<p>The following grammar is given using the same notation as the
0N/Agrammar in the XML Recommendation<a href="#XML">[XML10]</a>. Symbols in the
0N/Agrammar that are not defined here are defined in the XML
0N/ARecommendation.</p>
0N/A
0N/A<h5>xml-stylesheet processing instruction</h5>
0N/A<table class="scrap">
0N/A<tbody>
0N/A<tr valign="baseline">
0N/A<td>
0N/A<a name="NT-StyleSheetPI"></a>[1]&nbsp;&nbsp;&nbsp;</td>
0N/A<td>StyleSheetPI</td>
0N/A<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
0N/A<td>'&lt;?xml-stylesheet' (<a href="http://www.w3.org/TR/REC-xml#NT-S">S</a> <a href="#NT-PseudoAtt">PseudoAtt</a>)* <a href="http://www.w3.org/TR/REC-xml#NT-S">S</a>? '?&gt;'</td>
0N/A<td>
0N/A</td>
0N/A</tr>
0N/A<tr valign="baseline">
0N/A<td>
0N/A<a name="NT-PseudoAtt"></a>[2]&nbsp;&nbsp;&nbsp;</td>
0N/A<td>PseudoAtt</td>
0N/A<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
0N/A<td>
0N/A<a href="http://www.w3.org/TR/REC-xml#NT-Name">Name</a> <a href="http://www.w3.org/TR/REC-xml#NT-S">S</a>? '=' <a href="http://www.w3.org/TR/REC-xml#NT-S">S</a>? <a href="#NT-PseudoAttValue">PseudoAttValue</a>
0N/A</td>
0N/A<td>
0N/A</td>
0N/A</tr>
0N/A<tr valign="baseline">
0N/A<td>
0N/A<a name="NT-PseudoAttValue"></a>[3]&nbsp;&nbsp;&nbsp;</td>
0N/A<td>PseudoAttValue</td>
0N/A<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
0N/A<td>('"' ([^"&lt;&amp;] | <a href="http://www.w3.org/TR/REC-xml#NT-CharRef">CharRef</a> | <a href="#NT-PredefEntityRef">PredefEntityRef</a>)* '"'</td>
0N/A<td>
0N/A</td>
0N/A</tr>
0N/A<tr valign="baseline">
0N/A<td>
0N/A</td>
0N/A<td>
0N/A</td>
0N/A<td>
0N/A</td>
0N/A<td>| "'" ([^'&lt;&amp;] | <a href="http://www.w3.org/TR/REC-xml#NT-CharRef">CharRef</a> | <a href="#NT-PredefEntityRef">PredefEntityRef</a>)* "'")</td>
0N/A<td>
0N/A</td>
0N/A</tr>
0N/A<tr valign="baseline">
0N/A<td>
0N/A</td>
0N/A<td>
0N/A</td>
0N/A<td>
0N/A</td>
0N/A<td>- (<a href="http://www.w3.org/TR/REC-xml#NT-Char">Char</a>* '?&gt;' <a href="http://www.w3.org/TR/REC-xml#NT-Char">Char</a>*)</td>
0N/A<td>
0N/A</td>
0N/A</tr>
0N/A<tr valign="baseline">
0N/A<td>
0N/A<a name="NT-PredefEntityRef"></a>[4]&nbsp;&nbsp;&nbsp;</td>
0N/A<td>PredefEntityRef</td>
0N/A<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
0N/A<td>'&amp;amp;' | '&amp;lt;' | '&amp;gt;' | '&amp;quot;' | '&amp;apos;'</td>
0N/A<td>
0N/A</td>
0N/A</tr>
0N/A</tbody>
0N/A</table>
0N/A
0N/A<p>In <a href="#NT-PseudoAttValue">PseudoAttValue</a>, a <a href="http://www.w3.org/TR/REC-xml#NT-CharRef">CharRef</a> or a <a href="#NT-PredefEntityRef">PredefEntityRef</a> is interpreted in the
0N/Asame manner as in a normal XML attribute value. The actual value of
0N/Athe pseudo-attribute is the value after each reference is replaced by
0N/Athe character it references. This replacement is not performed
0N/Aautomatically by an XML processor.</p>
0N/A
0N/A<p>The <code>xml-stylesheet</code> processing instruction is allowed
0N/Aonly in the prolog of an XML document. The syntax of XML constrains
0N/Awhere processing instructions are allowed in the prolog; the
0N/A<code>xml-stylesheet</code> processing instruction is allowed anywhere
0N/Ain the prolog that meets these constraints.</p>
0N/A
0N/A<blockquote>
0N/A<b>NOTE: </b>If the <code>xml-stylesheet</code> processing instruction
0N/Aoccurs in the external DTD subset or in a parameter entity, it is
0N/Apossible that it may not be processed by a non-validating XML
0N/Aprocessor (see <a href="#XML">[XML10]</a>).</blockquote>
0N/A
0N/A<p>The following pseudo attributes are defined</p>
0N/A
0N/A<pre>href CDATA #REQUIRED
0N/Atype CDATA #REQUIRED
0N/Atitle CDATA #IMPLIED
0N/Amedia CDATA #IMPLIED
0N/Acharset CDATA #IMPLIED
0N/Aalternate (yes|no) "no"</pre>
0N/A
0N/A<p>The semantics of the pseudo-attributes are exactly as with
0N/A<code>&lt;LINK REL="stylesheet"&gt;</code> in HTML 4.0, with the
0N/Aexception of the <code>alternate</code> pseudo-attribute. If
0N/A<code>alternate="yes"</code> is specified, then the processing
0N/Ainstruction has the semantics of <code>&lt;LINK REL="alternate
0N/Astylesheet"&gt;</code> instead of <code>&lt;LINK
0N/AREL="stylesheet"&gt;</code>.</p>
0N/A
0N/A<blockquote>
0N/A<b>NOTE: </b>Since the value of the <code>href</code> attribute is a URI
0N/Areference, it may be a relative URI and it may contain a fragment
0N/Aidentifier. In particular the URI reference may contain only a
0N/Afragment identifier. Such a URI reference is a reference to a part of
0N/Athe document containing the <code>xml-stylesheet</code> processing
0N/Ainstruction (see <a href="#RFC2396">[RFC2396]</a>). The consequence is that the
0N/A<code>xml-stylesheet</code> processing instruction allows style sheets
0N/Ato be embedded in the same document as the <code>xml-stylesheet</code>
0N/Aprocessing instruction.</blockquote>
0N/A
0N/A<p>In some cases, style sheets may be linked with an XML document by
0N/Ameans external to the document. For example, earlier versions of HTTP
0N/A<a href="#RFC2068">[RFC2068]</a> (section 19.6.2.4) allowed style sheets to be
0N/Aassociated with XML documents by means of the <code>Link</code>
0N/Aheader. Any links to style sheets that are specified externally to the
0N/Adocument are considered to occur before the links specified by the
0N/A<code>xml-stylesheet</code> processing instructions. This is the same
0N/Aas in HTML 4.0 (see <a href="http://www.w3.org/TR/REC-html40/present/styles.html#h-14.6">section
0N/A14.6</a>).</p>
0N/A
0N/A<p>Here are some examples from HTML 4.0 with the corresponding
0N/Aprocessing instruction:</p>
0N/A
0N/A<pre>&lt;LINK href="mystyle.css" rel="style sheet" type="text/css"&gt;
0N/A&lt;?xml-stylesheet href="mystyle.css" type="text/css"?&gt;
0N/A
0N/A&lt;LINK href="mystyle.css" title="Compact" rel="stylesheet"
0N/Atype="text/css"&gt;
0N/A&lt;?xml-stylesheet href="mystyle.css" title="Compact" type="text/css"?&gt;
0N/A
0N/A&lt;LINK href="mystyle.css" title="Medium" rel="alternate stylesheet"
0N/Atype="text/css"&gt;
0N/A&lt;?xml-stylesheet alternate="yes" href="mystyle.css" title="Medium"
0N/Atype="text/css"?&gt;</pre>
0N/A
0N/A<p>Multiple <code>xml-stylesheet</code> processing instructions are
0N/Aalso allowed with exactly the same semantics as with <code>LINK
0N/AREL="stylesheet"</code>. For example,</p>
0N/A
0N/A<pre>&lt;LINK rel="alternate stylesheet" title="compact" href="small-base.css"
0N/Atype="text/css"&gt;
0N/A&lt;LINK rel="alternate stylesheet" title="compact" href="small-extras.css"
0N/Atype="text/css"&gt;
0N/A&lt;LINK rel="alternate stylesheet" title="big print" href="bigprint.css"
0N/Atype="text/css"&gt;
0N/A&lt;LINK rel="stylesheet" href="common.css" type="text/css"&gt;</pre>
0N/A
0N/A<p>would be equivalent to:</p>
0N/A
0N/A<pre>&lt;?xml-stylesheet alternate="yes" title="compact" href="small-base.css"
0N/Atype="text/css"?&gt;
0N/A&lt;?xml-stylesheet alternate="yes" title="compact" href="small-extras.css"
0N/Atype="text/css"?&gt;
0N/A&lt;?xml-stylesheet alternate="yes" title="big print" href="bigprint.css"
0N/Atype="text/css"?&gt;
0N/A&lt;?xml-stylesheet href="common.css" type="text/css"?&gt;</pre>
0N/A
0N/A
0N/A
0N/A<hr title="Separator from footer">
0N/A
0N/A<h2>
0N/A<a name="References"></a>A References</h2>
0N/A
0N/A<dl>
0N/A
0N/A<dt>
0N/A<a name="HTML">HTML40</a>
0N/A</dt>
0N/A<dd>World Wide Web
0N/AConsortium. <i>HTML 4.0 Specification.</i> W3C Recommendation. See
0N/A<a href="http://www.w3.org/TR/REC-html40">http://www.w3.org/TR/REC-html40</a>
0N/A</dd>
0N/A
0N/A<dt>
0N/A<a name="RFC2068">RFC2068</a>
0N/A</dt>
0N/A<dd>R. Fielding, J. Gettys, J. Mogul,
0N/AH. Frystyk Nielsen, and T. Berners-Lee. <i>Hypertext Transfer
0N/AProtocol -- HTTP/1.1.</i>. IETF RFC 2068. See <a href="http://www.ietf.org/rfc/rfc2068.txt">http://www.ietf.org/rfc/rfc2068.txt</a>.</dd>
0N/A
0N/A<dt>
0N/A<a name="RFC2396">RFC2396</a>
0N/A</dt>
0N/A<dd>T. Berners-Lee, R. Fielding, and
0N/AL. Masinter. <i>Uniform Resource Identifiers (URI): Generic
0N/ASyntax</i>. IETF RFC 2396. See <a href="http://www.ietf.org/rfc/rfc2396.txt">http://www.ietf.org/rfc/rfc2396.txt</a>.</dd>
0N/A
0N/A<dt>
0N/A<a name="XML">XML10</a>
0N/A</dt>
0N/A<dd>World Wide Web Consortium. <i>Extensible
0N/AMarkup Language (XML) 1.0.</i> W3C Recommendation. See <a href="http://www.w3.org/TR/1998/REC-xml-19980210">http://www.w3.org/TR/1998/REC-xml-19980210</a>
0N/A</dd>
0N/A
0N/A</dl>
0N/A
0N/A
0N/A
0N/A
0N/A<h2>
0N/A<a name="rationale"></a>B Rationale</h2>
0N/A
0N/A<p>There was an urgent requirement for a specification for style sheet
0N/Alinking that could be completed in time for the next release from
0N/Amajor browser vendors. Only by choosing a simple mechanism closely
0N/Abased on a proven existing mechanism could the specification be
0N/Acompleted in time to meet this requirement.</p>
0N/A
0N/A<p>Use of a processing instruction avoids polluting the main document
0N/Astructure with application specific processing information.</p>
0N/A
0N/A<p>The mechanism chosen for this version of the specification is not a
0N/Aconstraint on the additional mechanisms planned for future versions.
0N/AThere is no expectation that these will use processing instructions;
0N/Aindeed they may not include the linking information in the source
0N/Adocument.</p>
0N/A
0N/A
0N/A
0N/A
0N/A</body>
0N/A</html>