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 Curtis Leach <cu...@mci.com> on 2003/12/12 19:38:18 UTC

Xerces 2.3.0 question for C++

I have a Java Program using Xerces & I need to convert the Xerces stuff into
C++ so that our C++ program can reuse the same code.

But I can't seem to get anything using the DefaultHandler class to work.
The XML document is passed to me via a CORBA call, so that it is already in
memory.  But the "Parser" class doesn't seem to work with the DefaultHandler
in this case.

I looked at the source code in your examples & it seems that DefaultHandler
only works with XML read in from a file.  Is this correct?  Is there a way
to do this without a file?  Or must I convert the program to use the more
limited HandlerBase class?  (I have gotten my own stub program to work with
this class)

The sample code I was using to kick of the parse was:

const char * xml = <the xml document>
SAX2XMLReader * parser = XMLReaderFactory::createXMLReader ();
parser->setContextHandler (this);
parser->parse (xml);

But none of the methods in the DefaultHandler class ever get called!
(startElement, characters, etc.)

Curtis



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


RE: Xerces 2.3.0 question for C++

Posted by Curtis Leach <cu...@mci.com>.
Hi Norm,

I was planing on using SAX instead of DOM since everything I read said that
DOM had significant overhead when compared to SAX.  And the requirement here
is speed above all else.  (And the Java code I'm implementing in C++ was
written using SAX as well.)

So I guess my real question is this.
Even though Java uses DefaultHandler for SAX, does the C++ version of this
library support using the DefaultHandler for SAX?

Curtis

-----Original Message-----
From: Norman Samuelson [mailto:nhs@llnl.gov]
Sent: Friday, December 12, 2003 1:35 PM
To: xerces-c-dev@xml.apache.org
Subject: Re: Xerces 2.3.0 question for C++


At 10:38 AM 12/12/2003, you wrote:
>I have a Java Program using Xerces & I need to convert the Xerces stuff
into
>C++ so that our C++ program can reuse the same code.
>
>But I can't seem to get anything using the DefaultHandler class to work.
>The XML document is passed to me via a CORBA call, so that it is already in
>memory.  But the "Parser" class doesn't seem to work with the
DefaultHandler
>in this case.
>
>I looked at the source code in your examples & it seems that DefaultHandler
>only works with XML read in from a file.  Is this correct?  Is there a way
>to do this without a file?  Or must I convert the program to use the more
>limited HandlerBase class?  (I have gotten my own stub program to work with
>this class)
>
>The sample code I was using to kick of the parse was:
>
>const char * xml = <the xml document>
>SAX2XMLReader * parser = XMLReaderFactory::createXMLReader ();
>parser->setContextHandler (this);
>parser->parse (xml);
>
>But none of the methods in the DefaultHandler class ever get called!
>(startElement, characters, etc.)
>
>Curtis

I am using Xerces-c in a way similar to what you are doing.  Here is the
code
I use, from the time I have read the incoming XML into a buffer  (a char*)
named inputFileStream with length inputStreamSize:


>    /* Initialize the parse module */
>    XMLPlatformUtils::Initialize();
>    XercesDOMParser *parser = new XercesDOMParser;
>    DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter() ;
>    /* create a MemBufInputSource to describe
>     * the buffer being passed to the parser */
>    MemBufInputSource* memBufIS = new MemBufInputSource (
>       (const XMLByte*)inputFileStream, inputStreamSize,
>       fileName, false) ;
>    parser->setErrorHandler(errReporter) ;
>    bool errorsOccured = false;
>
>    try {
>       parser->parse(*memBufIS);
>    }




- Norm -

Moderation in all things, including moderation.


---------------------------------------------------------------------
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: Xerces 2.3.0 question for C++

Posted by Curtis Leach <cu...@mci.com>.
As an FYI, it was the missing MemBufInputSource variable that was my
problem.  It seems the parse() method using const char * does something else
instead of converting it to a MemBufInputSource before using it.

So it looks like I'll be able to use the SAX2 code base after all.

Thanks for the hint.

Curtis

-----Original Message-----
From: Norman Samuelson [mailto:nhs@llnl.gov]
Sent: Friday, December 12, 2003 1:35 PM
To: xerces-c-dev@xml.apache.org
Subject: Re: Xerces 2.3.0 question for C++


At 10:38 AM 12/12/2003, you wrote:
>I have a Java Program using Xerces & I need to convert the Xerces stuff
into
>C++ so that our C++ program can reuse the same code.
>
>But I can't seem to get anything using the DefaultHandler class to work.
>The XML document is passed to me via a CORBA call, so that it is already in
>memory.  But the "Parser" class doesn't seem to work with the
DefaultHandler
>in this case.
>
>I looked at the source code in your examples & it seems that DefaultHandler
>only works with XML read in from a file.  Is this correct?  Is there a way
>to do this without a file?  Or must I convert the program to use the more
>limited HandlerBase class?  (I have gotten my own stub program to work with
>this class)
>
>The sample code I was using to kick of the parse was:
>
>const char * xml = <the xml document>
>SAX2XMLReader * parser = XMLReaderFactory::createXMLReader ();
>parser->setContextHandler (this);
>parser->parse (xml);
>
>But none of the methods in the DefaultHandler class ever get called!
>(startElement, characters, etc.)
>
>Curtis

I am using Xerces-c in a way similar to what you are doing.  Here is the
code
I use, from the time I have read the incoming XML into a buffer  (a char*)
named inputFileStream with length inputStreamSize:


>    /* Initialize the parse module */
>    XMLPlatformUtils::Initialize();
>    XercesDOMParser *parser = new XercesDOMParser;
>    DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter() ;
>    /* create a MemBufInputSource to describe
>     * the buffer being passed to the parser */
>    MemBufInputSource* memBufIS = new MemBufInputSource (
>       (const XMLByte*)inputFileStream, inputStreamSize,
>       fileName, false) ;
>    parser->setErrorHandler(errReporter) ;
>    bool errorsOccured = false;
>
>    try {
>       parser->parse(*memBufIS);
>    }




- Norm -

Moderation in all things, including moderation.


---------------------------------------------------------------------
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: Xerces 2.3.0 question for C++

Posted by Norman Samuelson <nh...@llnl.gov>.
At 10:38 AM 12/12/2003, you wrote:
>I have a Java Program using Xerces & I need to convert the Xerces stuff into
>C++ so that our C++ program can reuse the same code.
>
>But I can't seem to get anything using the DefaultHandler class to work.
>The XML document is passed to me via a CORBA call, so that it is already in
>memory.  But the "Parser" class doesn't seem to work with the DefaultHandler
>in this case.
>
>I looked at the source code in your examples & it seems that DefaultHandler
>only works with XML read in from a file.  Is this correct?  Is there a way
>to do this without a file?  Or must I convert the program to use the more
>limited HandlerBase class?  (I have gotten my own stub program to work with
>this class)
>
>The sample code I was using to kick of the parse was:
>
>const char * xml = <the xml document>
>SAX2XMLReader * parser = XMLReaderFactory::createXMLReader ();
>parser->setContextHandler (this);
>parser->parse (xml);
>
>But none of the methods in the DefaultHandler class ever get called!
>(startElement, characters, etc.)
>
>Curtis

I am using Xerces-c in a way similar to what you are doing.  Here is the code
I use, from the time I have read the incoming XML into a buffer  (a char*)
named inputFileStream with length inputStreamSize:


>    /* Initialize the parse module */
>    XMLPlatformUtils::Initialize();
>    XercesDOMParser *parser = new XercesDOMParser;
>    DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter() ;
>    /* create a MemBufInputSource to describe
>     * the buffer being passed to the parser */
>    MemBufInputSource* memBufIS = new MemBufInputSource (
>       (const XMLByte*)inputFileStream, inputStreamSize,
>       fileName, false) ;
>    parser->setErrorHandler(errReporter) ;
>    bool errorsOccured = false;
>
>    try {
>       parser->parse(*memBufIS);
>    }




- Norm -

Moderation in all things, including moderation.


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