Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Remarks on 1.0d8 API

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: Laurent Bihanic <laurent.bihanic AT atosorigin.com>, XOM-interest <XOM-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Remarks on 1.0d8 API
  • Date: Wed, 15 Jan 2003 11:01:21 -0500

At 4:52 PM +0100 1/15/03, Laurent Bihanic wrote:
Hi,

I was looking at the XOM 1.0d8 API and found two things that may be worth changing:

- setData vs. getValue: Comment, Text and ProcessingInstruction all require to use setData to modify the node data and getValue to retrieve this same value. On the other hand, Attribute provides setValue and getValue. I think the API would be more intuitive if Comment, Text and ProcessingInstruction used setValue instead of setData.


I've thought that myself, though I hadn't noticed Comment and Text, only ProcessingInstruction. I chose getValue() because that has an XPath definition, and setData because that has an XML 1.0 definition. Every node has a value that can be gotten but not every node has a value that can be set. Thus the difference, but you're right. This is needlessly divergent. It would be nice to improve this. What do other people think?

- Likewise, many classes offer protected checkXxx methods (e.g. checkRoot, checkRemove, checkTarget, checkData) but Comment and Text only have check(). For consistency, it would be nice to rename them checkData (or checkValue), even if these classes only have one check method (but Document and Attributes are in the same case).

Sounds good. Any objections from anyone?

Also, one final asymmetry: Element has declareNamespace and removeNamespaceDeclaration. Should this be declareNamespace and undeclareNamespace? or addNamespaceDeclaration and removeNamesapceDeclaration?

The big concern for the declare and undeclare methods is what happens when you attempt to declare or undeclare the namespace of that element or one of its attributes? Should I throw an exception? no-op? Or should I allow namespace declarations in the list of additional namespaces which duplicate the namespaces of the element and its attributes, in case the URI or prefix of the element or attribute is later changed?
--

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo AT metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| Processing XML with Java (Addison-Wesley, 2002) |
| http://www.cafeconleche.org/books/xmljava |
| http://www.amazon.com/exec/obidos/ISBN%3D0201771861/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