|
Boost Users : |
From: Boris Kolpackov (boris_at_[hidden])
Date: 2007-02-12 15:39:35
Hi Abir,
abir basak <abirbasak_at_[hidden]> writes:
> Now I am looking to use spirit for parsing an specific xml file ( w3c
> inkml file). So my intension is not to have a generic xml parser, rather
> than a specific xml parser (which also have some BNF grammar) . Anyone
> had used spirit for domain specific xml parsing?
Trust me you don't want to go this route. Parsing XML is a lot more
than finding opening and closing tags. To implement a conforming XML
parser you will need to handle namespaces, entity references, CDATA,
etc. This is a lot harder to get right than most people think.
The only time it makes sense to have a domain specific XML parser is
when you have control over all your XML instances and can make sure
that only a subset of XML 1.0 is used. This is normally done for
performance reasons.
> I believe using spirit will make it faster.
Highly unlikely since most of the XML parsers are hand-coded.
> Also I am interested to
> parse only a portion of the whole document at a time, and generate data
> from that portion only, rather generating data for whole DOM (The
> files are large, 4-20 MB typically)
> my xml file is something like,
>
> [...]
>
> note that inside <trace> the grammar is a BNF (comma sep float pairs
> mostly)
You can use a SAX2 parser (e.g., Expat or Xerces-C++) to handle XML and
then use Spirit-based parser to handle the data.
hth,
-boris
-- Boris Kolpackov Code Synthesis Tools CC http://www.codesynthesis.com Open-Source, Cross-Platform C++ XML Data Binding
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net