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

Re: Create XML


sax create xml
[Rick Marshall]

> ok, i need to have something in real time, callable as a C library that
> works like a printf.
> ...
> for our large database applications i want to output Mbytes of xml in a
> stream as i'm processing records. this is a different problem.
>
> xml_start_document()
>
> puts out an xml header string "<?xml etc". possibly needs some
> arguments, but can get away without it for now.
>
> xml_start_tag(tag)
>
> puts out "<tag", checking for character errors. pushes tag context onto
> an internal stack.
> ... [more API stuff elided]

See, the thing is, you have two ways to go.  One is to do what you are
suggesting.  Only you are reinventing a SAX handler.  Why don't you just get
a SAX handler, and create the Sax events for it as you stream your data into
it?  No need to reinvent it (though your code would probably be lighter
weight, you wouldn't have to write it,and you could use any SAX handler)
SAX 1 would be simpler (I am assuming you do not need namespaces).

The other way to go is to figure out how, at each step, you would
automatically get well-formedness.  Well, maybe that is too much, but go as
far as possible in that direction.  You say you are getting data from a
database, so presumably that will be rows.  Then collect a row from the
file, and call

do_row(row).

do_row is supposed to make sure the row is well-formed.  Add its results to
your output.  This way you do not have to worry about missing an end call,
etc., and there are fewer calls to write in the handler.

If you have a simple nested structure, you could do something like

do_container(do_row(row))

Once again, you guarantee that everything is properly closed without having
to get a lot of details right every time you write a new handler for a new
type of data.  This may get too hard for an arbitrary and changable nested
document, but that is not what you have mentioned.

Cheers,

Tom 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.