1 How is "RELAX NG" pronounced?
It's pronounced "relaxing".
2 Why does RELAX NG use an XML syntax?
Seriously, is there any other choice?
If you don't want to write RELAX NG in XML syntax, there is a tool by James Clark that allows you to write RELAX NG schema in non-XML syntax and that tool will convert it to XML syntax for you.
3 Why is RELAX NG so verbose?
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.
Compared to DTD syntax all XML based schema is more
<!ELEMENT foobar ( A, ( B | C )+, D) >
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.
However, notice that well written and indented RELAX is
vastly more readable and significantly less verbose than
the equivalent W3C Schema offering.
Verbose tends to one of those subjective issues, but on
the whole we feel that RELAX offers a good balance and
is not excessive.
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).
4 What about entity declarations? Why doesn't RELAX NG
allow me to declare entities? What do I do if I need to declare an
5 What about notation declarations? Why doesn't RELAX NG
allow me to declare notations? What do I do if I need to declare a
6 Why doesn't RELAX NG do type assignment? How can I
use RELAX NG if I want to do schema-based type
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.
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.
7 How can I do data-binding with RELAX
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.
8 Why should I care about RELAX NG when I have
9 What about ID/IDREF? Why doesn't RELAX NG do ID/IDREF?
What do I do if I need ID/IDREF?
10 Why doesn't RELAX NG provide a feature like key,
keyRef in XML Schema? What do I do if I need this
11 Why doesn't RELAX NG provide a
If you want to write documentation in RELAX NG schema, you can do it by simply using a namespace of your choice, like this:
Here is my documentation
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.
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.
<xhtml:h1>Overview of this element</xhtml:h1>
<xhtml:p>This element is used to do some craptacular thing</xhtml:p>
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 documentation element in the
http://relaxng.org/ns/annotation/0.9 namespace. For example,
This element is used to save the world from starvation.
As I wrote earlier, you can write this element anywhere in the schema.
12 I read that RELAX NG is based on "regular tree
languages"? What's that all about? Does it have any practical
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
The validation algorithm becomes simple because this theory is
well-studied. This contributes to make validators smaller and faster.
It enables static analysis of schemas: is anything allowed by one schema
also allowed by another schema?
13 Why does RELAX NG base itself on grammars? Isn't a
constraint-based approach like Schematron more
One answer to this question is, the grammar-based approach is well-studied by scientists and (therefore) the validation is relatively fast.
Also, there will be tools available which let you combine RELAX NG and Schematron. Check out the tools section.
14 What about the XML Schema
processContents="strict|lax|skip" feature? How can
I do this in RELAX NG?
There is no special primitive for the wild card in RELAX NG, but you
can use the "name class" to achieve the same effect.
Generally, "skip" is easy to mimic, but "strict" and "lax" are hard.
For example, the following pattern corresponds with:
<any processContents="skip" namespace="##other"/>
15 What about exclusions (as in SGML)? Why doesn't RELAX
NG support exclusions? What do I do if I need this
16 Why doesn't RELAX NG support minOccurs/maxOccurs as
If you really want to use minOccurs/maxOccurs, you can use
a tool like
this, which recognizes
minOccurs/maxOccurs and expand it to the normal RELAX NG syntax.
17 (Something about namespaces. Why does RELAX NG take
the approach that it does? How does RELAX Namespace fit in? Compare
with W3C Schema approach.)
18 (Something about attribute/element content
19 I read that, unlike DTDs and XML Schema, RELAX NG does
not prohibit ambiguous content models? Does this have any practical
20 What's the use of the interleave
element in RELAX NG?
One of the frequent use would be to implement an unordered content model
( XML Schema's <all> particle.)
Another nice technique is to implement a "set" of tokens.
21 What's the use of the parentRef
element in RELAX NG? What's the use of nested
22 What's the use of the combine attribute in RELAX
Practically, combine="choice" and
combine="interleave" serve two
completely different purposes.
One of the use case of combine="choice" is
to create an implicit "class" of elements.
<define name="inline.class" combine="choice">
<element name="b"> ... </element>
<define name="inline.class" combine="choice">
<element name="i"> ... </element>
In this way, each element can collaboratively form a class of elements,
without any central control. This is useful when writing a modularized schema.
Another common use of combine="choice" is
to extend an already defined "class" of elements.
<define name="list.class" combine="choice">
What's the difference between the empty pattern and
the notAllowed pattern?
Why do I need RELAX NG, when W3C XML Schema is there?
Consider why most people prefer to drive cars, even though
they could all be buying Hummers instead, after all Hummers
are now available.
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.
By limiting the scope to structure definitions, RELAX avoids
the drawbacks of W3C Schema, giving a much more
elegant and predictable toolset.
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.
A simpler specification reduces the risks and gives a
more reliable business deployment.
Why doesn't RELAX NG modify the infoset?
I want to specify the default attribute value. How can I do that?
How can I express the concept of the inheritance?
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.
How/where can I learn more about RELAX NG?
What kind of tools are available now?
What is the relationship between RELAX/TREX and RELAX NG
In short, RELAX (to be precise, RELAX Core) and TREX are parents of RELAX NG.