Richard Carlsson <>
Fri Aug 30 14:27:42 CEST 2002

On Fri, 30 Aug 2002, Vlad Dumitrescu wrote:

> I wrote that function just because I thought export wouldn't give me
> what I needed, but it is possible that I didn't dig deep enough into
> xmerl...
> can xmerl:export be used to return another XML structure too? The
> examples only return text representing the XML or HTML, so I might
> have been mislead into thinking that this is all xmerl:export can
> do...

As Ulf said, you can do some very simple on-the-fly transformations
during export by using #xml-redefine#, but basically, calling export
implies that you intend to move your data to a text representation. This
should generally mean that you have already done all the transformations
you want to do. The xml-redefine stuff is really only there for making
the implementation of export formats simpler, to let you say "to handle
this thing, just rewrite it to this other thing that we already know how
to handle". In any case, yes, the final output will always be text.

Rewriting the XML data is preferably done as one or more passes over the
xmerl tree before exporting to text form (as opposed to doing it while
parsing or exporting). This keeps your code cleaner. In general, trying
to cram a complicated transformation into one pass tends to make a big
buggy mess of your code. Don't be afraid to use several passes if it
helps you clean up the transformation conceptually.

When everything appears to be working, you can look at joining passes
into one for the sake of speed - but don't do this unless you are pretty
sure that you will not need to do any major changes to them later - in
that case, just leave them separated for your own sanity. ("Compiler
writers do it in multiple passes." :-)


Richard Carlsson ()   (This space intentionally left blank.)
E-mail: 	WWW: http://user.it.uu.se/~richardc/

More information about the erlang-questions mailing list