Biztalk mapper altering nodes order - biztalk

I need to map document X to document Y, being both quite similar. X has the following [fragment of] XSD:
<xsd:complexType>
<xsd:sequence>
<xsd:choice minOccurs="3" maxOccurs="unbounded">
<xsd:element maxOccurs="unbounded" ref="A" />
<xsd:element maxOccurs="unbounded" ref="B" />
<xsd:element maxOccurs="unbounded" ref="C" />
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="D"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
Y has the same elements (A,B,C), but they're not within a sequence.
My problem arises when I test the map with the following input:
<doc-X>
<A>...</A>
<B>...</B>
<C>...</C>
<D>...</D>
<C>...</C>
<D>...</D>
</doc-X>
I get something like this:
<doc-Y>
<A>...</A>
<B>...</B>
<C>...</C>
<C>...</C>
<D>...</D>
<D>...</D>
</doc-Y>
I don't understand why is this happening, since I just map each element with its corresponding pair on the other schema.
EDIT : I've tried putting the property PreserveSequenceOrder to "Yes", but that hasn't worked

XSD on its own does not guarantee that sibling elements will appear in any given order. From what you've described, it sounds like the output is perfectly valid according to its schema. Are you actually getting a failure in your test map?
Is there any way you can post the complete schema and document instances?

You are getting that output because, Map always look for output document ( Document Y) Connections from top elment to bottom element. So in your case it will execute first elment A ( in Document Y) Links, afterthat B, after that C.
Try to modify the output doucment( Document Y) xsd to sth like this
<xsd:complexType>
<xsd:sequence>
<xsd:choice minOccurs="3" maxOccurs="unbounded">
<xsd:element maxOccurs="unbounded" ref="D" />
<xsd:element maxOccurs="unbounded" ref="C" />
<xsd:element maxOccurs="unbounded" ref="B" />
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="A"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
You will see the difference.....

Related

How to declare optional date field in XSD

I was using XSD to validate my incoming XML elements.
XSD File
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.rg/2001/XMLSchema"
xmlns:tns="http://xxxy/ervices/V0"
targetNamespace="http://xxxy/ervices/V" elementFormDefault="qualified"
attributeFormDefault="unqualified" >
<xs:complexType name="FailType">
<xs:sequence>
<xs:element name="ConDt" type="xs:date" minOccurs="0" maxOccurs="1" nillable="true"/>
<xs:element name="PreEn" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
My XML File
<Pat xmlns="http://xxxy/ervices/V">
<ConDt></ConDt>
</Pat>
I was getting element is invalid - The value '' is invalid according to its datatype 'http://org/2001/XMLSchema:date' - The string '' is not a valid Date value.
Specifying nillable="true" allows your instance to contain
<ConDt xsi:nil="true"></ConDt>
but it doesn't allow you to write
<ConDt></ConDt>
(Please don't ask me what they were thinking...)
If you want to allow
<ConDt></ConDt>
Then two possible approaches are
define it as a union type that allows either an xs:date or a
zero-length string, or
(my preferred approach) define it as a list type: a list of xs:date values with maxLength="1".
Thanks a lot Michael. I really appreciate your help.
Below code will allow us to declare optional date field.
<xs:element name="ConDt" maxOccurs="unbounded" minOccurs="0">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0" />
<xs:maxLength value="0" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:date" />
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:element>

Parsing input file with DFDL page by page

I have a very simple row based document in which each row comprises a record. I want to have a DFDL that parses it into chunks that contains fixed number of rows(say, for example 3 records at each chunk).
Original File:
record1
record2
record3
record4
record5
record6
record7
After DFDL Parse:
1) [record1, record2, record3]
2) [record4, record5, record6]
3) [record7]
I am currently able to get all records at once with the following DFDL, but it creates a serious problem when the size of document gets bigger, that' s why i want to get these records page by page. Is it possible to do this? Does anyone have any idea how can this be done?
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:ibmDfdlExtn="http://www.ibm.com/dfdl/extensions" xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions" xmlns:recSepFieldsFmt="http://www.ibm.com/dfdl/RecordSeparatedFieldFormat" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.ibm.com/dfdl/RecordSeparatedFieldFormat" schemaLocation="../IBMdefined/RecordSeparatedFieldFormat.xsd"/>
<xsd:annotation>
<xsd:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format byteOrder="{$dfdl:byteOrder}" encoding="{$dfdl:encoding}" escapeSchemeRef="recSepFieldsFmt:RecordEscapeScheme" occursCountKind="fixed" ref="recSepFieldsFmt:RecordSeparatedFieldsFormat"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:element dfdl:encoding="{$dfdl:encoding}" ibmSchExtn:docRoot="true" name="MM1">
<xsd:complexType>
<xsd:sequence dfdl:separator="%CR;%LF;%WSP*;" dfdl:terminator="">
<xsd:element dfdl:alignment="1" dfdl:escapeSchemeRef="" dfdl:lengthKind="delimited" dfdl:occursCountKind="implicit" maxOccurs="unbounded" name="body" type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Thanks
<xsd:element ibmSchExtn:docRoot="true" name="MM1">
<xsd:complexType>
<xsd:sequence dfdl:separator="" dfdl:terminator="">
<xsd:element dfdl:occursCountKind="implicit" maxOccurs="unbounded" name="Chunk">
<xsd:complexType>
<xsd:sequence dfdl:separator="%CR;%LF;%WSP*;" dfdl:terminator="">
<xsd:element dfdl:lengthKind="delimited" dfdl:occursCountKind="implicit" maxOccurs="3" name="Body" type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

xsd attribute minOccurs="0" is not working for type="xsd:dateTime"

In my wsdl i want the date field to be optional for that in the wsdl i gave
<xsd:element maxOccurs="1" minOccurs="0" name="Date" type="xsd:dateTime" nillable="true" >
</xsd:element>
but its is not working.it is expecting value in this field.How make a dateTime field optional?can anyone please help
Try removing the nillable attribute, keeping the minOccurs.

Unmarshal xhtml as string using xsd

I'm trying to unmarshal a large xhtml document using XSD's and jaxb. I've got everything working except for one part, which contains pure html. Here is an example of the xhtml I'm getting (I am able to grab every element except the "content"):
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">...</title>
<id>...</id>
<updated>...</updated>
<entry>
<id>...</id>
<title type="text">...</title>
<updated>...</updated>
<author>
<name>...</name>
</author>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<div>{html...}<div>{html...}</div>/<div>/<div>
</content>
</entry>
</feed>
Here's an expansion of the xsd file:
<xsd:complexType name="ApCategoriesJAXB" >
<xsd:sequence>
<xsd:element name="id" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="title" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="updated" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="link" type="tns:ApLinkJAXB" minOccurs="0"></xsd:element>
<xsd:element name="entry" type="tns:ApEntryJAXB" minOccurs="0" maxOccurs="unbounded"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ApEntryJAXB">
<xsd:sequence>
<xsd:element name="id" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="name" type="xsd:string" minOccurs="0"></xsd:element>
<xsd:element name="title" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="updated" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="author" type="tns:ApAuthorJAXB" minOccurs="0"></xsd:element>
<xsd:element name="link" type="tns:ApLinkJAXB" minOccurs="0"></xsd:element>
<xsd:element name="category" type="tns:ApCategoryJAXB" minOccurs="0"></xsd:element>
<xsd:element name="content" type="tns:ApContentJAXB" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ApCategoryJAXB" >
<xsd:sequence></xsd:sequence>
<xsd:attribute name="term" type="xsd:string" />
<xsd:attribute name="label" type="xsd:string" />
<xsd:attribute name="scheme" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="ApContentJAXB" >
<xsd:sequence>
<xsd:element name="div" type="tns:ApDivJAXB" minOccurs="0" maxOccurs="unbounded"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ApDivJAXB" >
<xsd:sequence>
<xsd:any namespace="http://www.w3.org/2005/Atom" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
I have tried every combination of nested xsd elements, complexTypes, xsd:any etc etc and cannot seem to get this "content" value no matter what I try. I am happy to take all the html as a string, or unmarshal it into an object.
Thank you in advance for any thoughts.
** I've edited the xsd part to include relevant parts. I've tried both nesting the "any" element in the "div" complexType as seen, as well as skipping the "div" complexType altogether.
Thanks again.
If you want <content> to have a type of xsd:string, you need to encode or otherwise escape the HTML. You could use CDATA sections, Base64 encoding, or escape all the entities (e.g. < to <, etc.).
Otherwise, xsd:any should work. Can you provide a more complete example of your XSD when you tried this?

SOAP Response not unserialized correctly in Flex 4

I am seeing certain nodes of my SOAP response disappearing in Flex 4. I am using an <mx:WebService> that is written using PHP/nusoap and 99% of the responses are unserialized correctly in Flex. For some reason this snippet is causing problems:
RAW XML:
<data xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:reportData[1]">
<item xsi:type="tns:reportData">
<name xsi:type="xsd:string">Tue. 8 Mar. 2011</name>
<year xsi:type="xsd:int">2011</year>
<month xsi:type="xsd:int">3</month>
<day xsi:type="xsd:int">8</day>
<counts xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:double[3]">
<item xsi:type="xsd:double">26</item>
<item xsi:type="xsd:double">11</item>
<item xsi:type="xsd:double">11</item>
</counts>
</item>
</data>
The only element to show in the Flex ProxyObject is "name". All other values are simply ignored.
The WSDL defines reportData as:
<xsd:complexType name="reportData">
<xsd:all>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="url" type="xsd:string"/>
<xsd:element name="year" type="xsd:int"/>
<xsd:element name="month" type="xsd:int"/>
<xsd:element name="day" type="xsd:int"/>
<xsd:element name="hour" type="xsd:int"/>
<xsd:element name="counts" type="tns:reportCountList"/>
<xsd:element name="breakdown_total" type="tns:reportCountList"/>
<xsd:element name="breakdown" type="tns:reportDataList"/>
</xsd:all>
</xsd:complexType>
Any ideas why this XML will not unserialize correctly?
From the comments above:
According to w3.org/TR/2001/REC-xmlschema-1-20010502/#element-all minOccurs defaults to 1 meaning it needs to be explicitly set to minOccurs=0 in the WSDL.
The above SOAP response was missing the required url element. Changing the WSDL to explicitly define the url element as optional minOccurs="0" fixes the issue.

Resources