Version française
Home     About     Download     Resources     Contact us    
Browse thread
Fast XML parser
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Till Varoquaux <till.varoquaux@g...>
Subject: Re: [Caml-list] Fast XML parser
OOps fogot to "reply to all". Here we go again:

On 7/19/07, Gabriel Kerneis <gabriel.kerneis@enst.fr> wrote:
>
> I certainly wouldn't recommend xml-light for *every* project where an
> XML parser is needed, but look at the OP's requirements :
> > > > I am interested in parsing Wiki markup language that has a few
> > > > tags, like <pre>...</pre>, <math>...,</math>.
> > > > These tags are sparse, meaning that the ratio of number of tags /
> > > > number of bytes is low.
> On such a simple case, xml-light (which is basically a simple ocamllex
> file + a few things to build the syntax tree) should perform quite
> well. I know it doesn't handle DTD, etc. but in *that* case, who cares ?
>
Xml-light would indeed provide a very simple parser and pretty good
speed. Whether to use it vs an event based parser is a matter of how
big these files really are (if they are not huge you shouldn't see a
real difference so you might as well keep it simple).

As for compliance, xml-light sort of does DTD. The issue is a lot more
subtle: it drops many features from the xml standard (including
encoding declaration) and thus will reject many valid xml documents.
This is, off course, not tolerable when you have to accepts documents
from sources other than your program... I wouldn't recommend xml-light
for any serious project reading xml files from the open. It can
however be great when you have control over the source generating your
documents (ie documents generated by xml-light itself).
> > Ultimately if you are parsing very simple files and are aiming for
> > pure speed you could write a simple lexer with ocamllex and use that
> > as base layer.
>
> That could be a solution, and (provided the licence you chose for your
> project is compatible) you could even use xml-light as an example to
> begin with (stripping things you don't need).

Indeed, and that should be real quick to do since the source code is
simple and easy to read. I should have mentioned it.

Cheers,
Til