[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how to use xml:base and relative URLs with SAX/Java?

  • To: Anil Philip <goodnewsforyou@y...>
  • Subject: Re: how to use xml:base and relative URLs with SAX/Java?
  • From: Liam Quin <liam@w...>
  • Date: Sat, 10 Dec 2005 13:32:45 -0500
  • Cc: xml-dev@l...
  • In-reply-to: <20051210164934.87558.qmail@w...>
  • References: <20051210045416.GC8981@w...> <20051210164934.87558.qmail@w...>
  • User-agent: Mutt/1.5.9i

java uri xml base
On Sat, Dec 10, 2005 at 08:49:34AM -0800, Anil Philip wrote:
> 1) Thank you for replying. I tried your fix - it
> doesnt work.
> The problem is not with the faulty url (it treats it
> as a string so spaces are ok - actually I have fixed
> the url in other data).

There were three parts to my "fix" -- (1) you need to use
a hierarchical URI scheme in order for xml:base to do
what you want, and (2) you need to modify the schema
to allow the xml:base attribute... as Mike Kay pointed
out, you'll need to "go complex" to do this... (3) you
need to take parent elements into account, since xml:base
affects all its descendents -- in your case you may be
able to get away without doing this because you're
supplying xml:base directly everywhere it's needed.

I wasn't very clear before, sorry.

An aside on inheritance...

Consider an example fragment:

    <imagelist xml:base="http://fromoldbooks.org/OldEngland/">
      <description xlink:href="index.html" /><!--* A *-->
      <image xml:base="pages/421-LudlowCastle/">
        <description xlink:href="index.html" /><!--* B *-->
      </image>
    </imagelist>

A resolves to http://fromoldbooks.org/OldEngland/index.html
B might resolve to
http://fromoldbooks.org/OldEngland/pages/421-LudlowCastle/index.html
if a relative base URI is allowed -- there was some debate about
that in the past but I don't remember the status of the published
documents and errata.

In either case, B's href is relative to the base given in its
parent image, since it doesn't have a base explicitly given.
If its parent image doesn't have a base given either, B gets its
href resolved against the imagelist element's base.

<aside-on-the-aside>
    Things get more complex if you also use external parsed entities,
    so that (say) the "description" element B is actually in a
    separate file, which implicitly gets its own xml:base...
</aside-on-the-aside>

In an ideal world where the rivers flowed with milky treacle (I
never did understand that metaphor, but swimming in the Promised
Land would be interesting) we (W3C) would republish the
XML specification to incorporate namespaces, xml:base, xml:id,
so that APIs would take all these things into account..
but it'd be pretty hard to justify spending the hundreds of
millions of Yen it'd take.

Best,

Liam

-- 
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin/
http://www.holoweb.net/~liam/
Words and pictures from old books: http://fromoldbooks.org/

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.