包含其他架构时出现 JiBx 错误
以下是我用于 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 栏) 。
非常感谢任何帮助。
Here is the schema I am using for JiBx to codegen and 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>
and this is the error I am getting when trying to generate code.
ERROR codegen.CodeGen - Error: Referenced element '{http://www.abc.com/abc/service/APIService}:OTA_AirLowFareSearchRQ' is not defined for 'element' at (line 11, col 47, in APIService.xsd).
Any help is highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Narayanan,
您的 xml 命名空间不正确。您的错误消息告诉您出了什么问题。未定义“{http://www.abc.com/abc/service/APIService}:OTA_AirLowFareSearchRQ”,因为 OTA_AirLowFareSearchRQ 位于 {http://www.opentravel.org/OTA/2003/05} 命名空间中。
更正很简单,要么包含正确命名空间中的元素,要么更简单地将您的架构放入 opentravel 命名空间中。这是更正后的架构定义:
我用 JiBX 对此进行了测试,现在应该可以正常工作了!
大学教师
Narayanan,
Your xml namespaces are incorrect. Your error message is telling you what is wrong. '{http://www.abc.com/abc/service/APIService}:OTA_AirLowFareSearchRQ' is not defined, because OTA_AirLowFareSearchRQ is in the {http://www.opentravel.org/OTA/2003/05} namespace.
The correction is simple, either include the element from the correct namespace, or more simply place your schema in the opentravel name space. Here is your corrected schema definition:
I tested this with JiBX and it Should work fine now!
Don