0

这是我用于 JiBx 代码生成和绑定的模式。

<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' 未在(APIService.xsd 中的第 11 行第 47 列)的“元素”中定义.

非常感谢任何帮助。

4

1 回答 1

0

纳拉亚南,

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

更正很简单,要么包含来自正确命名空间的元素,要么更简单地将你的模式放在 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 对此进行了测试,现在应该可以正常工作了!

大学教师

于 2011-09-20T17:30:28.903 回答