[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?
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|