Hm, the snippet I sent worked fine with a w3c XML schema. (No "implements
Serializable" without the wrapper, interface added with the wrapper.) Now I
admit that I never tried to use xjc with a DTD, and it's probably foolhardy
to assume that this works just like compiling XML schemas.
Also, I've serched for "DTD" in Sun's official JAXB 2.0 Specification. It
says that support for DTDs is a (verbatim) "non-goal", and the authors
further state that "the existence of several conversion tools that automate
the conversion of a DTD to XML Schema allows DTD users to be able to take
advantage of JAXB technology by converting their existing DTDs to XML
Schema."
-W
On Fri, Jun 12, 2009 at 1:59 PM, Ryan O'Connell <Ryan.Oconnell_at_sun.com>wrote:
> Hi Wolfgang,
>
> Thank you for the response. I assume that the schemaLocation attribute
> should be a URI to the DTD I'm compiling? If so, I tried a few variations
> of URIs and still received the exact same error.
>
> I'm also a little surprised I would need to put the URI of the DTD I'm
> compiling in the custom binding file. It was not required in the previous
> version of JAXB and it would also mean I need to have a binding file for
> each schema/DTD I'm compiling which seems inefficient.
>
> I must be doing something else wrong. Wish I knew what it was :-).
>
> Any further thoughts appreciated.
> --ryano
>
>
>
> Wolfgang Laun wrote:
>
>> Wrap the globalBindings element in a jaxb:bindings, specifying the schema
>> locatiion
>>
>> <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
>> version="2.0">
>> <jaxb:bindings schemaLocation="uri">
>> <jaxb:globalBindings>
>> <jaxb:serializable/>
>> </jaxb:globalBindings>
>> </jaxb:bindings>
>> </jaxb:bindings>
>>
>> This will give you "implements Serializable", but no serialVersionUID; you
>> can request this
>> by specifying attribute uid="<int>" but this value is used in all classes.
>>
>> -W
>>
>> On Thu, Jun 11, 2009 at 11:41 PM, Ryan O'Connell <Ryan.Oconnell_at_sun.com<mailto:
>> Ryan.Oconnell_at_sun.com>> wrote:
>>
>> Hello,
>>
>> In the past I was able to compile DTDs using JAXB. I also
>> specified a custom binding that made each implementation class
>> Serializable. The version of JAXB I was using created interfaces
>> for all XML content as well as impls of those interfaces
>>
>> The binding file contained the following content:
>>
>> <?xml version="1.0" ?>
>> <xml-java-binding-schema
>> xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
>> <xjc:serializable uid="1" />
>> </xml-java-binding-schema>
>>
>> And I invoked the JAXB compiler using the xjc task like so:
>>
>> <xjc schema="${ts.home}/lib/dtds/sun-application_5_0-0.dtd"
>> binding="${ts.home}/src/${porting.package.dir}/jaxb-cust.xml"
>> target="${ts.home}/src"
>> package="${porting.package}.app">
>> <arg value="-dtd"/>
>> <depends dir="${ts.home}/lib/dtds"
>> includes="sun-application_6_0-0.dtd"/>
>> <produces dir="${ts.home}/src/${porting.package.dir}/app"
>> includes="**/*"/>
>> </xjc>
>>
>>
>> At some point I upgraded to JAXB 2.x and I noticed interfaces were
>> no longer generated just plain Java classes, and I also noticed my
>> classes did not implement Serializable. I have tried many
>> variations of binding file and I can't seem to make it work. This
>> binding file seems like it should work:
>>
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
>> version="2.0">
>> <jaxb:globalBindings>
>> <jaxb:serializable/>
>> </jaxb:globalBindings>
>> </jaxb:bindings>
>>
>> but I keep getting the following error:
>>
>> [xjc] [ERROR] cvc-elt.1: Cannot find the declaration of element
>> 'jaxb:globalBindings'.
>> [xjc] line 3 of
>>
>> file:/Users/ryanoconnell/Documents/workspace/spider/src/com/sun/ts/lib/implementation/sun/javaee/runtime/jaxb-cust.xml
>>
>>
>> Can anyone tell me where I fell off the beam?
>>
>> Thanks in advance.
>> --ryano
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> <mailto:users-unsubscribe_at_jaxb.dev.java.net>
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>> <mailto:users-help_at_jaxb.dev.java.net>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>