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: Johannes Döbler <jd AT aztecrider.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Base URIs
  • Date: Wed, 25 Sep 2002 16:04:23 +0200

4. By default most nodes created in memory will have null base URIs unless specifcally set otherwise. What happens when such a URI is appended to or inserted in a parent that has a base URI? Doe sit inherit the base URI of its parent or not?

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?

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?

The baseUri value should be inherited imho.
I would not use an own property to store the base uri value (with the exception of the Document class), but rather map getBaseUri, setBaseUri to the existence of xml:base attributes.
setBaseURI() makes only sense for Element and Document nodes.

Therefore:

Node
{
public String getBaseURI()
{
return getParent().getBaseURI();
}
}

Element
{
public String getBaseURI()
{
String uri = readAttribute("xml:base");
return uri != null ? uri : getParent().getBaseURI();
}

public void setBaseURI(String uri)
{
if (uri == null)
removeAttribute("xml:base");
else
addAttribute(new Attribute("xml:base", uri));
}
}

Document
{
public String getBaseURI()
{
return baseUri_;
}

public void setBaseURI(String uri)
{
baseUri_ = uri;
}

private String baseUri_;
}

regards,
Johannes





Archive powered by MHonArc 2.6.24.

Top of Page