这是我为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-错误:引用的元素"{http://www.abc.com/abc/service/APIService}:(APIService.xsd中第47列第11行)处的"element"未定义OTA_AirLowFareSearchRQ。
非常感谢您的帮助。
Narayanan,
您的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测试了这个,现在应该可以正常工作了!
Don