Saturday 15 June 2013

jaxb2 basics - JAXB Simplify plugin still usable? -



jaxb2 basics - JAXB Simplify plugin still usable? -

i tried solution of question here jaxb simplify plugin vs *.xjb.

but failed next exception

" compiler unable honor simplify:as-element-property customization. attached wrong place, or inconsistent other bindings. "

this customization binding used

<jaxb:bindings node="//xs:complextype[@name='op']//xs:choice/xs:element[@name='time']"> <simplify:as-element-property/> </jaxb:bindings>

the jaxb simplify plugin confluence page not accessible, has used plugin , can give illustration please?

here updated schema according answer

<xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" elementformdefault="qualified" attributeformdefault="unqualified" xmlns="http://www.amadeus.com/apt/fom/00" targetnamespace="http://www.amadeus.com/apt/fom/00" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify" jaxb:extensionbindingprefixes="simplify"> ... ... <xs:complextype> <xs:sequence> <xs:choice minoccurs="1" maxoccurs="1"> <xs:element name="time" type="xs:datetime" minoccurs="1" maxoccurs="1"> <xs:annotation> <xs:appinfo> <simplify:as-element-property /> </xs:appinfo> </xs:annotation> </xs:element> ... ... </xs:choice> ...

i got exception during maven build "unsupported binding namespace "http://jaxb2-commons.dev.java.net/basic/simplify". perhaps meant "http://jaxb.dev.java.net/plugin/code-injector"?"

disclaimer: author of simplify plugin part of jaxb2 basics.

the plugin project , alive, documentation server dies time time. have no resources maintain own hosting i'm moving projects github.

you can find jaxb2 basics project here:

https://github.com/highsource/jaxb2-basics

documentation not moved yet, here's link 1 of test projects utilize it:

https://github.com/highsource/jaxb2-basics/tree/master/tests/issues

below fragment of schema uses simplify:as-element-property customization:

<xs:complextype name="gh1" mixed="true"> <xs:sequence> <xs:element name="a" type="xs:string"> <xs:annotation> <xs:appinfo> <simplify:as-element-property/> </xs:appinfo> </xs:annotation> </xs:element> <xs:element name="b" type="xs:int"/> </xs:sequence> </xs:complextype>

i'll bring server online in few hours.

please post schema/customization check. problem have have set customization in wrong place. hard figure out.

update

this error:

"unsupported binding namespace "http://jaxb2-commons.dev.java.net/basic/simplify". perhaps meant "http://jaxb.dev.java.net/plugin/code-injector"?"

means plugin missing or not activated. assume utilize maven-jaxb2-plugin. create sure have jaxb2-basics jaxb2 plugin , included -xsimplify switch. here's sample:

<plugin> <groupid>org.jvnet.jaxb2.maven2</groupid> <artifactid>maven-jaxb2-plugin</artifactid> <configuration> <extension>true</extension> <args> <arg>-xsimplify</arg> </args> <plugins> <plugin> <groupid>org.jvnet.jaxb2_commons</groupid> <artifactid>jaxb2-basics</artifactid> </plugin> </plugins> </configuration> </plugin>

next, original error "unable honor ... customization" may related place te customization. have placed on element (which i'd also).

but in cases xjc reads these customizations other schema components. in case, seek place customization on xs:choice instead.

if error persists, please file issue on github providing minimal schema reproduces error. i'll take care of then.

update 2

the server online, have moved documentation of jaxb2 simplify plugin github:

https://github.com/highsource/jaxb2-basics/wiki/jaxb2-simplify-plugin

update 3

the final solution version 0.9.1 sketched here:

https://github.com/highsource/jaxb2-basics/issues/3

customize class with:

<simplify:property name="type2ortype3"> <simplify:as-element-property/> </simplify:property>

example.

jaxb jaxb2-basics xjb jaxb2-simplify-plugin

No comments:

Post a Comment