Skip to Content.
Sympa Menu

xom-interest - RE: [XOM-interest] Sparta: similar to XOM.

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "O'Brien-Strain, Eamonn" <eob AT exch.hpl.hp.com>
  • To: "'Elliotte Rusty Harold'" <elharo AT metalab.unc.edu>, "O'Brien-Strain, Eamonn" <eob AT exch.hpl.hp.com>
  • Cc: "'xom-interest AT lists.ibiblio.org'" <xom-interest AT lists.ibiblio.org>
  • Subject: RE: [XOM-interest] Sparta: similar to XOM.
  • Date: Sun, 29 Sep 2002 23:06:14 -0700


> -----Original Message-----
> From: Elliotte Rusty Harold [mailto:elharo AT metalab.unc.edu]
[...]
> >Just like attribute values, it is OK to pass in arbitrary text. The
> >toXml() serializer will either encode the text or enclose it in
> ><![CDATA[ ... ]]>
>
>
> No, there are characters which are legal in Java strings, but which
> are illegal in XML content. These include the C0 controls (which some
> developers do actually try to use), unmatched halves of surrogate
> pairs, and 0xFFFE and 0xFFFF.

I assumed the standard Java char<->byte Unicode encoding/decoding stuff would
handle most of this, but I admit I have not tested it. I will see if I can
add a test to the Sparta JUnit tests to demonstrate cases like this in which
adding character using the DOM API to the attribute values or text node
content will cause bad XML to be serialized to bytes.

> [...] Perhaps I should move some of
> >the checks from the parser to the DOM creation code -- which would
> >probably not increase the code size much. But then more of the DOM
> >methods would have to throw exceptions, which would be annoying.
> >Another approach is to "encode" bad tag and attribute names as
> >correct names -- but I am a bit dubious about that.
>
> That does sound dubious. I do think throwing an exception is correct.
> XOM uses runtime exceptions so there's not a huge impact on the code
> if you know your strings are correct in advance.

Perhaps, though I am a little bit suspicious of overuse of unchecked
exceptions. Despite some of the arguments against checked exceptions (like
the tendency of harried programmers to swallow them in their code rather than
propagating them or otherwise dealing with them) I still think the explicit
declarations make for safer code. However I do think that some of the
arguments that you and Bruce Eckel make are pretty valid, and perhaps I will
change my mind on this one.

__
Eamonn O'Brien-Strain
HP Labs
eob AT hpl.hp.com
http://sparta-xml.sourceforge.net/







Archive powered by MHonArc 2.6.24.

Top of Page