[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

[ANN] new XML reader and writer

  • To: xml-dev@l...
  • Subject: [ANN] new XML reader and writer
  • From: Roger Flores <roger.flores@p...>
  • Date: Tue, 17 Feb 2004 23:16:33 -0800
  • User-agent: Mozilla Thunderbird 0.5 (Windows/20040207)

xml reader
I'm releasing two projects of mine, Ali and Alo.  They're at SourceForge.net

http://alo.sourceforge.net/
http://ali.sourceforge.net/

Alo is a concise way in ANSI C code to write data in XML format to a 
file.  I got tired of using fprintf.


Ali is an XML parser that reads structured XML data into C data 
structures in a way convenient for your ANSI C code. The result is that 
your code is smaller and easy to understand. Most other solutions like 
SAX and require many callback functions.

Suppose you want to input address book data like:

<person id="1000">
     <name>Roger Flores</name>
     <zipcode>94062</zipcode>
     <state>CA</state>
</person>


You could write C code using Ali like this:

/* The first function opens the xml document, reads it, and closes it. */
{
    rootN = ali_open(&doc, "person.xml", true, &data);

    if (doc.error == ALI_ERROR_NONE)
    {
       personN = ali_in(doc, rootN, "^e%f", 0, "person", parse_person);
       ali_close(&doc);
    }
}

/* The second function parses the person element. */
static void
parse_person(ali_doc_info *doc, ali_element_ref personN, void * data, 
bool new_element)
{
    my_person_struct * person = a_new_person(data);

    if (!doc->error) ali_in(doc, personN, "^a%d", 0, "id", &person->id);
    if (!doc->error) ali_in(doc, personN, "^e%s", 0, "name", &person->name);
    if (!doc->error) ali_in(doc, personN, "^e%u", 0, "zipcode", 
&person->zipcode);
    if (!doc->error) ali_in(doc, personN, "^e%s", 0, "state", 
&person->state);
}



Writing XML using Alo is basically the opposite, and about the same 
amount of work.

Both projects are small. Alo is about 4KB and Ali 7KB compiled.

I wrote them so an app of mine could load and save it's dat in XML/RDF 
and realized I should make them available to others.  Ali isn't a 
conforming XML processor 
(http://www.w3.org/TR/2004/REC-xml-20040204/#dt-xml-proc) because it's 
fairly incomplete compared to the XML spec.  Alo supports more XML 
notations than Ali because it's easier to code a writer than a reader. 
But they both cover my XML data needs.

Take a look and try them and let me know what you think.  They're both 
early in development.  There are no known bugs, but there are missing 
features!

-Roger Flores
mailto:roger.flores@p...


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.