2011-05-24 26 views
0

下面是我用於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'沒有爲'元素'定義(行11,列47,在APIService.xsd中)。

任何幫助,高度讚賞。

回答

0

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,它應該現在工作正常!

相關問題