[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: Re: RELAX NG FAQ
Answers from David and Murata-san were checked in to the repository. Also, the attached faq.html is the latest snapshot transformed into HTML. (We definitely need more fancy stylesheet.) regards, -- Kohsuke KAWAGUCHI +1 650 786 0721 Sun Microsystems kohsuke.kawaguchi@sun.comTitle: Frequently Asked Questions about RELAX NG
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. 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 verbose. Comparing <!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. 6 Why doesn't RELAX NG do type assignment? How can I use RELAX NG if I want to do schema-based type assignment? If you want to write documentation in RELAX NG schema, you can do it by simply using a namespace of your choice, like this: <element xmlns:doc="my:own:choice:of:namespace:URI"> <anyName/> <doc:document> Here is my documentation </doc:document> ... </element> 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. <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> 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, <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> 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 benefits? 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"/> <define name="wildcard.skipOther"> <element> <anyName> <except><nsName/></except> </anyName> <zeroOrMore> <choice> <text/> <attribute><anyName/></attribute> <ref name="wildcard.skipOther"/> </choice> </zeroOrMore> </element> </define> 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. 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. <list> <interleave> <optional> <value>abc</value> </optional><optional> <value>def</value> </optional><optional> <value>ghi</value> </optional> </interleave> </list> Practically, combine="choice" and combine="interleave" serve two completely different purposes.
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. Here is a proposal by MURATA Makoto for capturing inheritance in RELAX NG. |
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC