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: Tue, 21 Jan 2003 16:28:01 +0100

Elliotte Rusty Harold wrote:
At 7:26 PM +0100 1/15/03, Laurent Bihanic wrote:
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.


Actually, you can't reach that situation, or at least I don't think you can. Curretnly, you cannot redeclare the namespace of an attribute by calling e.addNamespaceDeclaration(). Did you mean something else?

Yes, you can. Here's an except (from XOM 1.0d8) of Element.declareNamespace():

// check for conflicts with attribute prefixes
if (!prefix.equals("")) {
for (int i = 0; i < attributes.size(); i++) {
Attribute a = attributes.get(i);
if (a.getNamespacePrefix().equals(prefix)) {
if (a.getNamespaceURI().equals(uri)) break;
else {
throw new NamespaceException(
"Attribute prefix conflicts with additional
namespace");
}
}
}
}

// local constraints
checkAddNamespaceDeclaration(prefix, uri);

namespaces.put(prefix, uri);
}

If the prefix and URI are the same as one of the attribute namespace, the break statement causes the namespace to be added.

But your right, the namespace is *really* added into the namespaces table so you can see it in a loop using getNamespaceDeclarationCount and getNamespacePrefix(int).

Here's another asymmetry: Redeclaration of attribute namespace is added to the table while redeclaration of the element namespace is not (uses a return; statement instead of a break;). Was this done on purpose? If yes, you should add a comment to document it.

So my example still applies if, in step 1, you try to redeclare the namespace of the element itself.

Laurent





Archive powered by MHonArc 2.6.24.

Top of Page