Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] XOM 1.0 alpha 1 is here

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: "Bradley S. Huffman" <hip AT cs.okstate.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] XOM 1.0 alpha 1 is here
  • Date: Wed, 9 Jun 2004 20:09:41 -0400

This all behaves as designed. There aren't any bugs here. It's not perfect, but I didn't find any solution that was. The problem this example demonstrates is simply that the real base URI may not be exposed until after the xml:base attribute has been removed. Since xml:base attributes are treated as attributes rather than as some magical thing in XOM, they can change the base URI in unexpected ways.

This example fails to address the real point of base URIs, which is to resolve relative URIs. If there's no relative URI to resolve, then this is all pointless. What's really needed is a relative URI somewhere in the far attribute, and then thinking about what happens to it at various stages including the stage where the far element has no parent at all. That's really why I decided to keep the entity URI on detachment.

What I eventually decided was the least bad option was

1. Relative URIs in newly created elements should be resolved relative to the parent element's base URI, rather than simply beiung left dangling and unresolvable.

2. Such relative URIs should not change their base simply because the element is moved, detached, or copied.

3. However, such elements can change their base due to the addition of an xml:base attribute because this is precisely what adding an xml:base attribute is supposed to do.

It would be possible to get a slightly more logically consistent position by allowing the base URI of a newly created element to remain null when it's appended to another element that has a base URI; in other words requiring the base URI on new elements to always be explicitly set. However, that seemed to me to violate the principle of least surprise for the common use cases. It required an extra method call to get the behavior most people were going to want most of the time when elements were added to one document, detached from that document, and then added to another. (An uncommon sequence, I suspect.)

Anyway, that's the best I could come up with. I don't think I can do better without special casing the xml:base attribute, which would introduce problems of its own; especially with pre-XML Base specs like XPath and XSLT. :-(
--

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