ANN: ezex 0.1--an xml shorthand in python; was: [XML-SIG] ANN: SLiP and SLIDE - a quick XML shorthand syntax and tool for editing

Uche Ogbuji uche.ogbuji@fourthought.com
Tue, 24 Dec 2002 05:07:52 -0700


> > Your post sounds interesting, and apparently a lot of work has gone into your 
> > ideas.  Some brief examples would be helpful as I'm trying to get a sense of 
> > your ideas quickly.
> 
> Uche and all:
> 
> I have since implemented a prototype of my xml shorthand ideas and created some
> illustrative examples.  You can find it all at http://www.sistema.it/ezex/
> 
> The name "ezex" tries to convey that it is an easy (ez) syntax for xml (ex).
> Suggestions for better names are very welcome.  As I mentioned before, the
> approach has some similarities with SOX (particularly in data mode) and with
> PYX (particularly in document mode).  
> 
> On the server:
> 
> ezex.0.1.alpha.py is the code.  
> 
> In the examples e1 through e4, the file without extension (e1) is the ezex
> source and the one with the .xml extension is the output produced with the
> prototype.  
> 
> The examples illustrate the following:
> 
> * e1 gives an example for using ezex in "data mode" where leading and trailing
>   whitespace does not matter and whitespace is extensively used for a layout
>   that optimizes readability.  (Data mode is selected by setting useIndent to
>   1).  The similarities to SOX are obvious, even if the syntax is slightly
>   different and SOX allows more "shortcuts"
> 
> * e2 gives an example for using ezex in "document mode" where whitespace
>   matters and mixed content is common.  While a little more cumbersome to write
>   than data mode, note that the author has complete control over whitespace.
>   This is very similar to PYX.  
> 
>   [Note:  a subset of ezex that avoids the use of multi-line {text, comments},
>   as well as elements with text content on the same line, can be as easily
>   analyzed with grep as can PYX.  It would be easy to implement this option in 
>   an xml to ezex converter.] 
> 
> * e3 is a very minimal example for the extensibility of ezex.  Here, a
>   simplistic custom parser for lists was implemented.  More complex examples
>   could include:
>   - tables
>   - nested lists
>   - structured text (reStructuredText, structuredTextNG, some wiki stuff)
>   - raw (for example for including xml syntax)
>   - include (to add and parse the content of an external file)
>   - csv (to parse a csv table into an xml table)
>   - e-mail (that parses e-mail format into xml)
>   - sh (that includes the result of some sh command such as ls)
> 
>   As the example suggests, it is quite straight forward to write simple custom
>   parsers or to incorporate existing parsers (structured text).  Since it is
>   basically a call to a python function, it is also easy to define "pipelines"
>   of processing.  For example, it should be easy to import a csv file and then
>   parse it to create an xml table representation. 
> 
> * e4 illustrates the syntax used in more detail giving examples for all options.  
> 
> * e5 illustrates the use of namespaces.  While ezex is not actually aware of
>   ns, it makes it quite straight forward to declare them and to use prefixed in
>   element and attribute names.  
> 
> I'm looking forward to your comments and suggestions!
> 
> kind regards
> 
> --bud
> 
> 
> 
> -------------------- simple example,  ezex input -------------------------------
> 
> ?xml version="1.0" encoding="UTF-8"
> !mydoctype "some elaborate stuff here"
> <root
>   # this is an exmaple of EZEX in data mode (useIndent=1)
>   <address
>        @type home
>      <street 123 Sesame Street
>      <city Wonderland
>      <state CA
>      <zipCode 90012
>      <comment
>          """
>          Please leave packages with Grouch
>          in garbage can next door."""
> 
> -------------------- simple example,  xml output  -------------------------------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!mydoctype "some elaborate stuff here">
> <root>
>     <!--this is an exmaple of EZEX in data mode (useIndent=1)-->
>     <address
>             type="home">
>         <street>123 Sesame Street</street>
>         <city>Wonderland</city>
>         <state>CA</state>
>         <zipCode>90012</zipCode>
>         <comment>
>             Please leave packages with Grouch
>             in garbage can next door.
>         </comment>
>     </address>
> </root>

I've come back to this post several times, but it has been hard to judge this 
format without really having had a need for such a shorthand myself.  I've 
been using Wiki markup lately, which has pretty much eliminated my need for 
editing XML directly, except for short examples in articles and such.

It does look promising, and perhaps a bit more natural to me than SLiP.  The 
"mydoctype" business is generating malformed XML, but I think that can easily 
be remedied.

One suggestion I do have is to see that the format is listed on PaulT's new 
page

http://www.pault.com/pault/pxml/xmlalternatives.html

I did mention ezex to him, but you might wish to follow up.


-- 
Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
A Python & XML Companion - http://www.xml.com/pub/a/2002/12/11/py-xml.html
XML class warfare - http://www.adtmag.com/article.asp?id=6965
MusicBrainz  metadata - http://www-106.ibm.com/developerworks/xml/library/x-thi
nk14.html