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: "Bradley S. Huffman" <hip AT cs.okstate.edu>
  • To: Elliotte Harold - java FAQ <elharo AT metalab.unc.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] XOM 1.0 alpha 1 is here
  • Date: Wed, 09 Jun 2004 10:20:36 -0500

Elliotte Harold - java FAQ writes:

> Yes. That seemed to me to follow the priniciple of least surprise. If I
> load in an XHTML document, create some new elements inlcuding a elements,
> and stick them in, I'd expect the relative URLs in the href attributes to
> be resolved relative to that document, and I expect that not to change
> when they're detached.

But is does change :-) Here's another use case, adding a base attribute to
the root element in file://home/hip/text_xom/test.xml

<root xml:base="www.acme.org"><foo><bah/></foo></root>

Document
--------
root base uri=file:/home/hip/test-xom/www.acme.org
foo base uri=file:/home/hip/test-xom/www.acme.org
bah base uri=file:/home/hip/test-xom/www.acme.org

After creation
--------------
far base uri=

After appended to root
----------------------
far base uri=file:/home/hip/test-xom/www.acme.org

After removed from root
-----------------------
far base uri=file:/home/hip/test-xom/test.xml

Now append far to another document file://home/hip/text_xom/test1.xml

<bang><boom><ding/></boom></bang>

Append to document test1.xml
----------------------------
bang base uri=file:/home/hip/test-xom/test1.xml
boom base uri=file:/home/hip/test-xom/test1.xml
ding base uri=file:/home/hip/test-xom/test1.xml
far base uri=file:/home/hip/test-xom/test.xml

So relative URLs under far aren't going to resolve to www.acme.org like in
the first document it was attached to, and won't resolve relative to the
new document. I think users are going to find that very confusing :-(

> Regrettably neither RFC 2396 or XML Base was
> really written with the sort of issues that arise with in-memory documents
> in mind. They all assume, implicitly or explicitly, that all elements come
> from documents with well-defined URIs, and they really don't know what to
> do when that isn't the case. :-(

Right, they don't cover cases where documents are broken apart and
recombined so any algorithms they provide are probably going to break
down. That's why I advocate getter and setters for the source URI along
with a default implementation of the XML Base algorithm (which XOM has
right now in getBaseURI).

With the source URI, access to a element's attributes and access to it's
parental hierarchy a application should have the information it needs to
apply it's own resolution alogrithm that works in those use cases where
the default doesn't.

But right now I don't see a way to always get the URI of the source from
which the document was loaded (if it exists). getBaseURI may return it.
Then again, it may not :-(

Brad




Archive powered by MHonArc 2.6.24.

Top of Page