-
Notifications
You must be signed in to change notification settings - Fork 0
/
faq.xml
466 lines (428 loc) · 13.7 KB
/
faq.xml
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
454
455
456
457
458
459
460
461
462
463
464
465
466
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- This DOCTYPE is to make ID/IDREF work. -->
<!DOCTYPE article [
<!-- ELEMENT declarations work around MSXML bug. -->
<!ELEMENT qandaentry ANY>
<!ATTLIST qandaentry id ID #IMPLIED>
]>
<article class="faq">
<articleinfo>
<title>Frequently Asked Questions about RELAX NG</title>
<releaseinfo>$Revision: 1.7 $</releaseinfo>
</articleinfo>
<qandaset>
<qandaentry>
<question><para>How is "RELAX NG" pronounced?</para></question>
<answer><para>It's pronounced "relaxing".</para></answer>
</qandaentry>
<qandaentry>
<question><para>Why does RELAX NG use an XML syntax?</para></question>
<answer><para>
Seriously, is there any other choice?
</para><para>
If you don't want to write RELAX NG in XML syntax, there is <ulink href="http://thaiopensource.com/relaxng/nonxml/">a tool by James Clark</ulink> that allows you to write RELAX NG schema in non-XML syntax and that tool will convert it to XML syntax for you.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>Why is RELAX NG so verbose?</para></question>
<answer>
<para>
If you find it too verbose for hand writing, there are tools that let you write one in more concise syntax. Check out the tools section.
</para>
</answer>
<answer>
<para>
Compared to DTD syntax all XML based schema is more
verbose.
</para><para>
Comparing
</para>
<programlisting><![CDATA[<!ELEMENT foobar ( A, ( B | C )+, D) >]]></programlisting>
<para>
to its equivalent is always going to be more verbose.
As with everything the trade-offs bring advantages.
RELAX is much more expressive than DTD, and also
fixes the omissions and limitations in DTD. The price
is that you have to accept more syntax.
</para><para>
However, notice that well written and indented RELAX is
vastly more readable and significantly less verbose than
the equivalent W3C Schema offering.
</para><para>
Verbose tends to one of those subjective issues, but on
the whole we feel that RELAX offers a good balance and
is not excessive.
</para>
</answer>
<answer>
<para>
RELAX NG heavily uses elements for representing patterns.
This approach makes RELAX NG simple but verbose.
Feedback from schema authors is very welcome.
In addition to the standard syntax, there are some proposals
and implementations for more concise syntax (see the tools section).
</para>
<!-- I am wondering if <optionalAttribute> is a useful syntax sugar. -->
</answer>
</qandaentry>
<qandaentry>
<question><para>What about entity declarations? Why doesn't RELAX NG
allow me to declare entities? What do I do if I need to declare an
entity?</para></question>
</qandaentry>
<qandaentry>
<question><para>What about notation declarations? Why doesn't RELAX NG
allow me to declare notations? What do I do if I need to declare a
notation?</para></question>
</qandaentry>
<qandaentry>
<question><para>Why doesn't RELAX NG do type assignment? How can I
use RELAX NG if I want to do schema-based type
assignment?</para></question>
<answer><para>
Actually you can do the type assignment if you use a tool that supports it.
For example, Sun Multi-Schema XML Validator supports the type assignment.
</para></answer>
<answer><para>
Since RELAX NG allows ambiguous grammars, type-assignment is not always possible. And in some other cases, type-assignment is possible but needs multiple passes. That's one of the reasons why we don't have type-assignment in our core spec.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>How can I do data-binding with RELAX
NG?</para></question>
<answer><para>
There are not many, but there certainly exists tools for data-binding.
For one, you can use Relaxer. Check out the tools section for more.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>Why should I care about RELAX NG when I have
DTDs?</para></question>
</qandaentry>
<qandaentry>
<question><para>What about ID/IDREF? Why doesn't RELAX NG do ID/IDREF?
What do I do if I need ID/IDREF?</para></question>
</qandaentry>
<qandaentry>
<question><para>Why doesn't RELAX NG provide a feature like key,
keyRef in XML Schema? What do I do if I need this
functionality?</para></question>
</qandaentry>
<qandaentry>
<question><para>Why doesn't RELAX NG provide a
<literal>documentation</literal> element?</para></question>
<answer>
<para>
If you want to write documentation in RELAX NG schema, you can do it by simply using a namespace of your choice, like this:
</para>
<programlisting><![CDATA[
<element xmlns:doc="my:own:choice:of:namespace:URI">
<anyName/>
<doc:document>
Here is my documentation
</doc:document>
...
</element>
]]></programlisting>
<para>
RELAX NG allows you to write any elements and attributes to anywhere as long as it belongs to the namespace other than the RELAX NG namespace. So the above is completely legal.
</para><para>
Or another way to do this is to use elements of XHTML, DocBook, TEI or whatsoever.
In this way, you can format your documents quite nicely.
</para>
<programlisting><![CDATA[
<element xmlns:xhtml="http://www.w3.org/1999/xhtml">
<anyName/>
<xhtml:div>
<xhtml:h1>Overview of this element</xhtml:h1>
<xhtml:p>This element is used to do some craptacular thing</xhtml:p>
</xhtml:div>
...
</element>
]]></programlisting>
<para>
If you are looking for a plain simple text-only documentation, then you may want to use the documentation tag specified in the "RELAX NG DTD compatibility specification". No, you don't need to read the spec. Just use the <literal>documentation</literal> element in the
<literal>http://relaxng.org/ns/annotation/0.9</literal> namespace. For example,
</para>
<programlisting><![CDATA[
<element xmlns:a="http://relaxng.org/ns/annotation/0.9">
<anyName/>
<a:documentation>
This element is used to save the world from starvation.
</a:documentation>
...
</element>
]]></programlisting>
<para>
As I wrote earlier, you can write this element anywhere in the schema.
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>I read that RELAX NG is based on "regular tree
languages"? What's that all about? Does it have any practical
benefits?</para></question>
<answer>
<para>
As long as you are using RELAX NG, you don't need to know anything
about those geeky stuff. But yes, it does have several practical
benefits.
</para>
<orderedlist>
<listitem><para>
The validation algorithm becomes simple because this theory is
well-studied. This contributes to make validators smaller and faster.
</para></listitem>
<listitem><para>
It enables static analysis of schemas: is anything allowed by one schema
also allowed by another schema?
</para></listitem>
</orderedlist>
</answer>
</qandaentry>
<qandaentry>
<question><para>Why does RELAX NG base itself on grammars? Isn't a
constraint-based approach like Schematron more
powerful?</para></question>
<answer>
<para>
One answer to this question is, the grammar-based approach is well-studied by scientists and (therefore) the validation is relatively fast.
</para>
<para>
Also, there will be tools available which let you combine RELAX NG and Schematron. Check out the tools section.
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>What about the XML Schema
<literal>processContents="strict|lax|skip"</literal> feature? How can
I do this in RELAX NG?</para></question>
<answer>
<para>
There is no special primitive for the wild card in RELAX NG, but you
can use the "name class" to achieve the same effect.
</para><para>
Generally, "skip" is easy to mimic, but "strict" and "lax" are hard.
For example, the following pattern corresponds with:
</para>
<programlisting><![CDATA[<any processContents="skip" namespace="##other"/>]]></programlisting>
<programlisting><![CDATA[
<define name="wildcard.skipOther">
<element>
<anyName>
<except><nsName/></except>
</anyName>
<zeroOrMore>
<choice>
<text/>
<attribute><anyName/></attribute>
<ref name="wildcard.skipOther"/>
</choice>
</zeroOrMore>
</element>
</define>
]]></programlisting>
</answer>
</qandaentry>
<qandaentry>
<question><para>What about exclusions (as in SGML)? Why doesn't RELAX
NG support exclusions? What do I do if I need this
functionality?</para></question>
</qandaentry>
<qandaentry>
<question><para>Why doesn't RELAX NG support minOccurs/maxOccurs as
XML Schema?</para></question>
<answer>
<para>
If you really want to use minOccurs/maxOccurs, you can use
a tool like
<ulink href="http://www.geocities.com/kohsukekawaguchi/relaxng/shorthand/ShortRNG.html"
>this</ulink>, which recognizes
minOccurs/maxOccurs and expand it to the normal RELAX NG syntax.
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>(Something about namespaces. Why does RELAX NG take
the approach that it does? How does RELAX Namespace fit in? Compare
with W3C Schema approach.)</para></question>
</qandaentry>
<qandaentry>
<question><para>(Something about attribute/element content
models.)</para></question>
</qandaentry>
<qandaentry>
<question><para>I read that, unlike DTDs and XML Schema, RELAX NG does
not prohibit ambiguous content models? Does this have any practical
benefit?</para></question>
</qandaentry>
<qandaentry>
<question><para>What's the use of the <literal>interleave</literal>
element in RELAX NG?</para></question>
<answer>
<para>
One of the frequent use would be to implement an unordered content model
( XML Schema's <all> particle.)
</para><para>
Another nice technique is to implement a "set" of tokens.
</para>
<programlisting><![CDATA[
<list>
<interleave>
<optional>
<value>abc</value>
</optional><optional>
<value>def</value>
</optional><optional>
<value>ghi</value>
</optional>
</interleave>
</list>
]]></programlisting>
</answer>
</qandaentry>
<qandaentry>
<question><para>What's the use of the <literal>parentRef</literal>
element in RELAX NG? What's the use of nested
grammars?</para></question>
</qandaentry>
<qandaentry>
<question><para>What's the use of the <literal>combine</literal> attribute in RELAX
NG?</para></question>
<answer>
<para>
Practically, <literal>combine="choice"</literal> and
<literal>combine="interleave"</literal> serve two
completely different purposes.
</para>
<itemizedlist>
<listitem>
<para>
One of the use case of <literal>combine="choice"</literal> is
to create an implicit "class" of elements.
</para>
<programlisting><![CDATA[
<define name="inline.class" combine="choice">
<element name="b"> ... </element>
</define>
<define name="inline.class" combine="choice">
<element name="i"> ... </element>
</define>
]]></programlisting>
<para>
In this way, each element can collaboratively form a class of elements,
without any central control. This is useful when writing a modularized schema.
</para>
</listitem><listitem>
<para>
Another common use of <literal>combine="choice"</literal> is
to extend an already defined "class" of elements.
</para>
<programlisting><![CDATA[
<define name="list.class">
<choice>
<ref name="dl"/>
<ref name="ul"/>
<ref name="ol"/>
</choice>
</define>
<define name="list.class" combine="choice">
<ref name="xl"/>
</define>
]]></programlisting>
</listitem>
</itemizedlist>
</answer>
</qandaentry>
<qandaentry>
<question><para>
What's the difference between the <literal>empty</literal> pattern and
the <literal>notAllowed</literal> pattern?
</para></question>
</qandaentry>
<qandaentry>
<question><para>
Why do I need RELAX NG, when W3C XML Schema is there?
</para></question>
<answer>
<para>
Consider why most people prefer to drive cars, even though
they could all be buying Hummers instead, after all Hummers
are now available.
</para><para>
A cursory inspection of the requirements specification for
W3C Schema gives a good sense of how RELAX is designed
to fulfil a clear mission that is concise and descrete.
</para><para>
By limiting the scope to structure definitions, RELAX avoids
the drawbacks of W3C Schema, giving a much more
elegant and predictable toolset.
</para><para>
A further issue with W3C Schema is implementation
consistency. With a large and complex specification
behaviour of the software implementations is an impediment
to consistent deployment. Something you program into
your schema may not behave as you intended on certain
of your customer environments and vice versa.
</para><para>
A simpler specification reduces the risks and gives a
more reliable business deployment.
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>
Why doesn't RELAX NG modify the infoset?
</para></question>
</qandaentry>
<qandaentry>
<question><para>
I want to specify the default attribute value. How can I do that?
</para></question>
</qandaentry>
<qandaentry>
<question><para>
How can I express the concept of the inheritance?
</para></question>
<answer>
<para>
Here is a
<ulink href="http://www.asahi-net.or.jp/~eb2m-mrt/oo.html">
proposal by MURATA Makoto</ulink>
for capturing inheritance in RELAX NG.
</para>
</answer>
<answer>
<para>
One way to do this is to invent a new syntax of RELAX NG that has
OO-fravor, and make it convertible to normal RELAX NG.
In fact, there are tools that do this.
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>
How/where can I learn more about RELAX NG?
</para></question>
</qandaentry>
<qandaentry>
<question><para>
What kind of tools are available now?
</para></question>
</qandaentry>
<qandaentry>
<question><para>
What is the relationship between RELAX/TREX and RELAX NG
</para></question>
<answer><para>
In short, RELAX (to be precise, RELAX Core) and TREX are parents of RELAX NG.
</para></answer>
</qandaentry>
<!-- template
<qandaentry>
<question><para>
</para></question>
</qandaentry>
-->
</qandaset>
</article>