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: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: "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 18:53:58 -0400

At 2:59 PM -0700 9/29/02, O'Brien-Strain, Eamonn wrote:

Similarly, the setAttribute method isn't checking attribute
names or values[...]

This is true for the attribute name. However it is OK to pass arbitrary characters in the attribute value: it will be encoded in the toXml() serializer.

The Text class also seems to be allowing anything, well-formed or not:
[...]

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.

XOM is fanatical about enforcing well-formedness. Sparta appears to
be ignoring that issue completely, and relying on the client
programmer to know, remember, and follow all the well-formedness
rules of XML.

Yes, Sparta does assume that certain preconditions are met and these should be documented in the JavaDoc. 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.
--

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo AT metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
| http://www.cafeconleche.org/books/xian2/ |
| http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+




Archive powered by MHonArc 2.6.24.

Top of Page