1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Property Expression Parsing</title>
<link type="text/css" href="../../../page.css" rel="stylesheet">
</head>
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" text="#000000" bgcolor="#FFFFFF">
<div class="content">
<h1>Property Expression Parsing</h1>
<p>
<font size="-2">by Peter B. West</font>
</p>
<ul class="minitoc">
<li>
<a href="#N10014">Property expression parsing</a>
<ul class="minitoc">
<li>
<a href="#N10044">Data types</a>
</li>
<li>
<a href="#N10252">Tokenizer</a>
</li>
<li>
<a href="#N1029C">Parser</a>
</li>
</ul>
</li>
</ul>
<a name="N10014"></a>
<h3>Property expression parsing</h3>
<p>
The parsing of property value expressions is handled by two
closely related classes: <a href=
"javascript:window.top.displayCode(
'PropertyTokenizer.html#PropertyTokenizerClass' )" ><span
class= "codefrag" >org.apache.fop.fo.expr.PropertyTokenizer</span></a>
and its subclass, <a href= "javascript:window.top.displayCode(
'PropertyParser.html#PropertyParserClass' )" ><span
class= "codefrag" >org.apache.fop.fo.expr.PropertyParser</span></a>,
and by <span class= "codefrag" >refineParsing(int, FONode,
PropertyValue)</span> methods in the individual property
classes. <span class= "codefrag" >PropertyTokenizer</span>, as
the name suggests, handles the tokenizing of the expression,
handing <a href= "javascript:window.top.displayCode(
'PropertyTokenizer.html#EOF' )" ><em>tokens</em></a> back to
its subclass, <span
class= "codefrag" >PropertyParser</span>. <span
class= "codefrag" >PropertyParser</span>, in turn, returns a <a
href= "javascript:window.top.displayCode(
'PropertyValueList.html#PropertyValueListClass' )" ><span
class= "codefrag">PropertyValueList</span></a>, a list of <a
href= "javascript:window.top.displayCode(
'PropertyValue.html#PropertyValueInterface' )" ><span class=
"codefrag">PropertyValue</span></a>s.
</p>
<p>
The tokenizer and parser rely in turn on the datatype
definitions from the <span
class= "codefrag" >org.apache.fop.datatypes</span> package,
which include the <a href= "javascript:window.top.displayCode(
'PropertyValue.html#NO_TYPE' )" ><span class= "codefrag"
>PropertyValue</span> datatype constant definitions</a>.
</p>
<a name="N10044"></a>
<h4>Data types</h4>
<p>
The data types currently defined in
<span class= "codefrag" >org.apache.fop.datatypes</span> include:
</p>
<table class="ForrestTable" cellspacing="1" cellpadding="4">
<tr>
<th colspan="2" rowspan="1">Numbers and lengths</th>
</tr>
<tr>
<th colspan="1" rowspan="1">Numeric</th>
<td colspan="3" rowspan="1">
The fundamental length data type. <em>Numerics</em> of
various types are constructed by the classes listed
below.
</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<th colspan="3"
rowspan="1">Constructor classes for <em>Numeric</em></th>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1">Ems</td>
<td colspan="2" rowspan="1">Relative length in <em>ems</em></td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1">IntegerType</td>
<td colspan="1" rowspan="1"></td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1">Length</td>
<td colspan="2" rowspan="1">In centimetres(cm), millimetres(mm),
inches(in), points(pt), picas(pc) or pixels(px)</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1">Percentage</td>
<td colspan="1" rowspan="1"></td>
</tr>
<tr>
<th colspan="1" rowspan="1">Other Numeric</th>
<td colspan="3" rowspan="1">
Other numeric vaues which do not interact with the
lengths represented by <em>Numeric</em> values.
</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1">Angle</td>
<td colspan="2" rowspan="1">In degrees(deg), gradients(grad) or
radians(rad)</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1">Frequency</td>
<td colspan="2" rowspan="1">In hertz(Hz) or kilohertz(kHz)</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1">Time</td>
<td colspan="1" rowspan="1">In seconds(s) or milliseconds(ms)</td>
</tr>
<tr>
<th colspan="2" rowspan="1">Strings</th>
</tr>
<tr>
<th colspan="1" rowspan="1">StringType</th>
<td colspan="3" rowspan="1">
Base class for data types which result in a <em>String</em>.
</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<th colspan="1" rowspan="1">Literal</th>
<td colspan="2" rowspan="1">
A subclass of <em>StringType</em> for literals which
exceed the constraints of an <em>NCName</em>.
</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<th colspan="1" rowspan="1">MimeType</th>
<td colspan="2" rowspan="1">
A subclass of <em>StringType</em> for literals which
represent a mime type.
</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<th colspan="1" rowspan="1">UriType</th>
<td colspan="2" rowspan="1">
A subclass of <em>StringType</em> for literals which
represent a URI, as specified by the argument to
<em>url()</em>.
</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<th colspan="1" rowspan="1">NCName</th>
<td colspan="2" rowspan="1">
A subclass of <em>StringType</em> for literals which
meet the constraints of an <em>NCName</em>.
</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1"></td>
<th colspan="1" rowspan="1">Country</th>
<td colspan="1" rowspan="1">An RFC 3066/ISO 3166 country code.</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1"></td>
<th colspan="1" rowspan="1">Language</th>
<td colspan="1" rowspan="1">An RFC 3066/ISO 639 language code.</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1"></td>
<th colspan="1" rowspan="1">Script</th>
<td colspan="1" rowspan="1">An ISO 15924 script code.</td>
</tr>
<tr>
<th colspan="2" rowspan="1">Enumerated types</th>
</tr>
<tr>
<th colspan="1" rowspan="1">EnumType</th>
<td colspan="3" rowspan="1">
An integer representing one of the tokens in a set of
enumeration values.
</td>
</tr>
<tr>
<td colspan="1" rowspan="1"></td>
<th colspan="1" rowspan="1">MappedNumeric</th>
<td colspan="2" rowspan="1">
A subclass of <em>EnumType</em>. Maintains a
<em>Numeric</em> with the value to which the associated
"raw" enumeration token maps. E.g., the
<em>font-size</em> enumeration value "medium" maps to
the <em>Numeric</em> "12pt".
</td>
</tr>
<tr>
<th colspan="2" rowspan="1">Colors</th>
</tr>
<tr>
<th colspan="1" rowspan="1">ColorType</th>
<td colspan="3" rowspan="1">
Maintains a four-element array of float, derived from
the name of a standard colour, the name returned by a
call to <em>system-color()</em>, or an RGB
specification.
</td>
</tr>
<tr>
<th colspan="2" rowspan="1">Fonts</th>
</tr>
<tr>
<th colspan="1" rowspan="1">FontFamilySet</th>
<td colspan="3" rowspan="1">
Maintains an array of <em>String</em>s containing a
prioritized list of possibly generic font family names.
</td>
</tr>
<tr>
<th colspan="2" rowspan="1">Pseudo-types</th>
</tr>
<tr>
<td colspan="4" rowspan="1">
A variety of pseudo-types have been defined as
convenience types for frequently appearing enumeration
token values, or for other special purposes.
</td>
</tr>
<tr>
<th colspan="1" rowspan="1">Inherit</th>
<td colspan="3" rowspan="1">
For values of <em>inherit</em>.
</td>
</tr>
<tr>
<th colspan="1" rowspan="1">Auto</th>
<td colspan="3" rowspan="1">
For values of <em>auto</em>.
</td>
</tr>
<tr>
<th colspan="1" rowspan="1">None</th>
<td colspan="3" rowspan="1">
For values of <em>none</em>.
</td>
</tr>
<tr>
<th colspan="1" rowspan="1">Bool</th>
<td colspan="3" rowspan="1">
For values of <em>true/false</em>.
</td>
</tr>
<tr>
<th colspan="1" rowspan="1">FromNearestSpecified</th>
<td colspan="3" rowspan="1">
Created to ensure that, when associated with
a shorthand, the <em>from-nearest-specified-value()</em>
core function is the sole component of the expression.
</td>
</tr>
<tr>
<th colspan="1" rowspan="1">FromParent</th>
<td colspan="3" rowspan="1">
Created to ensure that, when associated with
a shorthand, the <em>from-parent()</em>
core function is the sole component of the expression.
</td>
</tr>
</table>
<a name="N10252"></a>
<h4>Tokenizer</h4>
<p>
As mentioned above, the <span class= "codefrag"
>PropertyTokenizer</span> hands <a href=
"javascript:window.top.displayCode( 'PropertyTokenizer.html#EOF'
)" ><em>tokens</em></a> back to its subclass, <span class=
"codefrag" >PropertyParser</span>. Most of these tokens are
self-explanatory, but a few need further comment.
</p>
<dl>
<dt>AUTO</dt>
<dd>
Because of its frequency of occurrence, and the fact that it
is always the <em>initial value</em> for any property which
supports it, AUTO has been promoted into a pseudo-type with
its on datatype class. Therefore, it is also reported as a
token.
</dd>
<dt>NONE</dt>
<dd>
Similarly to AUTO, NONE has been promoted to a pseudo-type
because of its frequency.
</dd>
<dt>BOOL</dt>
<dd>
There is a <em>de facto</em> boolean type buried in the
enumeration types for many of the properties. It had been
specified as a type in its own right in this code.
</dd>
<dt>MIMETYPE</dt>
<dd>
The property <span class= "codefrag" >content-type</span>
introduces this complication. It can have two values of the
form <strong>content-type:</strong><em>mime-type</em>
(e.g. <span class= "codefrag"
>content-type="content-type:xml/svg"</span>) or
<strong>namespace-prefix:</strong><em>prefix</em>
(e.g. <span class= "codefrag"
>content-type="namespace-prefix:svg"</span>). The
experimental code reduces these options to the payload in
each case: an <span class= "codefrag" >NCName</span> in the
case of a namespace prefix, and a MIMETYPE in the case of a
content-type specification. <span class= "codefrag"
>NCName</span>s cannot contain a "/".
</dd>
</dl>
<a name="N1029C"></a>
<h4>Parser</h4>
<p>
The parser returns a <a href= "javascript:window.top.displayCode(
'PropertyValueList.html#PropertyValueListClass' )" ><span
class= "codefrag" >PropertyValueList</span ></a>, necessary
because of the possibility that a list of <a href=
"javascript:window.top.displayCode(
'PropertyValue.html#PropertyValueInterface' )" ><span class=
"codefrag" >PropertyValue</span ></a> elements may be returned
from the expressions of some properties.
</p>
<p>
<span class= "codefrag" >PropertyValueList</span>s may contain
<span class= "codefrag" >PropertyValue</span>s or other <span
class= "codefrag" >PropertyValueList</span>s. This latter
provision is necessitated by some of the more peculiar
expression possibilities, <em>e.g.</em> <em>font</em> and
<em>text-shadow</em>. <em>text-shadow</em> may contain whitespace
separated sublists of either two or three elements, separated
from one another by commas. To accommodate this peculiarity,
comma separated elements are added to the top-level list,
while whitespace separated values are always collected into
sublists to be added to the top-level list.
</p>
<p>
Other special cases include the processing of the core
functions <span class= "codefrag" >from-parent()</span> and
<span class= "codefrag" >from-nearest-specified-value()</span>
when these function calls are assigned to a shorthand
property, or used with a shorthand property name as an
argument. In these cases, the function call must be the sole
component of the expression. The pseudo-element classes <span
class= "codefrag" >FromParent</span> and <span
class= "codefrag" >FromNearestSpecified</span> are generated in
these circumstances so that an exception will be thrown if
they are involved in expression evaluation with other
components. (See Rec. Section 5.10.4 Property Value
Functions.)
</p>
<p>
The experimental code is a simple extension of the existing
parser code, which itself borrowed heavily from James
Clark's XT processor.
</p>
</div>
<table summary="footer" cellspacing="0" cellpadding="0" width="100%" height="20" border="0">
<tr>
<td colspan="2" height="1" bgcolor="#4C6C8F"><img height="1"
width="1" alt="" src="../../../skin/images/spacer.gif"><a
href="../../../skin/images/label.gif"></a><a
href="../../../skin/images/page.gif"></a><a
href="../../../skin/images/chapter.gif"></a><a
href="../../../skin/images/chapter_open.gif"></a><a
href="../../../skin/images/current.gif"></a><a
href="../../..//favicon.ico"></a></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CFDCED" class="copyright"
align="center"><font size="2" face="Arial, Helvetica,
Sans-Serif">Copyright © 1999-2002 The Apache
Software Foundation. All rights reserved.<script
type="text/javascript" language="JavaScript"><!--
document.write(" - "+"Last Published: " +
document.lastModified); // --></script></font></td>
</tr>
<tr>
<td align="left" bgcolor="#CFDCED" class="logos"></td><td
align="right" bgcolor="#CFDCED" class="logos"></td>
</tr>
</table>
</body>
</html>
|