[DAS2] RE: Working with xml:base in Java?
Lincoln Stein
lstein at cshl.edu
Thu Feb 9 16:15:48 UTC 2006
The Perl libraries provide a very simple HTTP_Base attribute. As you parse
your way through the XML, you can change the HTTP_Base using any of the
relative or absolute address resolution modes, so that subsequent URLs are
correctly resolved. Unfortunately it is a SAX model, so that you have to push
previous bases onto a stack and restore them as needed.
Lincoln
On Wednesday 08 February 2006 05:12, Helt,Gregg wrote:
> > -----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
>
> resolving
>
> > > 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.
>
> Gregg
>
>
> _______________________________________________
> DAS2 mailing list
> DAS2 at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/das2
--
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
FOR URGENT MESSAGES & SCHEDULING,
PLEASE CONTACT MY ASSISTANT,
SANDRA MICHELSEN, AT michelse at cshl.edu
More information about the DAS2
mailing list