Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Preserving base URIs on detachment

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: Re: [XOM-interest] Preserving base URIs on detachment
  • Date: Fri, 26 Mar 2004 17:28:24 -0500

At 3:10 PM -0500 3/26/04, jcowan AT reutershealth.com wrote:

I think it is too confusing to have one rule for Nodes built by Builder
and another for Nodes created directly by the application. One rule
should apply to all.

But that rule could be, "Nodes have the base URI of the document they come from, which is null for nodes that don't come from a document."

It would be good to add a clearBaseURI() method to remove the base URI.
I'm not sure what this does if the node has a parent.

It seems unnecessary. One can just call setBaseURI(null) if you really need to do this.

I'm not sure how I/O interacts with the base URI. Presumably, Builder
should set the base URI whenever an xml:base attribute is found.

No, the base URI is the one the document actually comes from. This is necessary, for example, to resolve relative base URIs encountered in xml:base attributes. The public getBaseURI() method takes account of xml:base attributes and ancestor elements. However, setBaseURI() merely sets the element's actual base URI. The two methods are *not* perfectly symmetric because an xml:base attribute, including one on ancestor element, can override the element's actual base URI.

Is the
attribute left in the attribute list or removed?

It's left in.

Likewise, when does
Serializer insert xml:base attributes?

When preserveBaseURI is true, or when there's an xml:base attribute in the element's attribute list.

Hmm, I am thinking that it probably makes sense that the result of calling getBaseURI() not change just because an element is detached. Therefore, it probably does make sense to set the base URI of all detached elements, whether they were initially created with a null URI or not. But should this be set to the base URI (that includes the result of xml:base) or just to the actual base URI? The base URI could no longer be in scope when the element is detached.

This is definitely one of the flakier areas of the XML spec. I don't think there's a clear one right answer. At some point I'll just have to pick one. But I am leaning toward retaining base URIs on detachment of all nodes; or at least I am at 5:26 on Friday. Ask me again in half an hour, you may get a different answer. :-)
--

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




Archive powered by MHonArc 2.6.24.

Top of Page