包含其他架构时的JiBx错误

时间:2011-05-24 05:41:12

标签: jibx codegen

这是我用于JiBx to codegen和bind的模式。

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.abc.com/abc/service/APIService" targetNamespace="http://www.abc.com/abc/service/Service" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.0">
<xs:include schemaLocation="OTA_AirLowFareSearchRQ.xsd"/>
<xs:include schemaLocation="OTA_AirLowFareSearchRS.xsd"/>
<xs:element name="APIRequest">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="OTA_AirLowFareSearchRQ"/>
        </xs:sequence>
        <xs:attribute name="version" type="xs:string" use="required"/>
        <xs:attribute name="bdmVersion" type="xs:string" use="required"/>
    </xs:complexType>
</xs:element>
<xs:element name="APIResponse">
    <xs:complexType>
        <xs:sequence>
            <xs:annotation>
                <xs:documentation xml:lang="en">All Schema files in the OTA specification are made available according to the terms defined by the OTA License Agreement at http://www.opentravel.org/ota_downloads_form.cfm</xs:documentation>
            </xs:annotation>
            <xs:element ref="OTA_AirLowFareSearchRS"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

这是我在尝试生成代码时遇到的错误。 错误codegen.CodeGen - 错误:引用元素'{http://www.abc.com/abc/service/APIService}:OTA_AirLowFareSearchRQ'未定义为'element'(第11行,第47行,APIService.xsd)

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

纳拉亚南,

您的xml命名空间不正确。您的错误消息告诉您出了什么问题。 '{http://www.abc.com/abc/service/APIService}:OTA_AirLowFareSearchRQ'未定义,因为OTA_AirLowFareSearchRQ位于{http://www.opentravel.org/OTA/2003/05}名称空间中。< / p>

更正很简单,要么包含来自正确名称空间的元素,要么更简单地将模式放在opentravel名称空间中。以下是您更正的架构定义:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns="http://www.opentravel.org/OTA/2003/05"
 targetNamespace="http://www.abc.com/abc/service/Service"
 elementFormDefault="qualified"
 attributeFormDefault="unqualified"
 version="2.0">
<xs:include schemaLocation="http://www.opentravel.org/2011A/OTA_AirLowFareSearchRQ.xsd"/>
<xs:include schemaLocation="http://www.opentravel.org/2011A/OTA_AirLowFareSearchRS.xsd"/>
<xs:element name="APIRequest">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="OTA_AirLowFareSearchRQ"/>
        </xs:sequence>
        <xs:attribute name="version" type="xs:string" use="required"/>
        <xs:attribute name="bdmVersion" type="xs:string" use="required"/>
    </xs:complexType>
</xs:element>
<xs:element name="APIResponse">
    <xs:complexType>
        <xs:sequence>
            <xs:annotation>
                <xs:documentation xml:lang="en">All Schema files in the OTA specification are made available according to the terms defined by the OTA License Agreement at http://www.opentravel.org/ota_downloads_form.cfm</xs:documentation>
            </xs:annotation>
            <xs:element ref="OTA_AirLowFareSearchRS"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
</xs:schema>

我用JiBX进行了测试,现在应该可以正常使用了!