modeling language for xml

Discussion in 'XML' started by Joseph H Allen, Feb 7, 2005.

  1. I've discovered that the C preprocessor is powerful enough to create a cheap
    object modeling language for XML (or any structured data format). Check
    out http://world.std.com/~jhallen/sdu.html The library is not very
    complete, but I wanted to get something out there.

    A schema looks like this:

    STRUCT(root,
    STRING(title)
    INTEGER(size)
    LIST(items,item)
    )

    STRUCT(item,
    STRING(name)
    INTEGER(price)
    )

    This gets fed into two sets of C preprocessor macros. One drives the XML
    parser. The other converts the schema into C structures, so that after
    parsing you end up with a tree of these data structures:

    struct root
    {
    /* Standard header (base class) */
    struct root *next; /* Next in list */
    struct meta *_meta; /* Definition of this for parser/printer */

    /* User members */
    char *title;
    int size;
    struct item *items;
    };

    struct item
    {
    struct root *next;
    struct meta *_meta;

    char *name;
    int price;
    };

    It's nice because the modeling language names appear as first class member
    names in C.
    --
    /* (192.74.137.5) */ /* Joseph H. Allen */
    int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
    +r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
    ]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}
    Joseph H Allen, Feb 7, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moe
    Replies:
    1
    Views:
    2,281
    Tom Hawkins
    Oct 26, 2003
  2. Guest
    Replies:
    0
    Views:
    504
    Guest
    Jul 16, 2004
  3. tenxian
    Replies:
    2
    Views:
    423
    Arne Vajhøj
    Apr 8, 2008
  4. emekadavid

    xml modeling

    emekadavid, Apr 14, 2008, in forum: XML
    Replies:
    1
    Views:
    406
    Joseph J. Kesselman
    Apr 15, 2008
  5. Clifford Heath
    Replies:
    2
    Views:
    192
    Clifford Heath
    Feb 7, 2007
Loading...

Share This Page