xmerl newlines
Erik Reitsma (ETM)
Erik.Reitsma@REDACTED
Wed Jun 18 09:27:46 CEST 2003
> There are many different requirements... (:
>
> I understand the problem as being that you've built a
> structure of tuples (or #xmlElement{}) in Erlang and want
> them exported with some pretty-printing. Is that right?
I think that that was James' issue. My "problem" was, that a pretty-printed XML document is not parsed into the same data structure as a non-pretty-printed. So:
<tagA><tagB>Some content</tagB></tagA>
is not parsed into the same structure as
<tagA>
<tagB>Some content</tagB>
</tagA>
using xmerl_scan:file/1
> I had implemented the {space,...} option wrongly in
> xmerl-0.15 and was set straight by those who use and
> understand XML. (: However, the option {space,normalize}
> _should_ do almost what you want. It will accumulate
> consecutive whitespace and replace it with one space. Close
> enough?
I did not know that this option existed. I had not read the source well enough.
This option makes it easier to pick out the parts of empty text and throw them out. Still, it would be easier if all xmlText records with empty text would be removed during parsing, especially if it has "siblings" that are xmlElement records. An option {space,remove} would be nice...
Now I have a function that walks through the #xmlElement{} tree and throws out what is the result of pretty printing, which works well enough for me to not start hacking xmerl myself :)
*Erik.
More information about the erlang-questions
mailing list