2
|
1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
2 |
<html>
|
|
3 |
<head>
|
|
4 |
<title>Associating Style Sheets with XML documents</title>
|
|
5 |
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-REC">
|
|
6 |
<style type="text/css">code { font-family: monospace }</style>
|
|
7 |
</head>
|
|
8 |
<body>
|
|
9 |
<div class="head">
|
|
10 |
<a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/WWW/w3c_home" alt="W3C" height="48" width="72"></a>
|
|
11 |
<h1>Associating Style Sheets with XML documents<br>Version 1.0</h1>
|
|
12 |
<h2>W3C Recommendation 29 June 1999</h2>
|
|
13 |
<dl>
|
|
14 |
<dt>This version:</dt>
|
|
15 |
<dd>
|
|
16 |
<a href="http://www.w3.org/1999/06/REC-xml-stylesheet-19990629">http://www.w3.org/1999/06/REC-xml-stylesheet-19990629</a>
|
|
17 |
<br>
|
|
18 |
</dd>
|
|
19 |
<dt>Latest version:</dt>
|
|
20 |
<dd>
|
|
21 |
<a href="http://www.w3.org/TR/xml-stylesheet">http://www.w3.org/TR/xml-stylesheet</a>
|
|
22 |
<br>
|
|
23 |
</dd>
|
|
24 |
<dt>Previous version:</dt>
|
|
25 |
<dd>
|
|
26 |
<a href="http://www.w3.org/TR/1999/xml-stylesheet-19990428">http://www.w3.org/TR/1999/xml-stylesheet-19990428</a>
|
|
27 |
<br>
|
|
28 |
</dd>
|
|
29 |
<dt>Editor:</dt>
|
|
30 |
<dd>
|
|
31 |
|
|
32 |
James Clark
|
|
33 |
<a href="mailto:jjc@jclark.com"><jjc@jclark.com></a>
|
|
34 |
<br>
|
|
35 |
</dd>
|
|
36 |
</dl>
|
|
37 |
<p class="copyright">
|
|
38 |
<a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#Copyright">
|
|
39 |
Copyright</a> © 1999 <a href="http://www.w3.org">W3C</a>
|
|
40 |
(<a href="http://www.lcs.mit.edu">MIT</a>,
|
|
41 |
<a href="http://www.inria.fr/">INRIA</a>,
|
|
42 |
<a href="http://www.keio.ac.jp/">Keio</a> ), All Rights Reserved. W3C
|
|
43 |
<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>,
|
|
44 |
<a href="http://www.w3.org/Consortium/Legal/copyright-documents.html">document use </a>and
|
|
45 |
<a href="http://www.w3.org/Consortium/Legal/copyright-software.html">software licensing </a>rules apply.
|
|
46 |
</p>
|
|
47 |
<hr title="Separator for header">
|
|
48 |
</div>
|
|
49 |
<h2>
|
|
50 |
<a name="abstract">Abstract</a>
|
|
51 |
</h2>
|
|
52 |
|
|
53 |
<p>This document allows a style sheet to be associated with an XML
|
|
54 |
document by including one or more processing instructions with a
|
|
55 |
target of <code>xml-stylesheet</code> in the document's prolog.</p>
|
|
56 |
|
|
57 |
<h2>
|
|
58 |
<a name="status">Status of this document</a>
|
|
59 |
</h2>
|
|
60 |
|
|
61 |
<p>This document has been reviewed by W3C Members and other interested
|
|
62 |
parties and has been endorsed by the Director as a W3C <a href="http://www.w3.org/Consortium/Process/#RecsW3C">Recommendation</a>. It
|
|
63 |
is a stable document and may be used as reference material or cited as
|
|
64 |
a normative reference from other documents. W3C's role in making the
|
|
65 |
Recommendation is to draw attention to the specification and to
|
|
66 |
promote its widespread deployment. This enhances the functionality and
|
|
67 |
interoperability of the Web.</p>
|
|
68 |
|
|
69 |
<p>The list of known errors in this specifications is available at
|
|
70 |
<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>
|
|
71 |
|
|
72 |
<p>Comments on this specification may be sent to <<a href="mailto:www-xml-stylesheet-comments@w3.org">www-xml-stylesheet-comments@w3.org</a>>. The archive of public
|
|
73 |
comments 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>
|
|
74 |
|
|
75 |
<p>A list of current W3C Recommendations and other technical documents
|
|
76 |
can be found at <a href="http://www.w3.org/TR">http://www.w3.org/TR</a>.</p>
|
|
77 |
|
|
78 |
<p>The Working Group expects additional mechanisms for linking style
|
|
79 |
sheets to XML document to be defined in a future specification.</p>
|
|
80 |
|
|
81 |
<p>The use of XML processing instructions in this specification should
|
|
82 |
not be taken as a precedent. The W3C does not anticipate recommending
|
|
83 |
the use of processing instructions in any future specification. The
|
|
84 |
<a href="#rationale">Rationale</a> explains why they were used in
|
|
85 |
this specification.</p>
|
|
86 |
|
|
87 |
<p>This document was produced as part of the <a href="http://www.w3.org/XML/Activity">W3C XML Activity</a>.</p>
|
|
88 |
|
|
89 |
|
|
90 |
<h2>
|
|
91 |
<a name="contents">Table of contents</a>
|
|
92 |
</h2>1 <a href="#The xml-stylesheet processing instruction">The xml-stylesheet processing instruction</a>
|
|
93 |
<br>
|
|
94 |
<h3>Appendices</h3>A <a href="#References">References</a>
|
|
95 |
<br>B <a href="#rationale">Rationale</a>
|
|
96 |
<br>
|
|
97 |
<hr>
|
|
98 |
|
|
99 |
<h2>
|
|
100 |
<a name="The xml-stylesheet processing instruction"></a>1 The <code>xml-stylesheet</code> processing instruction</h2>
|
|
101 |
|
|
102 |
<p>Style Sheets can be associated with an XML<a href="#XML">[XML10]</a>
|
|
103 |
document by using a processing instruction whose target is
|
|
104 |
<code>xml-stylesheet</code>. This processing instruction follows the
|
|
105 |
behaviour of the HTML 4.0 <code><LINK
|
|
106 |
REL="stylesheet"></code><a href="#HTML">[HTML40]</a>.</p>
|
|
107 |
|
|
108 |
<p>The <code>xml-stylesheet</code> processing instruction is parsed in
|
|
109 |
the same way as a start-tag, with the exception that entities other
|
|
110 |
than predefined entities must not be referenced.</p>
|
|
111 |
|
|
112 |
<p>The following grammar is given using the same notation as the
|
|
113 |
grammar in the XML Recommendation<a href="#XML">[XML10]</a>. Symbols in the
|
|
114 |
grammar that are not defined here are defined in the XML
|
|
115 |
Recommendation.</p>
|
|
116 |
|
|
117 |
<h5>xml-stylesheet processing instruction</h5>
|
|
118 |
<table class="scrap">
|
|
119 |
<tbody>
|
|
120 |
<tr valign="baseline">
|
|
121 |
<td>
|
|
122 |
<a name="NT-StyleSheetPI"></a>[1] </td>
|
|
123 |
<td>StyleSheetPI</td>
|
|
124 |
<td> ::= </td>
|
|
125 |
<td>'<?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>? '?>'</td>
|
|
126 |
<td>
|
|
127 |
</td>
|
|
128 |
</tr>
|
|
129 |
<tr valign="baseline">
|
|
130 |
<td>
|
|
131 |
<a name="NT-PseudoAtt"></a>[2] </td>
|
|
132 |
<td>PseudoAtt</td>
|
|
133 |
<td> ::= </td>
|
|
134 |
<td>
|
|
135 |
<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>
|
|
136 |
</td>
|
|
137 |
<td>
|
|
138 |
</td>
|
|
139 |
</tr>
|
|
140 |
<tr valign="baseline">
|
|
141 |
<td>
|
|
142 |
<a name="NT-PseudoAttValue"></a>[3] </td>
|
|
143 |
<td>PseudoAttValue</td>
|
|
144 |
<td> ::= </td>
|
|
145 |
<td>('"' ([^"<&] | <a href="http://www.w3.org/TR/REC-xml#NT-CharRef">CharRef</a> | <a href="#NT-PredefEntityRef">PredefEntityRef</a>)* '"'</td>
|
|
146 |
<td>
|
|
147 |
</td>
|
|
148 |
</tr>
|
|
149 |
<tr valign="baseline">
|
|
150 |
<td>
|
|
151 |
</td>
|
|
152 |
<td>
|
|
153 |
</td>
|
|
154 |
<td>
|
|
155 |
</td>
|
|
156 |
<td>| "'" ([^'<&] | <a href="http://www.w3.org/TR/REC-xml#NT-CharRef">CharRef</a> | <a href="#NT-PredefEntityRef">PredefEntityRef</a>)* "'")</td>
|
|
157 |
<td>
|
|
158 |
</td>
|
|
159 |
</tr>
|
|
160 |
<tr valign="baseline">
|
|
161 |
<td>
|
|
162 |
</td>
|
|
163 |
<td>
|
|
164 |
</td>
|
|
165 |
<td>
|
|
166 |
</td>
|
|
167 |
<td>- (<a href="http://www.w3.org/TR/REC-xml#NT-Char">Char</a>* '?>' <a href="http://www.w3.org/TR/REC-xml#NT-Char">Char</a>*)</td>
|
|
168 |
<td>
|
|
169 |
</td>
|
|
170 |
</tr>
|
|
171 |
<tr valign="baseline">
|
|
172 |
<td>
|
|
173 |
<a name="NT-PredefEntityRef"></a>[4] </td>
|
|
174 |
<td>PredefEntityRef</td>
|
|
175 |
<td> ::= </td>
|
|
176 |
<td>'&amp;' | '&lt;' | '&gt;' | '&quot;' | '&apos;'</td>
|
|
177 |
<td>
|
|
178 |
</td>
|
|
179 |
</tr>
|
|
180 |
</tbody>
|
|
181 |
</table>
|
|
182 |
|
|
183 |
<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
|
|
184 |
same manner as in a normal XML attribute value. The actual value of
|
|
185 |
the pseudo-attribute is the value after each reference is replaced by
|
|
186 |
the character it references. This replacement is not performed
|
|
187 |
automatically by an XML processor.</p>
|
|
188 |
|
|
189 |
<p>The <code>xml-stylesheet</code> processing instruction is allowed
|
|
190 |
only in the prolog of an XML document. The syntax of XML constrains
|
|
191 |
where processing instructions are allowed in the prolog; the
|
|
192 |
<code>xml-stylesheet</code> processing instruction is allowed anywhere
|
|
193 |
in the prolog that meets these constraints.</p>
|
|
194 |
|
|
195 |
<blockquote>
|
|
196 |
<b>NOTE: </b>If the <code>xml-stylesheet</code> processing instruction
|
|
197 |
occurs in the external DTD subset or in a parameter entity, it is
|
|
198 |
possible that it may not be processed by a non-validating XML
|
|
199 |
processor (see <a href="#XML">[XML10]</a>).</blockquote>
|
|
200 |
|
|
201 |
<p>The following pseudo attributes are defined</p>
|
|
202 |
|
|
203 |
<pre>href CDATA #REQUIRED
|
|
204 |
type CDATA #REQUIRED
|
|
205 |
title CDATA #IMPLIED
|
|
206 |
media CDATA #IMPLIED
|
|
207 |
charset CDATA #IMPLIED
|
|
208 |
alternate (yes|no) "no"</pre>
|
|
209 |
|
|
210 |
<p>The semantics of the pseudo-attributes are exactly as with
|
|
211 |
<code><LINK REL="stylesheet"></code> in HTML 4.0, with the
|
|
212 |
exception of the <code>alternate</code> pseudo-attribute. If
|
|
213 |
<code>alternate="yes"</code> is specified, then the processing
|
|
214 |
instruction has the semantics of <code><LINK REL="alternate
|
|
215 |
stylesheet"></code> instead of <code><LINK
|
|
216 |
REL="stylesheet"></code>.</p>
|
|
217 |
|
|
218 |
<blockquote>
|
|
219 |
<b>NOTE: </b>Since the value of the <code>href</code> attribute is a URI
|
|
220 |
reference, it may be a relative URI and it may contain a fragment
|
|
221 |
identifier. In particular the URI reference may contain only a
|
|
222 |
fragment identifier. Such a URI reference is a reference to a part of
|
|
223 |
the document containing the <code>xml-stylesheet</code> processing
|
|
224 |
instruction (see <a href="#RFC2396">[RFC2396]</a>). The consequence is that the
|
|
225 |
<code>xml-stylesheet</code> processing instruction allows style sheets
|
|
226 |
to be embedded in the same document as the <code>xml-stylesheet</code>
|
|
227 |
processing instruction.</blockquote>
|
|
228 |
|
|
229 |
<p>In some cases, style sheets may be linked with an XML document by
|
|
230 |
means external to the document. For example, earlier versions of HTTP
|
|
231 |
<a href="#RFC2068">[RFC2068]</a> (section 19.6.2.4) allowed style sheets to be
|
|
232 |
associated with XML documents by means of the <code>Link</code>
|
|
233 |
header. Any links to style sheets that are specified externally to the
|
|
234 |
document are considered to occur before the links specified by the
|
|
235 |
<code>xml-stylesheet</code> processing instructions. This is the same
|
|
236 |
as in HTML 4.0 (see <a href="http://www.w3.org/TR/REC-html40/present/styles.html#h-14.6">section
|
|
237 |
14.6</a>).</p>
|
|
238 |
|
|
239 |
<p>Here are some examples from HTML 4.0 with the corresponding
|
|
240 |
processing instruction:</p>
|
|
241 |
|
|
242 |
<pre><LINK href="mystyle.css" rel="style sheet" type="text/css">
|
|
243 |
<?xml-stylesheet href="mystyle.css" type="text/css"?>
|
|
244 |
|
|
245 |
<LINK href="mystyle.css" title="Compact" rel="stylesheet"
|
|
246 |
type="text/css">
|
|
247 |
<?xml-stylesheet href="mystyle.css" title="Compact" type="text/css"?>
|
|
248 |
|
|
249 |
<LINK href="mystyle.css" title="Medium" rel="alternate stylesheet"
|
|
250 |
type="text/css">
|
|
251 |
<?xml-stylesheet alternate="yes" href="mystyle.css" title="Medium"
|
|
252 |
type="text/css"?></pre>
|
|
253 |
|
|
254 |
<p>Multiple <code>xml-stylesheet</code> processing instructions are
|
|
255 |
also allowed with exactly the same semantics as with <code>LINK
|
|
256 |
REL="stylesheet"</code>. For example,</p>
|
|
257 |
|
|
258 |
<pre><LINK rel="alternate stylesheet" title="compact" href="small-base.css"
|
|
259 |
type="text/css">
|
|
260 |
<LINK rel="alternate stylesheet" title="compact" href="small-extras.css"
|
|
261 |
type="text/css">
|
|
262 |
<LINK rel="alternate stylesheet" title="big print" href="bigprint.css"
|
|
263 |
type="text/css">
|
|
264 |
<LINK rel="stylesheet" href="common.css" type="text/css"></pre>
|
|
265 |
|
|
266 |
<p>would be equivalent to:</p>
|
|
267 |
|
|
268 |
<pre><?xml-stylesheet alternate="yes" title="compact" href="small-base.css"
|
|
269 |
type="text/css"?>
|
|
270 |
<?xml-stylesheet alternate="yes" title="compact" href="small-extras.css"
|
|
271 |
type="text/css"?>
|
|
272 |
<?xml-stylesheet alternate="yes" title="big print" href="bigprint.css"
|
|
273 |
type="text/css"?>
|
|
274 |
<?xml-stylesheet href="common.css" type="text/css"?></pre>
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
<hr title="Separator from footer">
|
|
279 |
|
|
280 |
<h2>
|
|
281 |
<a name="References"></a>A References</h2>
|
|
282 |
|
|
283 |
<dl>
|
|
284 |
|
|
285 |
<dt>
|
|
286 |
<a name="HTML">HTML40</a>
|
|
287 |
</dt>
|
|
288 |
<dd>World Wide Web
|
|
289 |
Consortium. <i>HTML 4.0 Specification.</i> W3C Recommendation. See
|
|
290 |
<a href="http://www.w3.org/TR/REC-html40">http://www.w3.org/TR/REC-html40</a>
|
|
291 |
</dd>
|
|
292 |
|
|
293 |
<dt>
|
|
294 |
<a name="RFC2068">RFC2068</a>
|
|
295 |
</dt>
|
|
296 |
<dd>R. Fielding, J. Gettys, J. Mogul,
|
|
297 |
H. Frystyk Nielsen, and T. Berners-Lee. <i>Hypertext Transfer
|
|
298 |
Protocol -- 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>
|
|
299 |
|
|
300 |
<dt>
|
|
301 |
<a name="RFC2396">RFC2396</a>
|
|
302 |
</dt>
|
|
303 |
<dd>T. Berners-Lee, R. Fielding, and
|
|
304 |
L. Masinter. <i>Uniform Resource Identifiers (URI): Generic
|
|
305 |
Syntax</i>. IETF RFC 2396. See <a href="http://www.ietf.org/rfc/rfc2396.txt">http://www.ietf.org/rfc/rfc2396.txt</a>.</dd>
|
|
306 |
|
|
307 |
<dt>
|
|
308 |
<a name="XML">XML10</a>
|
|
309 |
</dt>
|
|
310 |
<dd>World Wide Web Consortium. <i>Extensible
|
|
311 |
Markup 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>
|
|
312 |
</dd>
|
|
313 |
|
|
314 |
</dl>
|
|
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
<h2>
|
|
320 |
<a name="rationale"></a>B Rationale</h2>
|
|
321 |
|
|
322 |
<p>There was an urgent requirement for a specification for style sheet
|
|
323 |
linking that could be completed in time for the next release from
|
|
324 |
major browser vendors. Only by choosing a simple mechanism closely
|
|
325 |
based on a proven existing mechanism could the specification be
|
|
326 |
completed in time to meet this requirement.</p>
|
|
327 |
|
|
328 |
<p>Use of a processing instruction avoids polluting the main document
|
|
329 |
structure with application specific processing information.</p>
|
|
330 |
|
|
331 |
<p>The mechanism chosen for this version of the specification is not a
|
|
332 |
constraint on the additional mechanisms planned for future versions.
|
|
333 |
There is no expectation that these will use processing instructions;
|
|
334 |
indeed they may not include the linking information in the source
|
|
335 |
document.</p>
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
</body>
|
|
341 |
</html>
|