[erlang-questions] xmerl still slow?

Willem de Jong w.a.de.jong@REDACTED
Thu Feb 1 13:01:07 CET 2007

On 1/31/07, Joel Reymont <joelr1@REDACTED> wrote:
> > On Jan 31, 2007, at 12:28 PM, Torbjorn Tornkvist wrote:
> > An alternative to xmerl may be: erlsom.
> What would be the advantage?

In this context: I am not sure. If I understand correctly, the point
of the template engine is to make it easy to create XML documents.
Erlsom can help you with that as well, but in a different way.

In general:
Erlsom and Xmerl do slightly different things. Which is best depends
on the context.

Erlsom checks the validity of an XML document against an XSD. Xmerl
cannot do that. However, Xmerl can check the validity against a DTD,
and Erlsom doesn't do that.

More importantly, the output of Erlsom (when parsing an XML document)
depends on the XSD. The output is in the form of records; the
definitions of these records correspond to the types that are defined
in the XSD. As a consequence, the output of Erlsom is a lot more
compact than the Xmerl output, and it is
easier to process (I think).

The opposite direction, from records to XML, is also supported. Again,
the records are a compact and convenient representation of the
information. Default values may be added to the record definitions
generated by erlsom to make things even easier (this is a bit like a
template, I think?).

Regarding speed: as far as I can make out, erlsom (doing validation
against a pre-compiled schema) is 3-4 times as fast as xmerl without
validation. I was a bit suprised by these results and I can't really
explain them. One reason may be the fact that the output is smaller.
I only did some performance comparisons for parsing, I didn't do any
tests for generation of XML.

> Also, can erlsom do this?
>     xmerl:export_simple([visit(Tree, Env)], xmerl_xml).

Not exactly, see above. Depending on what you are trying to do, Erlsom
may be just as good. However, if you have a big XML file where
everything has a standard value except for one or two elements deep
down in the tree structure, then the approach with the template may be
more convenient.

>        Thanks, Joel
> --
> http://wagerlabs.com/


More information about the erlang-questions mailing list