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: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: Laurent Bihanic <laurent.bihanic AT atosorigin.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Base URIs
  • Date: Thu, 26 Sep 2002 10:00:52 -0400

At 3:04 PM +0200 9/26/02, Laurent Bihanic wrote:
Elliotte Rusty Harold wrote:
We need to find a way to either ease subclassing of these or prevent it by using "pluggable behaviour classes" like TextWriter.
Do you have something specific in mind?

Not really. I was just wondering how I could implement a custom Serializer that provides special handling of xml:base attribute; for example a serializer that makes sure all xlink:hrefs are absolute URIs.
As of today, i'll be quite difficult if the xml:base storage is package-protected but also because there is no write(Attribute) method. I'd have to overwrite the write(Element) method.


How xml:base will be handled will depend on how I implement base URI handling. There've been a lot of good ideas presented in this thread, not all of them fully compatible with each other. I'm still rolling them around in my head. However, one thing they all have in common is a getBaseURI() or getBaseURL() method somewhere. This should be enough to allow subclasses to access the current base. They might be able to do it in other ways. And most of the serializer methods are not final, so they could be overridden to implement custom handling.

I do need to experiment to find out whether or not this is practically possible or not, or whether there are hidden dependencies as there were in JDOM's XMLOutputter. A CanonicalXMLSerializer subclass would be a good test. If there are any problems with writing Serializer subclasses, then that's an API design flaw I need to fix.

(FYI, just so everyone knows: I recently noticed a nasty bug in both Serializer and getStringForm() that gets the namespaces wrong when a child element has no namespace and an ancestor element is in the default namespace. This will be fixed in the next release. It's an implementation bug and required no API changes.)

As to a serializer that makes sure all xlink:hrefs are absolute URIs, I think is possible, but again I haven't actually tried to write it. Experiment will have to wait until I produce a preliminary base URI API.

--

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo AT metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
| http://www.cafeconleche.org/books/xian2/ |
| http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+




Archive powered by MHonArc 2.6.24.

Top of Page