Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Base URIs

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 AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Base URIs
  • Date: Wed, 25 Sep 2002 17:06:00 +0200

Elliotte Rusty Harold wrote:
I am exploring the API for base URLs. My current thinking is that there will be two methods in the Node class with the following signatures:

public final String getBaseURI()
public final void setBaseURI(String uri)

setBaseURI() shall not be defined in Node but only in ParentNode.
What do you think getBaseURI() should return? If called on any node but Element and Document, it can only return the parent's base URI. On Element and Document shall it try to resolve absent or relative URIs using the parent's base URI? If yes, how does an application retrieve the actual base URI it has just set?
Maybe Node needs a resolveBaseURI() method, get/setBaseURI being only defined by ParentNode. Another possibility would be for getBaseURI() to do the resolution while readAttribute("xml:base") returns the actual local value.

2. Should I allow relative URIs or only absolute URIs?

Relative URIs, as these are allowed by the XML Base spec. and parsers do not resolve relative URIs into absolute ones. In addition, base URIs shall be stored as specified in the input document or by the application and the resolution into absolute URIs shall only occur upon request and depend on the parent base URI.

5. If nodes with null URIs do inherit their parent's base URI, what happens when the node is detached? Does it keep the parent's base URI?
What if it's later added to a different node with a different base URI?

As nodes do keep their Namespace when moved around, people will expect the same behaviour for base URIs.

> 6. How do I handle xml:base attributes? Should they be included in an
> element's list of attributes? Should the setBaseURI method check for
> conflicts with an xml:base attribute? What should it do if it notices
> one? Should extra xml:base attributes be automatically generated as
> necessary when the document is serialized?

Making xml:base available as attribute would ease porting existing applications to XOM. setBaseURI could simply set the xml:base attribute value. Only the xml:base attributes defined by the application should be outputted, the structure of the document defining their scope, as for namespaces.

7. What have I forgotten?

How will the Serializer deal with base URIs? It can't use getBaseURI() if this method resolves the URI using the parent's. It'll need direct acces to the actual string value (possibly null or relative).

Laurent





Archive powered by MHonArc 2.6.24.

Top of Page