Gianugo Rabellino wrote:

Murray Altheim wrote:

I thought perhaps if I needed an answer to this question, others
might as well. I also figure that someone on this list has the
answer to this one at their fingertips...

For those programming in Java, the java.net.URL class is
ubiquitous. But creating a URL with 'xmldb' such as

  xmldb:xindice-embed:///db/documentation/overview

will result in

   [java] java.net.MalformedURLException: unknown protocol: xmldb
   [java]     at java.net.URL.<init>(URL.java:586)
   [java]     at java.net.URL.<init>(URL.java:476)
   [...]

which never feels all that much like a warm puppy or a cold beer.

So the question is: how does one register a new protocol in Java
so that you can create xmldb URLs and obtain a valid String when
doing getProtocol()?


URLStreamHandlerFactory is your friend and foe. It's your friend since it allows you to add a custom protocol to Java, it's your foe since only exactly ONE additional protocol per JVM is allowed. I think that the double colon issue can be somehow solves, but this limitation is quite hard to digest...

You could, instead, look into the Avalon Excalibur source resolver, which is used by Cocoon. It gives you an abstraction that allows you to do that. Also, with the XMLDBSource in the Cocoon XMLDB block, you've effectively got a way of reading/writing to/from a XMLDB 'thing'.


Regards, Upayavira




Reply via email to