You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by David Hubbard <DH...@opentext.com> on 2008/06/16 22:34:55 UTC
pull parser
Hi All,
Does anyone know if xerces has a pull parser where I can write code in a
loop pulling out the parsed xml rather than the
Sax implementation?
Re: pull parser
Posted by Pete Cordell <pe...@codalogic.com>.
----- Original Message From: "David Hubbard" <>
> Does anyone know if xerces has a pull parser where I can write code in a
> loop pulling out the parsed xml rather than the Sax implementation?
Unless things have changed lately I think the answer to that is no. libxml2
does have an XML Pull parser. Libxml2 is open source, but is written in
pure C so I don't know whether that is an issue for you. If you are using
MS Windows then I think MS's XMLLite is pull parser based. (It seems to be
the way modern parsers are going.)
HTH,
Pete Cordell
Codalogic
For XML C++ data binding visit http://www.codalogic.com/lmx/
Re: pull parser
Posted by Tobias <ub...@gmx.net>.
it is closed source,
but if someone wants to implement pulling / pushing on top of xercesc,
these interfaces are one way to implement the event queue / serialization.
regards
tobias
----- Original Message -----
From: <Th...@emc.com>
To: <c-...@xerces.apache.org>
Sent: Wednesday, June 18, 2008 5:11 PM
Subject: RE: pull parser
Hello Tobias,
Would you mind posting some example source of each?
Thanks,
Nicholas
-----Original Message-----
From: Tobias [mailto:ubub@gmx.net]
Sent: Wednesday, June 18, 2008 1:03 AM
To: c-users@xerces.apache.org
Subject: Re: pull parser
I've implemented a pull parser on top of xercesc's internal XMLScanner
interface and
a corresponding push-based writer by using XMLFormatter.
It's quite simple to implement pulling by using an event queue,
getting the various read...-methods right was the laborious task.
regards
tobias
----- Original Message -----
From: "Boris Kolpackov" <bo...@codesynthesis.com>
To: <c-...@xerces.apache.org>
Sent: Tuesday, June 17, 2008 11:02 PM
Subject: Re: pull parser
> David Bertoni <db...@apache.org> writes:
>
>> You can try the "progressive" parsing APIs, which report SAX events
>> incrementally. See:
>>
>> SAX2XMLReader::parseFirst()
>> SAX2XMLReader::parseNext()
>>
>> However, there is no control over the granularity of the parsing, so
you
>> should test to make sure what it produces will work for you.
>
> Interesting. I didn't know about this API. Looking at the
documentation
> it says that each call to parseNext() covers just one XML token (as
> defined by the spec). Based on this it should be pretty straight-
> forward to implement a custom pull parser on top of SAX2XMLReader,
> e.g., something along these lines:
>
> - Have a queue of events.
> - When SAX handlers are called they add corresponding events to the
queue.
> - When the user calls next(), the parser check if the queue is empty.
> If it is the parser calls parseNext and the handlers add some
event(s)
> to the queue with the first one then returned to the user.
>
> Boris
>
> --
> Boris Kolpackov, Code Synthesis Tools
> http://codesynthesis.com/~boris/blog
> Open source XML data binding for C++:
> http://codesynthesis.com/products/xsd
> Mobile/embedded validating XML parsing:
> http://codesynthesis.com/products/xsde
RE: pull parser
Posted by Th...@emc.com.
Hello Tobias,
Would you mind posting some example source of each?
Thanks,
Nicholas
-----Original Message-----
From: Tobias [mailto:ubub@gmx.net]
Sent: Wednesday, June 18, 2008 1:03 AM
To: c-users@xerces.apache.org
Subject: Re: pull parser
I've implemented a pull parser on top of xercesc's internal XMLScanner
interface and
a corresponding push-based writer by using XMLFormatter.
It's quite simple to implement pulling by using an event queue,
getting the various read...-methods right was the laborious task.
regards
tobias
----- Original Message -----
From: "Boris Kolpackov" <bo...@codesynthesis.com>
To: <c-...@xerces.apache.org>
Sent: Tuesday, June 17, 2008 11:02 PM
Subject: Re: pull parser
> David Bertoni <db...@apache.org> writes:
>
>> You can try the "progressive" parsing APIs, which report SAX events
>> incrementally. See:
>>
>> SAX2XMLReader::parseFirst()
>> SAX2XMLReader::parseNext()
>>
>> However, there is no control over the granularity of the parsing, so
you
>> should test to make sure what it produces will work for you.
>
> Interesting. I didn't know about this API. Looking at the
documentation
> it says that each call to parseNext() covers just one XML token (as
> defined by the spec). Based on this it should be pretty straight-
> forward to implement a custom pull parser on top of SAX2XMLReader,
> e.g., something along these lines:
>
> - Have a queue of events.
> - When SAX handlers are called they add corresponding events to the
queue.
> - When the user calls next(), the parser check if the queue is empty.
> If it is the parser calls parseNext and the handlers add some
event(s)
> to the queue with the first one then returned to the user.
>
> Boris
>
> --
> Boris Kolpackov, Code Synthesis Tools
> http://codesynthesis.com/~boris/blog
> Open source XML data binding for C++:
> http://codesynthesis.com/products/xsd
> Mobile/embedded validating XML parsing:
> http://codesynthesis.com/products/xsde
Re: pull parser
Posted by Tobias <ub...@gmx.net>.
I've implemented a pull parser on top of xercesc's internal XMLScanner
interface and
a corresponding push-based writer by using XMLFormatter.
It's quite simple to implement pulling by using an event queue,
getting the various read...-methods right was the laborious task.
regards
tobias
----- Original Message -----
From: "Boris Kolpackov" <bo...@codesynthesis.com>
To: <c-...@xerces.apache.org>
Sent: Tuesday, June 17, 2008 11:02 PM
Subject: Re: pull parser
> David Bertoni <db...@apache.org> writes:
>
>> You can try the "progressive" parsing APIs, which report SAX events
>> incrementally. See:
>>
>> SAX2XMLReader::parseFirst()
>> SAX2XMLReader::parseNext()
>>
>> However, there is no control over the granularity of the parsing, so you
>> should test to make sure what it produces will work for you.
>
> Interesting. I didn't know about this API. Looking at the documentation
> it says that each call to parseNext() covers just one XML token (as
> defined by the spec). Based on this it should be pretty straight-
> forward to implement a custom pull parser on top of SAX2XMLReader,
> e.g., something along these lines:
>
> - Have a queue of events.
> - When SAX handlers are called they add corresponding events to the queue.
> - When the user calls next(), the parser check if the queue is empty.
> If it is the parser calls parseNext and the handlers add some event(s)
> to the queue with the first one then returned to the user.
>
> Boris
>
> --
> Boris Kolpackov, Code Synthesis Tools
> http://codesynthesis.com/~boris/blog
> Open source XML data binding for C++:
> http://codesynthesis.com/products/xsd
> Mobile/embedded validating XML parsing:
> http://codesynthesis.com/products/xsde
Re: pull parser
Posted by Boris Kolpackov <bo...@codesynthesis.com>.
David Bertoni <db...@apache.org> writes:
> You can try the "progressive" parsing APIs, which report SAX events
> incrementally. See:
>
> SAX2XMLReader::parseFirst()
> SAX2XMLReader::parseNext()
>
> However, there is no control over the granularity of the parsing, so you
> should test to make sure what it produces will work for you.
Interesting. I didn't know about this API. Looking at the documentation
it says that each call to parseNext() covers just one XML token (as
defined by the spec). Based on this it should be pretty straight-
forward to implement a custom pull parser on top of SAX2XMLReader,
e.g., something along these lines:
- Have a queue of events.
- When SAX handlers are called they add corresponding events to the queue.
- When the user calls next(), the parser check if the queue is empty.
If it is the parser calls parseNext and the handlers add some event(s)
to the queue with the first one then returned to the user.
Boris
--
Boris Kolpackov, Code Synthesis Tools http://codesynthesis.com/~boris/blog
Open source XML data binding for C++: http://codesynthesis.com/products/xsd
Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde
Re: pull parser
Posted by David Bertoni <db...@apache.org>.
David Hubbard wrote:
> Hi All,
>
> Does anyone know if xerces has a pull parser where I can write code in a
> loop pulling out the parsed xml rather than the Sax implementation?
You can try the "progressive" parsing APIs, which report SAX events
incrementally. See:
SAX2XMLReader::parseFirst()
SAX2XMLReader::parseNext()
However, there is no control over the granularity of the parsing, so you
should test to make sure what it produces will work for you. In
general, the granularity is what you would get for SAX parsing.
Dave