【问题标题】:JiBx error when inlcuding other schema包含其他模式时出现 JiBx 错误
【发布时间】:2011-08-31 15:50:39
【问题描述】:

这是我用于 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 列)的“元素”中定义.

非常感谢任何帮助。

【问题讨论】:

    标签: jibx codegen


    【解决方案1】:

    纳拉亚南,

    您的 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 对此进行了测试,现在应该可以正常工作了!

    不要

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-10
      • 1970-01-01
      • 2012-11-05
      相关资源
      最近更新 更多