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: Laurent Bihanic <laurent.bihanic AT atosorigin.com>
  • To: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • Cc: XOM-interest <XOM-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Remarks on 1.0d8 API
  • Date: Wed, 15 Jan 2003 19:26:17 +0100

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

I'd prefer add/removeNamespaceDeclaration because it less imply that the actual namespace declaration will take place at this node in the serialized document. declareNamespace sounds like "I want the NS declaration to be place right here".

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?

When looked alone, the current implementation for add & remove looks fine,
i.e.:
- you can only add NSs that do not conflict with the namespaces of the element and its attributes
- attempts to add duplicate namespaces are ignored
- attempts to remove the namespace of the element or one of its attributes are ignored (side effect due to that the namespace list contains only the additional namespaces)

What bothers me more here is the behaviour of the methods getNamespaceDeclarationCount() and getNamespacePrefix(): they do not give access to the element and attributes namespaces.

Hence, you can easily reach the following situation:
1. call e.addNamespaceDeclaration() to redeclare the NS of an attribute: OK
2. call e.getNamespaceURI(prefix): OK, youy get the NS URI
3. call e.getNamespaceDeclarationCount and a loop to gather all prefixes: You won't find the namespace you've just declared.

That is not quite a "consistent" behaviour! I'd expect to be able to find any namespace I've successfully added.

Thus, it may be better if add/remove throw some exceptions for duplicate namespace declarations.

Laurent





Archive powered by MHonArc 2.6.24.

Top of Page