Skip to Content.
Sympa Menu

xom-interest - RE: [XOM-interest] A different question about xml:base

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Brendan.Johnston AT wellsfargo.com
  • To: xom-interest AT lists.ibiblio.org
  • Subject: RE: [XOM-interest] A different question about xml:base
  • Date: Wed, 14 Apr 2004 16:31:01 -0700

Elliotte,

In my code I started throwing exceptions ages ago.
Even on detached nodes.
If there is no clear action I would prefer a library to blowup in a big way.
If you are going to check the URI then check it, and die.
What would you do if the element was missing an end tag?

Brendan





-----Original Message-----
From: xom-interest-bounces AT lists.ibiblio.org
[mailto:xom-interest-bounces AT lists.ibiblio.org]On Behalf Of Elliotte
Rusty Harold
Sent: Wednesday, April 07, 2004 2:20 PM
To: Sandy Mustard
Cc: xom-interest
Subject: Re: [XOM-interest] A different question about xml:base


At 4:13 PM -0400 4/7/04, Sandy Mustard wrote:
>Forgive my ignorance of BaseURIs but is this possible?
>
><element xml:base="">abc</element>
>
>If so, then shouldn't getBaseURI() return "" and in the following case
>
><element>abc</element>
>
>getBaseURI() return NULL?
>

Good question! Let me look at the spec. Hmm, I don't see anything
squarely on point, but here's what I think:

1. xml:base="" is legal.

2. According to RFC 2396, "A URI reference that does not contain a
URI is a reference to the current document. In other words, an empty
URI reference within a document is interpreted as a reference to the
start of that document, and a reference containing only a fragment
identifier is a reference to the identified fragment of that
document. " So it seems that xml:base="" refers to the document's
base URI, *irrespective* of any other xml:base attributes or external
entities. In other words, like xmlns="" it resets the base URI within
the element. That almost makes sense except maybe in a 2396 context
the "current document" actually could mean the current entity in an
XML sense?

I suspect I need to write a unit test to make sure xml:base=""
overrides ancestor xml:base attributes. XOM probably doesn't get this
right yet. Yep, XOM didn't get that right. Fix is now in CVS.

3. According to the xml:base spec, the base URI for an element with
no xml:base attribute is "the base URI of the element's parent
element within the document or external entity, if one exists". So
for such an element the two cases are distinct. xml:base="" is not
the same as no xml:base attribute.

Does this mean they need to be distinguishable in code? Maybe, but I
don't think so. Suppose we have a relative URI in a document like
this one:

<html>
<body>
<a href="file.html">test</a>
</body>
</html>

Everybody agrees that the URI file.html is relative to the base URI
of this document. If this has not been explicitly set, then the only
representation we have of that base URI is the empty string. So it
makes sense that a.getBaseURI() return the empty string, not null. I
think returning the empty string still makes sense here, and it fits
in with the general principle (that XOM normally doesn't follow) of
never returning null if you can help it. And in your two examples:

<element xml:base="">abc</element>
<element>abc</element>

I think getBaseURI() should return the empty string for both of them.



--

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
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest




Archive powered by MHonArc 2.6.24.

Top of Page