当前位置: 首页 > 知识库问答 >
问题:

JAXB绑定不支持的绑定命名空间"http://www.w3.org/2001/XMLSchema"

别兴国
2023-03-14

我有以下XSD,我正在从中生成JAXB绑定…(只为这个问题留下了相关部分):

<?xml version="1.0"?>
<xsd:schema 
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
          xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
          jaxb:extensionBindingPrefixes="simplify">...
 <xsd:element name="trace">

     <xsd:annotation>

        <xsd:documentation>
            containing screen navigation data
        </xsd:documentation>

    </xsd:annotation>

    <xsd:complexType>

        <xsd:choice minOccurs ="0" maxOccurs ="unbounded">
            <xsd:element ref="time"  />
            <xsd:element ref="event" />
            <xsd:element ref="location" />
            <xsd:element minOccurs="0" ref="index" ></xsd:element>
            <xsd:element minOccurs="0" ref="caseId"/>
            <xsd:element minOccurs="0" ref="contactAttId" />
            <xsd:element minOccurs="0" ref="action" />
        </xsd:choice>
    </xsd:complexType>
</xsd:element>

共有1个答案

公风史
2023-03-14

您可以使用以下模式

  <xsd:simpleType name="LayerRate_T">
    <xsd:annotation>
       <xsd:appinfo>
          <xjc:javaType name="org.acme.foo.LayerRate"  adapter="org.acme.foo.LayerRateAdapter" />
       </xsd:appinfo>
    </xsd:annotation>
  </xsd:simpleType>

相反,当将绑定配置包括到XSD中时,使用外部绑定是不同的。

<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
           xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
           jaxb:extensionBindingPrefixes="xjc simplify" jaxb:version="2.1">
    <jaxb:bindings schemaLocation="compass_input_spec_12122014.xsd" node="/xsd:schema">
        <jaxb:bindings node="//xsd:element[@name='trace']/xsd:complexType">
            <simplify:property name="timeOrEventOrLocation">
                <simplify:as-element-property />
            </simplify:property>
        </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>
 类似资料: