JAXB Simplify插件仍然可用吗? [英] JAXB Simplify plugin still usable?

查看:157
本文介绍了JAXB Simplify插件仍然可用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里尝试了问题的解决方案 JAXB简化插件vs * .xjb

I tried the solution of the question here JAXB Simplify plugin vs *.xjb.

但失败并出现以下异常

编译器无法遵守此简化:as-element-property customization。它附加到一个错误的地方,或者与其他绑定不一致。

" compiler was unable to honor this simplify:as-element-property customization. It is attached to a wrong place, or its inconsistent with other bindings. "

这是我使用的自定义绑定

this is customization binding I used

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

jaxb简化插件汇合页面无法访问,所以有人使用过此插件并举例说明拜托?

the jaxb simplify plugin confluence page is not accessible, so has anyone used this plugin and can give an example please?

这是我根据答案更新的架构

Here is my updated schema according to the 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>
     ...

我在maven构建过程中遇到异常,例如Unsupported binding namespace http://jaxb2-commons.dev.java.net/basic/simplify。也许你的意思是 http://jaxb.dev.java.net/plugin / code-injector

I got the exception during the maven build like "Unsupported binding namespace "http://jaxb2-commons.dev.java.net/basic/simplify". Perhaps you meant "http://jaxb.dev.java.net/plugin/code-injector"?"

推荐答案

免责声明:我是简化插件,它是 JAXB2基础知识的一部分。

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

该项目的插件运行良好,但我的文档服务器不时死亡。我没有资源维护自己的托管所以我将所有项目都移动到GitHub。

The plugin an the project is well and alive, but my documentation server dies from time to time. I have no resources to maintain an own hosting so I'm moving all my projects to GitHub.

您可以在这里找到JAXB2 Basics项目:

You can find the JAXB2 Basics project here:

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

文档尚未移动,但这里是指向使用它的测试项目之一的链接:

Documentation is not moved yet, but here's a link to one of test projects which use it:

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

下面是 schema 使用简化: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'll bring the server back online in few hours.

请发布您的架构/自定义以供我们检查。您遇到的问题可能是您已将自定义放在错误的位置。这有时很难搞清楚。

Please post your schema/customization for us to check. The problem you have is probably that you have put the customization in the wrong place. This is sometimes hard to figure out.

更新

此错误:

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

表示插件缺失或未激活。我假设您使用 maven-jaxb2-plugin 。然后确保你有 jaxb2-basics 作为JAXB2插件,还包括 -Xsimplify 开关。这是示例

Means that the plugin is missing or not activated. I assume you use maven-jaxb2-plugin. Then make sure you have jaxb2-basics as JAXB2 plugin and also included the -Xsimplify switch. 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>

接下来,您的原始错误无法兑现此...自定义可能与您在哪里有关放置定制。你已将它放在元素上(这也是我所做的)。

Next, your original error "unable to honor this ... customization" may be related to WHERE you place te customization. You have placed it on the element (which is what I'd do also).

但在某些情况下,XJC从其他模式组件中读取这些自定义。在您的情况下,请尝试将自定义放在 xs:choice 上。

But in some cases XJC reads these customizations from other schema components. In your case, try to place the customization on xs:choice instead.

如果错误仍然存​​在,请< a gref =https://github.com/highsource/jaxb2-basics/issues =nofollow>在GitHub上提出问题,提供重现错误的最小模式。我会照顾它。

If the error persists, please file an issue on GitHub providing the minimal schema which reproduces the error. I'll take care of it then.

更新2

服务器重新上线,但我现在已经移动了 JAXB2 Simplify Plugin <的文档/ a>到GitHub:

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

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

更新3

这里概述了版本0.9.1的最终解决方案:

The final solution with version 0.9.1 is sketched here:

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

使用以下内容自定义类:

Customize the class with:

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

示例

这篇关于JAXB Simplify插件仍然可用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆