首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JAXB简化插件与*.xjb

JAXB简化插件与*.xjb
EN

Stack Overflow用户
提问于 2013-07-22 18:14:19
回答 1查看 2.5K关注 0票数 4

我试图使用简化插件来用一组简单的属性替换复杂的属性。我让它按照插件的手册工作。但是我不能更改原始模式,所以我必须使用外部bindings.xjb。它给我带来了各种各样的错误。有人有类似的例子吗?

原版XSD:

代码语言:javascript
复制
<xs:schema id="messages"
    elementFormDefault="qualified"
    version="Exchange2010_SP2"
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://schemas.microsoft.com/exchange/services/2006/messages">

<xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/types" schemaLocation="types.xsd"/>

...

<xs:complexType name="ArrayOfResponseMessagesType">
    <xs:choice maxOccurs="unbounded">
        <xs:element name="CreateItemResponseMessage" type="m:ItemInfoResponseMessageType"/>
        <xs:element name="DeleteItemResponseMessage" type="m:ResponseMessageType"/>
        <xs:element name="GetItemResponseMessage" type="m:ItemInfoResponseMessageType"/>

        ...

    </xs:choice>
</xs:complexType>

为我工作的修改的XSD:

代码语言:javascript
复制
<xs:schema id="messages"
    elementFormDefault="qualified"
    version="Exchange2010_SP2"
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    jaxb:extensionBindingPrefixes="simplify"
    targetNamespace="http://schemas.microsoft.com/exchange/services/2006/messages">

<xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/types" schemaLocation="types.xsd"/>

...

<xs:complexType name="ArrayOfResponseMessagesType">
    <xs:choice maxOccurs="unbounded">
        <xs:element name="CreateItemResponseMessage" type="m:ItemInfoResponseMessageType">
          <xs:annotation>
            <xs:appinfo>
              <simplify:as-element-property/>
            </xs:appinfo>
          </xs:annotation>
        </xs:element>
        <xs:element name="DeleteItemResponseMessage" type="m:ResponseMessageType"/>
        <xs:element name="GetItemResponseMessage" type="m:ItemInfoResponseMessageType"/>

        ...

    </xs:choice>
</xs:complexType>

My bindings.xjb (我想使用它而不是更改模式):

代码语言:javascript
复制
<bindings version="2.1"
      xmlns="http://java.sun.com/xml/ns/jaxb"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
      extensionBindingPrefixes="simplify">
<bindings schemaLocation="../wsdl/messages.xsd" node="/xs:schema/xs:complexType[@name='ArrayOfResponseMessagesType']/xs:choice/xs:element[1]">
    <xs:annotation>
        <xs:appinfo>
            <simplify:as-element-property/>
        </xs:appinfo>
    </xs:annotation>
</bindings>
</bindings>

我当前的异常

代码语言:javascript
复制
org.xml.sax.SAXParseException: Unsupported binding namespace "http://www.w3.org/2001/XMLSchema". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-24 17:24:35

好吧,我想出来了。下面是使其工作的配置:

代码语言:javascript
复制
<bindings version="2.1"
      xmlns="http://java.sun.com/xml/ns/jaxb"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
      extensionBindingPrefixes="simplify">


  <bindings schemaLocation="../wsdl/messages.xsd" node="/xs:schema/xs:complexType[@name='ArrayOfResponseMessagesType']/xs:choice/xs:element[1]">
    <simplify:as-element-property/>
  </bindings>

</bindings>

就这么简单。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17794506

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档