xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] Element.addNamespaceDeclaration ?
- From: Elliotte Harold <elharo AT metalab.unc.edu>
- To: Wolfgang Hoschek <whoschek AT lbl.gov>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] Element.addNamespaceDeclaration ?
- Date: Sat, 12 Feb 2005 15:59:29 -0500
Wolfgang Hoschek wrote:
Element.addNamespaceDeclaration(...)
...
String currentBinding = getLocalNamespaceURI(prefix);
// if (currentBinding != null && !currentBinding.equals(uri)) {
if (currentBinding != null) {
if (currentBinding.equals(uri)) return; // WH: nothing do do ???
throw new NamespaceConflictException(
"Additional namespace " + uri
+ " conflicts with existing namespace binding."
);
}
if (namespaces == null) namespaces = new Namespaces();
namespaces.put(prefix, uri);
What am I missing?
There might be an issue if at a later point the attribute or element that provided the duplicate current binding had its namespace changed. In this case, the current approach would still retain the binding from the additional namespace declaration, but this variation would lose it.
That is, suppose we have this:
Element element = new Element("pre:element, "http://www.example.org");
element.addNamespaceDeclaration("pre", "http://www.example.org");
element.setNamespacePrefix("foo");
The current code would keep the namespace binding for pre in scope after this code executes. Your proposal would not. It's a very minor distinction.
--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
-
[XOM-interest] Element.addNamespaceDeclaration ?,
Wolfgang Hoschek, 02/12/2005
- Re: [XOM-interest] Element.addNamespaceDeclaration ?, Elliotte Harold, 02/12/2005
Archive powered by MHonArc 2.6.24.