users@jaxb.java.net

Re: JAXB 2.1 XML to Java - Changing generated class name for a single XML element

From: Serge Merzliakov <smerz_at_epistatic.net>
Date: Mon, 8 Dec 2008 14:33:11 -0800 (PST)

Aleksei,
 Adding your config to my file did not work. I have tried this in the past
with no success. Adding annotation to the XML schema itself did work
however.

Serge


Aleksei Valikov wrote:
>
> Hi.
>
>> I am trying to configure JAXB 2.1 binding file to generate a different
>> class name for one element in the schema.
>> For element called 'event-registry', I want the generated class to be
>> called
>> EventRegistryConfiguration. For all other elements and type, I want the
>> default nameing used by JAXB 2.1
>>
>> When I use the nameXmlTransform property, it appends 'Configuration' to
>> all
>> class names generated. So I am close to what I want. Below is my .xjb
>> file
>> so far.
>>
>> Any thoughts on how to control the generated class names for one classes,
>> or
>> a subset of classes ?
>>
>> SAMPLE 1 - ALMOST WHAT I WANT....
>>
>> <jxb:bindings>
>> <jxb:bindings schemaLocation="osr-event-registry.xsd"
>> node="/xsd:schema">
>> <jxb:schemaBindings>
>> <jxb:package name="nsw.osr.esb.conf.event.registry"/>
>> <jxb:nameXmlTransform>
>> <jxb:elementName suffix="Configuration"/>
>> </jxb:nameXmlTransform>
>> </jxb:schemaBindings>
>> </jxb:bindings>
>>
>> </jxb:bindings>
>>
>> I have tried using (but it fails with errors). Combining both samples so
>> that schema details are the same fails also.
>>
>> SAMPLE 2 - DOES NOT WORK
>>
>> <jxb:bindings node="//xs:element[@name='event-register']">
>> <jxb:schemaBindings>
>> <jxb:nameXmlTransform>
>> <jxb:elementName suffix="Configuration"/>
>> </jxb:nameXmlTransform>
>> </jxb:schemaBindings>
>> </jxb:bindings>
>
> Something like:
>
> <jxb:bindings node="//xs:element[@name='event-register']">
> <jxb:class name="EventRegisterConfiguration"/>
> </jxb:bindings>
>
> Bye.
> /lexi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>

-- 
View this message in context: http://www.nabble.com/JAXB-2.1-XML-to-Java---Changing-generated-class-name-for-a-single-XML-element-tp20890301p20904953.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.