0

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.

narayanan
  • 515
  • 2
  • 10
  • 19

1 Answers1

0

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:

<?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>

I tested this with JiBX and it Should work fine now!

Don

Don Corley
  • 496
  • 2
  • 7