Reputation: 3597
I am being passed a large chunk of XML for processing in BizTalk. The xml is mainly in the form:
<FieldItem>
<Name>EmploymentStatus</Name>
<Value xsi:type="xsd:string">1</Value>
</FieldItem>
However, occasionally a name value pair becomes more complex, looking something like this:
<FieldItem>
<Name>EducationAndQualifications</Name>
<Value xsi:type="RepeatingFieldArray">
<Fields>
<RepeatingField>
<Items>
<FieldItem>
<Name>Qualification</Name>
<Value xsi:type="xsd:string">umbraco</Value>
</FieldItem>
<FieldItem>
<Name>Establishment</Name>
<Value xsi:type="xsd:string">IBM</Value>
</FieldItem>
<FieldItem>
<Name>DateAchieved</Name>
<Value xsi:type="xsd:string">June 2011</Value>
</FieldItem>
</Items>
</RepeatingField>
</Fields>
</Value>
</FieldItem>
I have tried generating a schema via BizTalks Generated Items Wizard but it can't cope with the types changing and then the additional repeating fields which may or may not be there.
So I am looking for advice/guidance on the best way forward on this. Is it possible to create a schema that BizTalk will like to deal with this? Or, the solution I'm favouring at the moment, should I create a custom pipeline component that splits this out into separate messages?
Thanks for your time.
UPDATE
If I create the following schema:
<?xml version="1.0" encoding="utf-16" ?>
<xsd:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="FormData">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="FormName" type="xsd:string" />
<xsd:element name="FormInstanceId" type="xsd:string" />
<xsd:element name="Status" type="xsd:string" />
<xsd:element name="Data">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="FieldItem">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" type="xsd:string" />
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Value" nillable="true" type="xsd:anyType" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
I get the following error:
This is an invalid xsi:type 'RepeatingFieldArray'
So I am still leaning towards writing some code to sort this all out ....
Upvotes: 1
Views: 1254
Reputation: 3597
I have decided to go down the custom pipeline component route extracting the repeating data into a generic schema which also matches the general repeating key/value pairs. I have added additional fields so that each message can be identified by it's section. See below:
<?xml version="1.0" encoding="utf-16" ?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="https://BizTalk.Interfaces.INT034.Schemas.PropertySchema" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:imports xmlns:b="http://schemas.microsoft.com/BizTalk/2003">
<b:namespace prefix="ns0" uri="https://BizTalk.Interfaces.INT034.Schemas.PropertySchema" location=".\PropertySchema.xsd" />
</b:imports>
</xs:appinfo>
</xs:annotation>
<xs:element name="Root">
<xs:annotation>
<xs:appinfo>
<b:properties>
<b:property name="ns0:Interface" xpath="/*[local-name()='Root' and namespace-uri()='']/*[local-name()='Interface' and namespace-uri()='']" />
</b:properties>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Interface" type="xs:string" />
<xs:element name="Type" type="xs:string" />
<xs:element name="FormName" type="xs:string" />
<xs:element name="FormInstanceId" type="xs:string" />
<xs:element name="Status" type="xs:string" />
<xs:element name="Data">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="FieldItem">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Value" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Upvotes: 1