Re: What is the URI of an element?

At 14:11 2001 06 29 +0200, Lars Marius Garshol wrote:
>The XML Base recommendation is very clear on how to interpret URIs
>appearing in attribute values, but I am not entirely certain what
>should be the URI of an element with an ID attribute.

There is no such thing as "the URI of an element."

I can think of two things you might mean:

1.  the [base URI] property of an element information item
    (using Infoset terminology), or

2.  an absolute URI reference with an XPointer fragment identifier
    that addresses the particular element instance.

I suspect you are referring to the second thing.

The first thing is affected by the XML Base Recommendation.

The second is not, nor is there a unique answer for the second thing.

>Let me give an example:
>
>  <!-- Document located at http://www.foo.no/ -->
>  <doc xml:base="http://www.foo.no/examples/"
>       xmlns:xlink="http://www.w3.org/1999/xlink">
>    <thing id="thing1"/>
>    <thingRef xlink:href="#thing1"/>
>  </doc>
>
>What is the URI of the <thing> element in this document? Is it
>
>  1) http://www.foo.no/examples/#thing1
>
>or
>
>  2) http://www.foo.no/#thing1

Most likely, neither.  You have not really given enough information
to address the resource.  Specifically, you have not said what the
name of the resource itself is.  Since http://www.foo.no/ ends in
a host name, that can't be the name of the resource.

If the resource were in fact accessible via http://www.foo.no/foo.xml,
then one absolute URI reference that would address the "thing" element
would be http://www.foo.no/foo.xml#thing1 (using the "bare name" form
of XPointer).


>I know what the [base uri] property of the element <thing> is, and
>that seems to imply that 1) is correct. This seems further supported
>by the fact that if 2) is correct, the <thingRef> will be broken,
>since it will point to an element that does not exist.

Your last statement above is incorrect.  Per RFC 2396, a relative URI
reference consisting only of the fragment identifier part is always
relative to the current resource.

>On the other hand, intelligent people are claiming that 2) is correct,
>and there is a certain logic to their arguments. It does seem difficult,
>however, to construct the URIs of elements from the XML Infoset if 2)
>is correct, if one is to take entities and so on into account.

The document infoitem's [base URI] property would give you an
absolute URI reference that would allow you to access the root
resource.  From there, you would have to traverse the various
[children] properties to reconstruct the equivalent of the
document tree down to the particular element in question.
That would allow you to construct an appropriate XPointer
(e.g., using the child sequence notation) to use as the
fragment identifier that, when combined with the root resource's
absolute URI reference, would be an absolute URI reference to
the desired element.

As far as entities, I note that XPointer uses XPath, and the
XPath data model assumes that all entities are expanded, so
there are no (non-character) entities remaining in this data model.

paul

Received on Friday, 29 June 2001 10:24:22 UTC