RE: createTextNode vs INVALID_CHARACTER_ERR

>I fear lots of serializers will just ignore this problem, producing
>non-well-formed XML.

That's a quality-of-implementation issue. Serializers have to examine every
character anyway, because some will need escaping (&, or characters not
directly supported in the target encoding). Adding a legal-character check
here is less expensive -- but admittedly less diagnostically useful -- than
doing so on the input side of the equation.

If you need a robust serializer, either demand robustness from the authors
of the one you're using or investigate others. If you know from first
principles that your DOM will contain only legal XML text, you may prefer
to sacrifice some robustness in exchange for greater performance. Which is
better is up to you; the DOM leaves you free to select either option.

When the DOM defines its own serializer API -- also coming in DOM Level 3
-- we'll have to make a decision on what we check when and how we report
anything we don't like.  That will _probably_ lean toward the robustness
side of the equation, since we're developing a basic utility. Of course
you'll still be able to use stand-alone serializers, so if you don't like
our choice of trade-offs you'll be able to pick another.



______________________________________
Joe Kesselman  / IBM Research

Received on Friday, 27 July 2001 09:15:21 UTC