Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

XML 1.0 Superset Makes XML Concise : Page 3

Because XML was not designed for data, it has serious ambiguities and constraints. These limitations are hard for many to understand because most articles never address them. ConciseXML, a superset of XML 1.0, aims to solve not only these limitations but also the verbosity of XML.


advertisement
ConciseXML and XML 1.0
XML was derived from SGML and contains constructs from a document-centric—not data-centric—world. The XML 1.0 syntax has no standard representation for objects with fields. Field key, data, and type information might be encoded in a dozen different ways in a dozen different standards. A substantial number of developers find XML 1.0 syntax verbose and cumbersome and avoid using it for these reasons. ConciseXML is efficient and readable without the use of special tools.

ConciseXML can be as concise as the comma separated value (CSV) format for data. When used for programming, ConciseXML is as concise as Java or C++ syntax.

ConciseXML has one consistent representation for encoding data: it uses attributes for fields. XML 1.0 specifies that attributes must be quoted strings, but ConciseXML allows the value of a field to be any object, not just a string. The key of a field can also be any object, not just a string. This simple extension significantly reduces the ambiguity of XML 1.0 documents and makes XML much more suited for representing data and logic.



ConciseXML is a superset of XML 1.0 and is both forward and backward compatible with XML 1.0. ConciseXML supports both the XML 1.0 form as well as a concise form. ConciseXML supports three syntactic extensions to XML 1.0 that reduce the verbosity of XML 1.0 (see Sidebar: ConciseXML Makes Eight Extensions to XML 1.0).

First, ConciseXML permits the closing tag name to be omitted. The closing tag name is redundant because a machine reading the XML can simply match opening tags with closing tags. Requiring the ending tag name encourages developers to choose short, abbreviated tag names. When calling a method in a normal programming language, you don't expect to type the method name twice:

XML 1.0: <textarea>hi</textarea> ConciseXML: <textarea>hi</>

An optional closing tag name is actually required for Water because of its dynamism. In some cases, the object of the call is calculated during runtime and therefore is not known when writing the code:

<set some_text="testing"/> <set text_input= <if> some_text.<more 30/> hypertext.TEXTAREA else hypertext.INPUT </if> /> <text_input 0=some_text/>

Second, ConciseXML supports by-position arguments. This means the attribute key can be omitted. When calling a method in a typical programming language, you do not expect to name the arguments in a call. This eliminates ambiguity because the definition of the method defines the exact ordering of arguments. In this respect, ConciseXML supports the calling convention of popular programming languages:

XML 1.0: <person first="Mike" last="Plusch"/> ConciseXML: <person "Mike" "Plusch"/>

Third, ConciseXML supports a dot notation for specifying a path. The dot notation is used in many languages including Java and JavaScript. Dot notation often makes the code more readable, and can significantly reduce the nesting of calls:

XML 1.0: <execute_path> "abe" <foo color="blue"/> bar </execute_path> ConciseXML: "abe".<foo color="blue"/>.bar

ConciseXML also eliminates the need for character entities and replaces them with a standard object reference. See the www.waterlanguage.org site for more details.

For every ConciseXML extension to XML 1.0, there is a corresponding representation in the XML 1.0 syntax. A single file can include both ConciseXML and XML 1.0 forms. Many different XML 1.0 representations for ConciseXML are possible, but ConciseXML uses a simple representation where attributes that have non-string keys or values are put within an attributes element. The following two examples create the same object:

XML 1.0: <list> <attributes><item name="bread"/><item name="milk"/></attributes> </list> ConciseXML: <list <item name="bread"/> <item name="milk"/> />



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap