Sign In/My Account | View Cart  
advertisement

Article:
 RELAX NG's Compact Syntax
Subject: So what?
Date: 2002-06-21 09:46:58
From: Paul Strand

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?


No Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • natural male enhancement
    2010-09-09 03:14:26 isiahdodson6

    Thank you for give very good info. Your website is so coolI am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more. You, my friend, ROCK! I found just the information I already searched everywhere and just couldn’t find. What a perfect site. Like this website your website is one of my new favs.I like this info given and it has given me some sort of inspiration to succeed for some reason, so thanks


Sponsored By: