[relaxng-user] Java datatype library: value object->string
conversion
Kohsuke Kawaguchi
Kohsuke.Kawaguchi at Sun.COM
Wed Nov 3 16:03:30 ICT 2004
Julian Scheid wrote:
> Kohsuke Kawaguchi wrote:
>> And even if you fix that, it's still not enough for code generators.
>> They have to know how to create an instance of QName, not a string
>> representation. You'd like to be able to generate something like:
>>
>> public static final QName ABC = new QName("foo","bar");
>
> Actually I don't need this, I'd just like to generate:
>
> Datatype qnameDatatype = ...;
> QName abc = (QName)qnameDatatype.createValue(literal, context);
>
> where 'literal' is some value read from an XML stream.
>
> I assume that's because I'm ok with the generated code depending on the
> datatype library.
Oh, OK. But if you are doing this, can't you just remember what literal
you passed in to Datatype.createValue, along with the context that you
passed in? You can also use .getClass() to find out what the type of
the value is for that particular literal.
> I agree that when it comes to transforming to literals the issue is
> somewhat more complex than I indicated. But isn't what's needed
> basically a registerNamespace(String uri, String prefix) method in the
> context?
No. My point was that generating code like the following is a lot more work:
public static final QName ABC = new QName("foo","bar");
It's clearly not just an issue of declaring a new namespace.
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi at sun.com
More information about the relaxng-user
mailing list