JAXB Simplify a plugin that can still be used?

I tried solving the issue here JAXB Simplify plugin vs * .xjb .

but this failed with the following exception:

"the compiler could not perform this simplified setup: as-element-property customization. It is bound to the wrong place or incompatible with other bindings."

this is the configuration binding that I used

<jaxb:bindings node="//xs:complexType[@name='Op']//xs:choice/xs:element[@name='Time']"> <simplify:as-element-property/> </jaxb:bindings> 

jaxb simplifies the merge plugin page is not available, so has anyone used this plugin and can set an example?

Here is my updated schema according to 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 an exception during the maven build, for example, "Unsupported link namespace" http://jaxb2-commons.dev.java.net/basic/simplify ". Perhaps you meant" http://jaxb.dev. java.net/plugin/code-injector "?"

+7
jaxb jaxb2-basics xjb jaxb2-simplify-plugin
source share
1 answer

Disclaimer: I am the author of the Simplify plugin, which is part of the JAXB2 Foundation .

The plugin is a good and lively project, but my documentation server dies from time to time. I don’t have the resources to support my own hosting, so I transfer all my projects to GitHub.

Here you can find the JAXB2 Basics project:

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

The documentation has not yet been moved, but here is a link to one of the test projects that use it:

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

The following is a schema fragment that uses the simplify:as-element-property setting simplify:as-element-property :

 <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 will return the server in a few hours.

Please post your circuit / setup for verification. The problem you have is probably that you made the setting in the wrong place. This is sometimes difficult to understand.


Update

This error:

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

Indicates that the plugin is missing or not activated. I assume you are using maven-jaxb2-plugin . Then make sure you have jaxb2-basics as a JAXB2 plugin, and the -Xsimplify switch is also on. Here's a 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> 

Then your initial mistake, “unable to comply with this ... setting”, may be related to the WHERE that you are posting. You put it in an element (which I will do).

But in some cases, the XJC reads these settings from other components of the circuit. In your case, try putting the setting on xs:choice .

If the error persists, write the problem to GitHub, providing a minimal scheme that reproduces the error. Then I will take care of him.

Update 2

The server is back online, but now I have moved the JAXB2 Simplify Plugin documentation to GitHub:

https://github.com/highsource/jaxb2-basics/wiki/JAXB2-Simplify-Plugin

Update 3

The final solution with version 0.9.1 is given here:

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

Set up the class as follows:

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

An example .

+4
source share

All Articles