JiBx error when inlcuding other schema - jibx

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

Related

Conversion of XML Schema to JSON array list in Biztalk

I have defined a xml scehema below
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.1">
<xs:element name="Root">
<xs:complexType>
<xs:all>
<xs:element name="bblist">
<xs:complexType>
<xs:sequence>
<xs:element name="item" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
I want to generate the Json below using a pipeline.
{
"bblist":
[
"13403"
]
}
but the BizTalk pipeline converts it to
{"bblist": "13403"}
Just wondering if my schema is correct. Am I defining the xsd to generate Json arrays correctly?
There are three issues with your XSD schema
You haven't defined a target Namespace. Which means when it goes through the XML Receive it sets the MessageType to a default set of values which doesn't reference the schema. Which means it might not know which schema to use in the JSON Encoder.
MessageType Root Promoted http://schemas.microsoft.com/BizTalk/2003/system-properties
You have used a <xs:all> rather than a <xs:sequence> in your schema definition. That the JSON Encoder doesn't handle.
If you define your schema as this
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://bblist" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" targetNamespace="http://bblist" vc:minVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" name="bblist">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="item" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
With a payload of
<ns0:Root xmlns:ns0="http://bblist">
<bblist>
<item>item_0</item>
</bblist>
</ns0:Root>
You get a output of
{
"bblist": {
"item": [
"item_0"
]
}
}
This is closer to your expected JSON, with it making an array of the repeating element.
Your structure is incorrect for the JSON you are expecting as you have the repeat on the item and not on the blist.
If you define your schema as
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://bblist" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" targetNamespace="http://bblist" vc:minVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="blist" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XML is
<ns0:Root xmlns:ns0="http://bblist">
<blist>blist_0</blist>
</ns0:Root>
JSON is
{
"blist": [
"blist_0"
]
}

tag validation in XSD File

Someone knows, how to implement the following validate in the XSD file:
When the tag TIPO has the value SER, it is mandatory to register the tag DETALLES_SERVICIOS otherwise if the value is EQU, it is optional
I am using the XSD version 1.0 and I can not implement a way to do this validation.
Thanks in advance for the help.
XML
<REQUERIMIENTO>
<DETALLES_SOLICITUDES>
<ID_PLAN>BP-7138</ID_PLAN>
<ID_SUBPRODUCTO>AUT</ID_SUBPRODUCTO>
<CANTIDAD>1</CANTIDAD>
<TIPO>SER</TIPO>
<DETALLES_SERVICIOS>
<NOMBRE_USUARIO>JANIO</NOMBRE_USUARIO>
<NUMERO_SERIE>12345</NUMERO_SERIE>
<IN_BODEGA>130</IN_BODEGA>
</DETALLES_SERVICIOS>
</DETALLES_SOLICITUDES>
<DETALLES_SOLICITUDES>
<ID_PLAN>0</ID_PLAN>
<ID_SUBPRODUCTO>SAMSUNG A510 G</ID_SUBPRODUCTO>
<CANTIDAD>1</CANTIDAD>
<TIPO>EQU</TIPO>
</DETALLES_SOLICITUDES>
</REQUERIMIENTO>
XSD
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) -->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="REQUERIMIENTO">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="DETALLES_SOLICITUDES">
<xs:complexType>
<xs:sequence>
<xs:element name="ID_PLAN" type="xs:string" />
<xs:element name="ID_SUBPRODUCTO" type="xs:string" />
<xs:element name="CANTIDAD" type="xs:string" />
<xs:element name="TIPO">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="SER"/>
<xs:enumeration value="EQU"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" name="DETALLES_SERVICIOS">
<xs:complexType>
<xs:sequence>
<xs:element name="NOMBRE_USUARIO" type="xs:string" />
<xs:element name="NUMERO_SERIE" type="xs:unsignedShort" />
<xs:element name="IN_BODEGA" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
It is not possible to implement this in XSD-1.0, but if you find a way to use XSD-1.1, you can use the following xs:assert expression after your second xs:sequence element:
<xs:assert test="((TIPO = 'SER') and DETALLES_SERVICIOS) or (TIPO='EQU')" />
EDIT: thx to #MichaelKay to make sure that it isn't possible at all.

XML validation using XSD failing [duplicate]

This is my sample XML code:
<Address>
<StreetAddress></StreetAddress>
<OtherDestination />
<City>TORONTO</City>
</Address>
That is currently using this XSD:
<xs:element name="Address" nillable="true">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:element ref="StreetAddress" minOccurs="0"/>
<xs:element ref="OtherDestination" minOccurs="0"/>
<xs:element ref="City" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
I want to add an attribute id to Address element like this..
<Address id="first">
<StreetAddress></StreetAddress>
<OtherDestination />
<City>TORONTO</City>
</Address>
How should I change the existing XSD to fulfill my requirement?
An attribute declaration can be added within xs:complexType after the xs:sequence:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="Address">
<xs:complexType>
<xs:sequence>
<xs:element name="StreetAddress" minOccurs="0" type="xs:string"/>
<xs:element name="OtherDestination" minOccurs="0" type="xs:string"/>
<xs:element name="City" minOccurs="0" type="xs:string"/>
</xs:sequence>
<!------------------------------------------>
<!-- This is where to declare attributes: -->
<xs:attribute name="id" type="xs:string"/>
<!------------------------------------------>
</xs:complexType>
</xs:element>
</xs:schema>
The above XSD will validate your XML successfully.

Unable to debug a map file due to Typed Polling schema in Biztalk

I have the below mentioned source schema.
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://schemas.microsoft.com/Sql/2008/05/TypedPolling/EmailNotifications" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="TypedPolling">
<xs:complexType>
<xs:sequence>
<xs:element name="TypedPollingResultSet0">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="TypedPollingResultSet0">
<xs:complexType>
<xs:sequence>
<xs:element name="strPortName" type="xs:string" />
<xs:element name="LastRun_UTC" type="xs:dateTime" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The destination schema is
<?xml version="1.0" encoding="utf-16" ?>
<xs:schema xmlns="http://_024_EmailNotifications_Schemas.BizTalkDTADBExtractMod" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://_024_EmailNotifications_Schemas.BizTalkDTADBExtractMod" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Notification">
<xs:complexType>
<xs:sequence>
<xs:element name="strPortName" type="xs:string" />
<xs:element name="LastRun_UTC" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I have a map as shown below
The input file for the map is
<ns0:Root xmlns:ns0="http://schemas.microsoft.com/BizTalk/2003/aggschema">
<InputMessagePart_0>
<ns1:EmailNotifications xmlns:ns1="http://024_EmailNotifications_Schemas.XMLConfig">
<App>
<Name>App1</Name>
<Port>Port1</Port>
<Email>email</Email>
</App>
<App>
<Name>App2</Name>
<Port>Port2</Port>
<Email>Email2</Email>
</App>
<App>
<Name>App3</Name>
<Port>Port3</Port>
<Email>Email3</Email>
</App>
<App>
<Name>App4</Name>
<Port />
<Email>Email4</Email>
</App>
</ns1:EmailNotifications>
</InputMessagePart_0>
<InputMessagePart_1>
<ns2:TypedPolling xmlns:ns2="http://schemas.microsoft.com/Sql/2008/05/TypedPolling/EmailNotifications">
<TypedPollingResultSet0>
<TypedPollingResultSet0>
<strPortName>Port1</strPortName>
<LastRun_UTC>2016-01-29T10:20:10.083Z</LastRun_UTC>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<strPortName>Port2</strPortName>
<LastRun_UTC>2016-01-29T11:37:38.82Z</LastRun_UTC>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<strPortName>Port3</strPortName>
<LastRun_UTC>2016-01-29T11:37:39.353Z</LastRun_UTC>
</TypedPollingResultSet0>
</TypedPollingResultSet0>
</ns2:TypedPolling>
</InputMessagePart_1>
</ns0:Root>
When I try to run the debug option in the map, I get this error which is preventing me from debugging the map, and I don't have a clue how to fix it. Appreciate any help I can get
E:\temp\EmailNotifications\InputInternal.xml: error btm1044: Input validation error: The element 'TypedPolling' in namespace 'http://schemas.microsoft.com/Sql/2008/05/TypedPolling/EmailNotifications' has invalid child element 'TypedPollingResultSet0' in namespace 'http://schemas.microsoft.com/Sql/2008/05/TypedPolling/EmailNotifications'. List of possible elements expected: 'TypedPollingResultSet0'.
When you do not specify the maxOccurs, it defaults to 1. Try setting the nested <TypedPollingResultSet0> element's maxOccurs to unbounded:
<xs:element name="TypedPollingResultSet0">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="TypedPollingResultSet0">
I'm not 100% sure of what corrected my issue.
I changed the name space from ..../EmailNotifications to ..../EmailNotification
That resolved the wiggly line issue in the input xml file in the visual studio.
Then I regenerated the schema file from the input file and viola the issue got resolved.
Thanks Gruff for the help

xsd substitution or xlt transformation

How Do I Change this XSD using substitution to get the following outcome?
I have a XML that is being returned from my asp.net API from a Saas providor. The service comes from asp.net mvc however, I can only use asp classic, and i'm pretty limited in what i can do. I can send TSQL queries to the SQL server 2005... Other than that there's not much that can be done. So my only option for what i need (well my best current option) is this. The data returns from my asp classic page service.asp. service.asp returns the structured xml based off an XSD file that is in the same folder as my script to get the data. I'll show you what it currently returns, what the current xsd is, and what it should return, and the modifications I tried making to the XSD. Hopefully that's the info someone will need to help me as this isn't exactly my strong suite. Thanks!
Current XML Response
Currently the data returns like this:
<xmldata>
<group>
<groupid>1</groupid>
<parentid>2</parentid>
<item>133</item>
<ProductCode>blahblah</ProductCode>
<ProductName>blahblah</ProductName>
</group>
<group>
<groupid>2</groupid>
<parentid>2</parentid>
<item>134</item>
<ProductCode>blahblah</ProductCode>
<ProductName>blahblah</ProductName>
</group>
<group>
<groupid>2</groupid>
<parentid>2</parentid>
<item>313</item>
<ProductCode>blahblah</ProductCode>
<ProductName>blahblah</ProductName>
</group>
<group>
<groupid>3</groupid>
<parentid>2</parentid>
<item>46</item>
<ProductCode>blahblah</ProductCode>
<ProductName>blahblah</ProductName>
</group>
</xmldata>
Current XSD File
My current XSD File is structured as follows:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="xmldata" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
<xs:element name="xmldata" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="groups">
<xs:complexType>
<xs:sequence>
<xs:element msprop:TableNameXsd="groupid" name="groupid" msprop:SqlDbType="Int" msprop:IsIdentity="true" minOccurs="0" />
<xs:element name="ParentID" msprop:SqlDbType="Int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="groupproductlink">
<xs:complexType>
<xs:sequence>
<xs:element msprop:TableNameXsd="groupproductlink" name="ID" msprop:SqlDbType="Int" msprop:IsIdentity="true" minOccurs="0" />
<xs:element name="groupID" msprop:SqlDbType="Int" minOccurs="0" />
<xs:element name="ProductCode" msprop:SqlDbType="Int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Products">
<xs:complexType>
<xs:sequence>
<xs:element msprop:TableNameXsd="Products" name="AutoDropShip" msprop:maxLength="1" msprop:SQLTableAlias="p" msprop:SqlDbType="VarChar" msprop:SQLFrom="FROM vm.Products p INNER JOIN vm.Products_Descriptions pd ON p.ProductCode = pd.ProductCode INNER JOIN vm.PE pe ON p.ProductCode = pe.ProductCode INNER JOIN vm.Products_Memos pm ON p.ProductCode = pm.ProductCode" minOccurs="0" />
<xs:element name="productid" msprop:maxLength="30" msprop:SQLTableAlias="p" msprop:SqlDbType="VarChar" minOccurs="1" />
<xs:element name="ProductCode" msprop:SQLTableAlias="p" msprop:SqlDbType="Int" msprop:IsIdentity="true" minOccurs="0" />
<xs:element name="ProductName" msprop:maxLength="255" msprop:SQLTableAlias="p" msprop:SqlDbType="VarChar" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
What the XML Should Be
The XML Needs to be returned in the following way (please note the attribute becoming the element)
<groups>
**<1> //<---Element=groupID**
<item>133</item>
<parentid>2</parentid>
<ProductCode>blahblah</ProductCode>
<ProductName>blahblah</ProductName>
**</1> //<---Element=groupID
<2> //<---Element=groupID**
<item>134</item>
<parentid>2</parentid>
<ProductCode>blahblah</ProductCode>
<ProductName>blahblah</ProductName>
**</2> //<---Element=groupID
<2> //<---Element=groupID**
<item>313</item>
<parentid>2</parentid>
<ProductCode>blahblah</ProductCode>
<ProductName>blahblah</ProductName>e="1">
**</2> //<---Element=groupID
<3> //<---Element=groupID**
<item>46</item>
<parentid>2</parentid>
<ProductCode>blahblah</ProductCode>
<ProductName>blahblah</ProductName>
**</3> //<---Element=groupID**
</groups>
The XSD I attempted to use and didn't get any response
I tried transforming the XSD that I listed above to the following:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="groups" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
**<xs:element name="groups" *msdata:IsDataSet="true"* msdata:UseCurrentLocale="true">**
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="groupid" *msdata:IsDataSet="true"* msdata:UseCurrentLocale="true" msprop:TableNameXsd="groupid" msprop:SqlDbType="Int" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element msprop:TableNameXsd="groupid" name="groupid" msprop:SqlDbType="Int" msprop:IsIdentity="true" minOccurs="0" />
<xs:element name="ParentID" msprop:SqlDbType="Int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="groupproductlink">
<xs:complexType>
<xs:sequence>
<xs:element msprop:TableNameXsd="groupproductlink" name="ID" msprop:SqlDbType="Int" msprop:IsIdentity="true" minOccurs="0" />
<xs:element name="groupID" msprop:SqlDbType="Int" minOccurs="0" />
<xs:element name="ProductCode" msprop:SqlDbType="Int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Products">
<xs:complexType>
<xs:sequence>
<xs:element msprop:TableNameXsd="Products" name="AutoDropShip" msprop:maxLength="1" msprop:SQLTableAlias="p" msprop:SqlDbType="VarChar" msprop:SQLFrom="FROM vm.Products p INNER JOIN vm.Products_Descriptions pd ON p.ProductCode = pd.ProductCode INNER JOIN vm.PE pe ON p.ProductCode = pe.ProductCode INNER JOIN vm.Products_Memos pm ON p.ProductCode = pm.ProductCode" minOccurs="0" />
<xs:element name="productid" msprop:maxLength="30" msprop:SQLTableAlias="p" msprop:SqlDbType="VarChar" minOccurs="1" />
<xs:element name="ProductCode" msprop:SQLTableAlias="p" msprop:SqlDbType="Int" msprop:IsIdentity="true" minOccurs="0" />
<xs:element name="ProductName" msprop:maxLength="255" msprop:SQLTableAlias="p" msprop:SqlDbType="VarChar" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
However,
It doesn't work currently. I think maybe I need to use a substitution group, however unfortunately it's been years since I did this and I can't remember what exactly I need to do. I truly hope someone here has some better ideas!