|
I thought the whole point of defining something other than DTD's (Relax NG or Schema, for example) was to get away from the syntax of DTD's which is not as readily parseable.
If XML is described by XML, you only need one parser at your side. Unfortunately, W3C Schemas are so complicated that the advantage of learning only one syntax is offset by the inability to quickly read that syntax for meaning. My take on this was that Relax NG was the compromise. However, they just reinvented DTD's by deriving an XML syntax based off of the DTD syntax and then derived a completely new syntax from that.
If they were going to go to all that trouble, why didn't they just use "micro processing" to simplify the syntax of DTD's into something easily readible, yet XML parseable? For example (and forgive the gratuitous use of Polish notation), they could have done something like this:
<!ELEMENT DTD (ELEMENT+)>
<!ATTLIST DTD
root NMTOKEN #IMPLIED>
<!ELEMENT ELEMENT (ATTRIBUTE*)>
<!ATTLIST ELEMENT
name NMTOKEN #REQUIRED
sequence CDATA #IMPLIED
content (PCDATA | EMPTY | ANY) #IMPLIED>
<!ELEMENT ATTRIBUTE EMPTY>
<!ATTLIST ATTRIBUTE
name NMTOKEN #REQUIRED
type (CDATA | NMTOKEN | NMTOKENS | ID | IDREF | IDREFS) #IMPLIED
enumeration CDATA #IMPLIED
declaration (IMPLIED | REQUIRED | FIXED) #IMPLIED
default CDATA #IMPLIED>
...which defines a DTD-similar syntax, reusing "*", "?", "|", "+" and ",", from DTD's as operators. The above is the DTD which defines how that syntax would be used. Below is how it would be expressed in its own syntax:
<!DOCTYPE DTD SYSTEM "XMLDTD.dtd">
<DTD root="DTD">
<ELEMENT name="DTD" sequence="+ELEMENT">
<ATTRIBUTE name="root" type="NMTOKEN" declaration="IMPLIED"/>
</ELEMENT>
<ELEMENT name="ELEMENT" sequence="*ATTRIBUTE">
<ATTRIBUTE name="name" type="NMTOKEN" declaration="REQUIRED"/>
<ATTRIBUTE name="sequence" type="CDATA" declaration="IMPLIED"/>
<ATTRIBUTE name="content" enumeration="| PCDATA | EMPTY ANY" declaration="IMPLIED"/>
</ELEMENT>
<ELEMENT name="ATTRIBUTE" content="EMPTY">
<ATTRIBUTE name="name" type="NMTOKEN" declaration="REQUIRED"/>
<ATTRIBUTE name="type" enumeration="| CDATA | NMTOKEN | NMTOKENS | ID | IDREF IDREFS" declaration="IMPLIED"/>
<ATTRIBUTE name="enumeration" type="CDATA" declaration="IMPLIED"/>
<ATTRIBUTE name="declaration" enumeration="| IMPLIED | REQUIRED FIXED" declaration="IMPLIED"/>
<ATTRIBUTE name="default" type="CDATA" declaration="IMPLIED"/>
</ELEMENT>
</DTD>
(For those of you not familiar with Polish notation, the operator comes before the one or two operands. So, A + B in Polish notation becomes + A B. This removes the necessity for parenthesis and makes parsing in this case easier.)
So, what does this compact syntax gain me? Actually, why go with Relax NG at all if it is not a Recommendation and it suffers from the pitfalls of both DTD's and Schema?
|