[DAS2] RE: Working with xml:base in Java?

Helt,Gregg Gregg_Helt at affymetrix.com
Wed Feb 8 10:12:22 UTC 2006

> -----Original Message-----
> From: Thomas Down [mailto:td2 at sanger.ac.uk]
> Sent: Wednesday, February 08, 2006 12:45 AM
> To: Helt,Gregg
> Cc: DAS/2
> Subject: Re: Working with xml:base in Java?
> On 7 Feb 2006, at 19:00, Helt,Gregg wrote:
> >
> > 	Thomas, I'm wondering what toolkits you're using for binding XML
> > to Java objects?  And particularly how you are dealing with
> > URIs when xml:base is used.  So far I've mostly used various
> > implementations of SAX and DOM -- I've found some reports of builtin
> > xml:base support in Xerces SAX/DOM, but it's still unclear.
> >
> > 	I've been avoiding the issue up till now.  It won't be too hard
> > to implement URI resolution relative to xml:base, but I thought I'd
> > check around first and see if there's automated support of this in
> > some
> > toolkit.
> Hi Greg,
> I'm actually using Stax (the streaming API for XML).  The
> implementation I use is called Woodstox:
>           http://woodstox.codehaus.org/

I would like to check out Stax, haven't used it before.
> (but there are a few others out there).  No builtin xml:base support
> but it's easy to write a little wrapper around XMLStreamReader to
> spot xml:base attributes and maintain a stack of base URIs.
> I'm using java.net.URI to do the URI handling/resolution/
> relativization.  Seems to be working okay... so far...

That's what I was thinking about when I said it wouldn't be too hard to
implement... But that was yesterday.  A long time ago.

Now I've taken a detour into re-reading the XML Base spec
http://www.w3.org/TR/xmlbase/, and things don't seem so easy.

I _think_ if there's at least one xml:base attribute in the element
hierarchy above where you're trying to determine a base URI, and
resolution of those xml:base attributes yields an absolute URI, it's all
good, that's the  base URI.  But on the other hand if this resolution
yields a relative URI instead of an absolute URI I'm not sure what
happens -- I would guess it's an error, but I can't see anywhere in the
XML Base spec that spells this out.  And if there's no xml:base to use
to determine a base URI, things get weird:
   if the document is "encapsulated within another entity", the base URI
is the URI of that entity (I have no idea if DAS/2 docs could appear in
such a context)
   otherwise the base URI is the URI used to retrieve the document
   oh, except if you burrow down into the spec pointers to RFC 2396
http://www.ietf.org/rfc/rfc2396.txt, if the request gets redirected you
need to make sure the base URI is the last URI used in the redirect
   oh yeah, and apparently external entity declarations can affect all
of this in ways I don't understand
   and there's probably other gotchas I've missed...

Now from the server side, none of this is really an issue.  Just pick
from a multitude of variants that XML Base allows when you send
responses to the client.  From the client side, if we really want DAS/2
to support XML Base (and I think we do), things get tricky.  It's
definitely pushing me towards using libraries that provide builtin
support for XML Base.


More information about the DAS2 mailing list