Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Namespace methods

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: jcowan AT reutershealth.com
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Namespace methods
  • Date: Thu, 5 Feb 2004 08:35:23 -0500

At 2:14 PM -0500 2/2/04, jcowan AT reutershealth.com wrote:

2) Consider flushing the no-namespace constructors: they save only 3 characters
(plus optional whitespace) over the corresponding namespace constructors.
Trying to let people use a namespaceless subset of XOM really doesn't save
much mental space, I don't think; DOM has these things because Level 1
predates namespaces.

The sentiment (including mine) is running against this. I'm keeping these.


2) Unify all namespace checking on a single routine, checkNamespace(String
prefix, String URI), to be called in place of checkNamespacePrefix,
checkNamespaceURI, and checkAddNamespaceDeclaration. In the first two
cases, the existing URI or prefix is passed. This allows applications
to enforce rules about prefix mapping. It also increases conceptual
compatibility with Attribute, which already has checkNamespace.


Checking the addition of a namespace declaration is potentially very different than checking the changing of a namespace for an element. checkAddNamespaceDeclaration will remain.

The reason Element and Attribute are asymmetrical here is that elements and attributes are not symmetrical. Because attributes are required to have prefixes to be in a namespace, the setNamespace method is different for the two. In Attribute, this means that you have to call setNamespace(prefix, URI) whereas for element you can call setNamespacePrefix(prefix) and setNamespaceURI(uri). Otherwise it would be possible to create an attribute in a namespace with no prefix, a very bad thing.(*) The check methods match the setter methods.

That said, I'm not sure they have to match. Element could fill in the prefix or URI as necessary from either setNamespacePrefix(prefix) or setNamespaceURI(uri) and then call checkNamespace(prefix, URI) or Attribute could call checkNamespacePrefix and checkNamespaceURI separately. Probably the latter makes more sense because otherwise the checks on prefix and namespace URI would each be made twice, once for the URI and once for the prefix. What do people think?
--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA

(*) In Element, calling setNamespacePrefix() before calling setNamespaceURI() throws an exception. However, the reverse order is allowed, because an element is still namespace well-formed if you call setNamespaceURI and then don't call setNamespacePrefix(). However, with attributes neither order could be allowed, because one without the other is always namespace malformed.




Archive powered by MHonArc 2.6.24.

Top of Page