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

BudP.Bruegger BudP.Bruegger
Tue, 29 Oct 2002 10:17:20 +0100


Hi Uche:

did you ever have a chance to look at the examples/code?  I realize that when I
released it you were over your head in discussion of other topics on the xml
SIG list...

best cheers
--bud



[*** Fasttrack ***:  look at the example at the end of the message]

On Thu, 05 Sep 2002 09:29:06 -0600
Uche Ogbuji <uche.ogbuji@fourthought.com> wrote:

[SNIP]
> 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>