users@jaxb.java.net

Re: exposing the namespace --> package name mapper

From: Kohsuke Kawaguchi <kohsuke.kawaguchi_at_sun.com>
Date: Thu, 27 Oct 2005 15:31:20 -0700

jonathan gold wrote:
> i've written a custom little string parser that takes a namespace and
> outputs the java package name. it works for us, because we have pretty
> simple package names that follow a known convention. i was hoping i'd be
> able to pick some stuff out of the xjc code to use it directly, and i
> looked around in xjc, and saw that ClassSelector seems to be able to do
> this, but it's also not particularly lightweight, which makes sense,
> since xjc needs to be aware of all of the jaxb customizations, bindings,
> and other compile time context. i'm curious to see if there's anyone
> else who would benefit from having a context free, lightweight, simple
> utility class that would just do the lexical conversion from a namespace
> to a package name?

The actual automatic URI->package conversion is defined in the
com.sun.tools.xjc.reader.Util.etPackageNameFromNamespaceURI method,
which is context-free code.

The one in ClassSelector.getPackage needs to take other things into
account, and this one isn't particularly reusable nor simple.

If your question is how you can plug-in your own nsURI->package
converter code, you can't do that today, but that seems like a
reasonable thing to expose for plugins.

Or did I miss your point?

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com