You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Pfleger Thomas,E2" <Th...@t-mobile.de> on 2003/01/07 15:05:00 UTC

Creating XML documents using SAX ?

Hello Xerces users/developers!

It is possible to create an XML document using calls to SAX (like startElement). This is illustrated in some samples I found in books.
After examining the documentation of Xerces, I found no means to set an output source for the document. Disappointig enough, this is also not covered in the samples I have seen so far.

I tried out the DOMWriter's writeNode and this works - however, "pretty printing" shows no line breaks. The 2003/12/20 build of Xerces does nicely but I'm not sure whether it would be compatible with Xalan 1.4.0.

I'm quite a newbee to Xerces and would be very glad to get some advice about serializing XML. I'd prefer SAX for it because exporting many data from a RDBMS would yield a big DOM memory footprint. Can one use SAX to programmatically create an XML doc in a file?

Thanks for any suggestions or tips,
Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Creating XML documents using SAX ?

Posted by Tinny Ng <tn...@ca.ibm.com>.
Thomas,

The sample SAXPrint writes the XML document to stdout using SAX.   It's
quite easy to modify from there and write to a file instead of stdout.   For
example, you can construct SAXPrintHandlers::fFormatter with
LocalFileFormatTarget instead of SAXPrintHandlers, e.g..

SAXPrintHandlers::SAXPrintHandlers( const   char* const
encodingName
                                    , const XMLFormatter::UnRepFlags
unRepFlags) :
{
    fTarget = new LocalFileFormatTarget(goutputfile);   // <== make sure you
delete fTarget in destructor
    fFormatter
    (
        encodingName
        , fTarget   // <==== use fTarget instead of "this" and thus there is
no need to derive SAXPrintHandlers from XMLFormatTarget
        , XMLFormatter::NoEscapes
        , unRepFlags
    )
:
:
}

Tinny

----- Original Message -----
From: "Pfleger Thomas,E2" <Th...@t-mobile.de>
To: <xe...@xml.apache.org>
Sent: Tuesday, January 07, 2003 9:05 AM
Subject: Creating XML documents using SAX ?


> Hello Xerces users/developers!
>
> It is possible to create an XML document using calls to SAX (like
startElement). This is illustrated in some samples I found in books.
> After examining the documentation of Xerces, I found no means to set an
output source for the document. Disappointig enough, this is also not
covered in the samples I have seen so far.
>
> I tried out the DOMWriter's writeNode and this works - however, "pretty
printing" shows no line breaks. The 2003/12/20 build of Xerces does nicely
but I'm not sure whether it would be compatible with Xalan 1.4.0.
>
> I'm quite a newbee to Xerces and would be very glad to get some advice
about serializing XML. I'd prefer SAX for it because exporting many data
from a RDBMS would yield a big DOM memory footprint. Can one use SAX to
programmatically create an XML doc in a file?
>
> Thanks for any suggestions or tips,
> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Creating XML documents using SAX ?

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	It is possible to do what you want. What you have then is an
implemented SAX application. SAX itself does not provide an "output
source" for use. Writing out a document is only 1 of a very large number
of possible uses. It is possible to use cout inside of the methods and
that will write to screen. If you want to do something more complicated
then you will have to write/find the supporting code.

hope this helps.

Gareth



On Tue, 7 Jan 2003, Pfleger Thomas,E2 wrote:

> Hello Xerces users/developers!
>
> It is possible to create an XML document using calls to SAX (like startElement). This is illustrated in some samples I found in books.
> After examining the documentation of Xerces, I found no means to set an output source for the document. Disappointig enough, this is also not covered in the samples I have seen so far.
>
> I tried out the DOMWriter's writeNode and this works - however, "pretty printing" shows no line breaks. The 2003/12/20 build of Xerces does nicely but I'm not sure whether it would be compatible with Xalan 1.4.0.
>
> I'm quite a newbee to Xerces and would be very glad to get some advice about serializing XML. I'd prefer SAX for it because exporting many data from a RDBMS would yield a big DOM memory footprint. Can one use SAX to programmatically create an XML doc in a file?
>
> Thanks for any suggestions or tips,
> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org