Schema validation failed xs:date - wcf

I am receiving "Schema validation failed" from the server when calling my WCF service.
The error message returned states that the validation is failing on an element of type "date"
Response from server
<s:Fault>
<s:Code>
<s:Value>s:VCE1001</s:Value>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-GB">Schema validation failed.</s:Text>
</s:Reason>
<s:Detail>
<FaultDetails xmlns="http://schemas.datacontract.org/2004/07/project.Error_Handler" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Information>Element Name: ExampleDateElement, Line Number: 0, Line Position: 0</Information>
</FaultDetails>
</s:Detail>
</s:Fault>
Request to server
<Message xsi:type="q1:Example_OutboundMessage" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:q1="project_messages">
<q1:Element1>123456789123</q1:Element1>
<q1:Element2>
<Nested1>string123</Nested1>
<Nested2>string123</Nested2>
</q1:Element2>
<q1:Element3>2017-03-28</q1:Element3>
<q1:ExampleDateElement>2017-03-29</q1:ExampleDateElement>
<q1:Element4>64bc7ab8-b418-4d23-8d31-47312e838c92</q1:Element4>
</Message>
Schema
<xs:complexType name="Example_OutboundMessage">
<xs:complexContent>
<xs:extension base="vct:OutboundMessage_Type">
<xs:sequence>
<xs:element name="Element1" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Info here
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="12" />
<xs:maxLength value="13" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Element2" minOccurs="1" maxOccurs="1" type="vct:Example_Type">
<xs:annotation>
<xs:documentation>
Info here.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Element3" minOccurs="1" maxOccurs="1" type="xs:date">
<xs:annotation>
<xs:documentation>
Info here.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ExampleDateElement" minOccurs="1" maxOccurs="1" type="xs:date">
<xs:annotation>
<xs:documentation>
Info here.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Element4" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Info here.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
<xs:maxLength value="255" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
Cannot see anything wrong with the date that is passed in for "ExampleDateElement".
Also the schema seems to pass for the date element above, even though the date formats are the same. It even fails if the dates are exactly the same.

Related

BizTalk FlatFile Schema multiple repeating records

I have a flat file and I need to create a schema so I can convert that flat file into XML and bring it to BizTalk.
I have used flat file schema wizard to create a schema but it is not working. I've modified it manually still not working. I will explain what is not working.
Flat File structure:
File header
Batch header
Detail (repeating records)
Address (repeating records)
Trailer
END
After creating the schema I'm trying to validate it and I'm getting error at this point.
Detail and Address are the body and they are repeatable.
My issue is that after it reads the line "DET" it is suppose to read the "ADD". However it is looking for "DET" again.
Error description:
error BEC2004: Unexpected data found while looking for:
'DET'
The current definition being parsed is RefundsRoot. The stream offset where the error occured is 799. The line number where the error occured is 4. The column where the error occured is 0.
Here is the sample
FDR06281339CREDIT REFUND CHECKS AC
HDR9008100000000000100006428
DET900810000000636992103500048763699210350004876369921035000487STMT, TEST 5 01TEST 5 STMT 6902 PINE ST OMAHA NE68106-2855 0000000000+0000000000500000 00FINUT A +00000000000004900 FHSC999999 +0000000000500 EN 0099000000000 +0000000000000+000000000000000000+0000000000000+000000000000000000+0000000000000+0000000000000000000000000000+00009999999999999+00009999999999999+00000000000000000+00000000000000000+999999999999999+99999999999999900000000000+9999999999999990000000000000009900
ADDF 6902 PINE ST OMAHA NE 68106-2855USA
TRL90081000000000001000000020000000000000642800000000000004900000000000000000000
END000000100000000200000000000000000000004900000000000000000000
Here is the schema (due to character limits I've only included related section)
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Fingerhut.BizTalk.Schemas.FSIn_Refunds" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Fingerhut.BizTalk.Schemas.FSIn_Refunds" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
<b:schemaInfo standard="Flat File" codepage="65001" default_pad_char="0x0A 0x0D" pad_char_type="hex" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="true" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="true" compile_parse_tables="false" root_reference="RefundsRoot" />
</xs:appinfo>
</xs:annotation>
<xs:element name="RefundsRoot">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:complexType name="Detail">
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="DETL-HDR" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-SYSTEM" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="4" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-PRIN-BANK" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="4" sequence_number="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-AGENT-BANK" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="4" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-ACCOUNT-NUMBER" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="16" sequence_number="5" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-PRMR-PI-ID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="16" sequence_number="6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-ENTR-ID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="16" sequence_number="7" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-PI-NM" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="8" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-FILLER" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="2" sequence_number="9" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-PI-ROLE-CD" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="2" sequence_number="10" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-PRIMARY-NAME" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="11" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-SECONDARY-NAME" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="12" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-ADDRESS-LINE-1" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="13" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-ADDRESS-LINE-2" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="26" sequence_number="14" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-CITY" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="18" sequence_number="15" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-STATE" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="2" sequence_number="16" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-POST-CODE" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="17" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-REF-NUM" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="18" sequence_number="18" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-CHK-STARTING-NUM" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="5" sequence_number="19" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-NUMBER-OF-CKS" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="4" sequence_number="20" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-DUALITY-FLAG" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="1" sequence_number="21" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-CREDIT-LIMIT" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="14" sequence_number="22" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-NUMBER-OF-PLASTICS" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="23" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DETL-CHECKING-ACCOUNT-NUM" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="17" sequence_number="24" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Address">
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="ADDR-EXPN-ADDR-RCRD-HEDR-ID" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-PRMR-CUST-ADDR-FRMT-CD" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="1" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-ATTN-LINE-TX" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="3" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-CMPN-NM" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="4" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-HOUS-NR" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="5" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-STRT-NM" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="40" sequence_number="6" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-CNTN-ADDR-LINE-1-TX" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="7" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-CNTN-ADDR-LINE-2-TX" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="8" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-CNTN-ADDR-LINE-3-TX" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="9" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-CNTN-ADDR-LINE-4-TX" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="50" sequence_number="10" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-PO-BOX-TX" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="11" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-CITY-NM" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="25" sequence_number="12" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-ST-CD" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="2" sequence_number="13" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-SBDV-TX" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="25" sequence_number="14" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-PSTL-CD" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="10" sequence_number="15" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-CTRY-CD" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="16" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ADDR-FILLER" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo sequence_number="17" justification="left" pos_length="271" pos_offset="0" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
The following schema works (you of cause need to change my string elements to the correct positional record).
What you have to do is:
Add a record after the flat file wizard.
Put the record after your FDR element.
Add your repeating records DEC ADD to this new records as child elements.
Set the record to unbound
Set Child order Infix
Child delimiter type to Hex
Child delimiter to 0x0D 0x0A
This gives you the following schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://FlatFileSchema4" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://FlatFileSchema4" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
<b:schemaInfo standard="Flat File" codepage="65001" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" root_reference="Root" />
</xs:appinfo>
</xs:annotation>
<xs:element name="Root">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0xD 0xA" child_order="postfix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="FDR">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="positional" tag_name="FDR" tag_offset="0" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="FDR" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="35" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="HDR">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="positional" tag_name="HDR" tag_offset="0" sequence_number="2" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="HDR" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="29" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="RR">
<xs:annotation>
<xs:appinfo>
<recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="3" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" child_order="infix" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="DET">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="positional" tag_name="DET" tag_offset="0" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="DET" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="482" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ADD">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="positional" tag_name="ADD" tag_offset="0" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="2" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="ADD" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="41" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TRL">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="positional" tag_name="TRL" tag_offset="0" sequence_number="4" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="TRL" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="81" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="END">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="positional" tag_name="END" tag_offset="0" sequence_number="5" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="END" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" pos_offset="0" pos_length="63" sequence_number="1" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
With test file:
FDR06281339CREDIT REFUND CHECKS AC
HDR9008100000000000100006428
DET900810000000636992103500048763699210350004876369921035000487STMT, TEST 5 01TEST 5 STMT 6902 PINE ST OMAHA NE68106-2855 0000000000+0000000000500000 00FINUT A +00000000000004900 FHSC999999 +0000000000500 EN 0099000000000 +0000000000000+000000000000000000+0000000000000+000000000000000000+0000000000000+0000000000000000000000000000+00009999999999999+00009999999999999+00000000000000000+00000000000000000+999999999999999+99999999999999900000000000+9999999999999990000000000000009900
ADDF 6902 PINE ST OMAHA NE 68106-2855USA
DET900810000000636992103500048763699210350004876369921035000487STMT, TEST 5 01TEST 5 STMT 6902 PINE ST OMAHA NE68106-2855 0000000000+0000000000500000 00FINUT A +00000000000004900 FHSC999999 +0000000000500 EN 0099000000000 +0000000000000+000000000000000000+0000000000000+000000000000000000+0000000000000+0000000000000000000000000000+00009999999999999+00009999999999999+00000000000000000+00000000000000000+999999999999999+99999999999999900000000000+9999999999999990000000000000009900
ADDF 6902 PINE ST OMAHA NE 68106-2855USA
TRL90081000000000001000000020000000000000642800000000000004900000000000000000000
END000000100000000200000000000000000000004900000000000000000000
And output:
<Root xmlns="http://FlatFileSchema4">
<FDR xmlns="">
<FDR>FDR06281339CREDIT REFUND CHECKS AC</FDR>
</FDR>
<HDR xmlns="">
<HDR>HDR9008100000000000100006428</HDR>
</HDR>
<RR xmlns="">
<DET>
<DET>DET900810000000636992103500048763699210350004876369921035000487STMT, TEST 5 01TEST 5 STMT 6902 PINE ST OMAHA NE68106-2855 0000000000+0000000000500000 00FINUT A +00000000000004900 FHSC999999 +0000000000500 EN 0099000000000 +0000000000000+000000000000000000+0000000000000+000000000000000000+0000000000000+0000000000000000000000000000+00009999999999999+00009999999999999+00000000000000000+00000000000000000+999999999999999+99999999999999900000000000+9999999999999990000000000000009900</DET>
</DET>
<ADD>
<ADD>ADDF 6902 PINE ST OMAHA NE 68106-2855USA</ADD>
</ADD>
</RR>
<RR xmlns="">
<DET>
<DET>DET900810000000636992103500048763699210350004876369921035000487STMT, TEST 5 01TEST 5 STMT 6902 PINE ST OMAHA NE68106-2855 0000000000+0000000000500000 00FINUT A +00000000000004900 FHSC999999 +0000000000500 EN 0099000000000 +0000000000000+000000000000000000+0000000000000+000000000000000000+0000000000000+0000000000000000000000000000+00009999999999999+00009999999999999+00000000000000000+00000000000000000+999999999999999+99999999999999900000000000+9999999999999990000000000000009900</DET>
</DET>
<ADD>
<ADD>ADDF 6902 PINE ST OMAHA NE 68106-2855USA</ADD>
</ADD>
</RR>
<TRL xmlns="">
<TRL>TRL90081000000000001000000020000000000000642800000000000004900000000000000000000</TRL>
</TRL>
<END xmlns="">
<END>END000000100000000200000000000000000000004900000000000000000000</END>
</END>
</Root>
I have updated the schema to also include the extra records that your testfile now have. And it works for me.

How to remove or exclude a schema that WCF adds that isn't used?

I've created a webservice in Visual studio with WCF and when looking at the generated WSDL it includes a reference to http://schemas.microsoft.com/2003/10/Serialization which contains a lot of type specifications. I do not use any of these specifications. Does anyone know why WCF adds this and if there's any way to get rid of it?
The xml added to my wsdl looks like this when using the singleWsdl argument on my service:
<xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="anyType" nillable="true" type="xs:anyType" />
<xs:element name="anyURI" nillable="true" type="xs:anyURI" />
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary" />
<xs:element name="boolean" nillable="true" type="xs:boolean" />
<xs:element name="byte" nillable="true" type="xs:byte" />
<xs:element name="dateTime" nillable="true" type="xs:dateTime" />
<xs:element name="decimal" nillable="true" type="xs:decimal" />
<xs:element name="double" nillable="true" type="xs:double" />
<xs:element name="float" nillable="true" type="xs:float" />
<xs:element name="int" nillable="true" type="xs:int" />
<xs:element name="long" nillable="true" type="xs:long" />
<xs:element name="QName" nillable="true" type="xs:QName" />
<xs:element name="short" nillable="true" type="xs:short" />
<xs:element name="string" nillable="true" type="xs:string" />
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte" />
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt" />
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong" />
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort" />
<xs:element name="char" nillable="true" type="tns:char" />
<xs:simpleType name="char">
<xs:restriction base="xs:int" />
</xs:simpleType>
<xs:element name="duration" nillable="true" type="tns:duration" />
<xs:simpleType name="duration">
<xs:restriction base="xs:duration">
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?" />
<xs:minInclusive value="-P10675199DT2H48M5.4775808S" />
<xs:maxInclusive value="P10675199DT2H48M5.4775807S" />
</xs:restriction>
</xs:simpleType>
<xs:element name="guid" nillable="true" type="tns:guid" />
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}" />
</xs:restriction>
</xs:simpleType>
<xs:attribute name="FactoryType" type="xs:QName" />
<xs:attribute name="Id" type="xs:ID" />
<xs:attribute name="Ref" type="xs:IDREF" />
</xs:schema>
Maybe it's too late now, but I ran into this issue and was able to solve it. The reason I wanted to remove it was because I was generating clients in both Java and RPG, and the wsdl2java and wsdl2rpg tools generate large, ugly data structures based on that schema.
In my case, it was because I was using the DataContract serializer, and some of the objects I was serializing had members of types that didn't have the [DataContract] attribute. To make that extra schema go away, everything being serialized, all the way down the type tree needed to have that attribute.
It also had this problem whenever a there was an inherited public member on the service contracts.
I agree there is no need to remove it. Also many times it is used and you do not know about it. The way to change default wsdl generatio is by implementing IWsdlExportExtension:
http://msdn.microsoft.com/en-us/library/system.servicemodel.description.iwsdlexportextension.aspx
The XSD definition for microsoft's WSDL implementation imports this namespace (see here).
Why do you want to remove it?

How to organize my code

I have an auto generated class file with many partial classes (auto generated from an xsd schema). I use VS2010 and VB.NET.
I want to create objects of all of the partial classes like this
Dim schema_obj As Schema
schema_obj = New Schema
schema_obj.Info = New Info
schema_obj.Info.Number = New Number
schema_obj.Info.Number.Value = 3
For all the properties in the different classes (like ex.
schema_obj.Info.Number.Value
schema_obj.Info.Birthday.Value
schema_obj.Info.Colour
I have to write
schema_obj.Info.Number = New Number
schema_obj.Info.Birthday = New Birtday
schema_obj.Info.Colourr = New Colour
I have one function that creates all of these objects and this way I fill the schema object with data.
What is the best way to organize my code? And what about dependency injection? Where should I put my function? In the business layer?
Thanks in advance
UPDATE:
Thanks for all comments and your complementary answer! I appreciate it very much!
I’m developing a part of and business application. The application is used for registration of persons data, invoicing, accounting, and so on. The part I’m developing is a reporting system to the authority via wcf services. In my part I will use VB.NET but the other parts of the system are developed in VB6. We use an SQL server and nearly all the business logic is located at the server side. Because I’m used to use VB6 its difficult to grasp all the OOP things I need to remember to write the code as it should be.
In my part of the application I get an xsd schema from the authority and auto generate my schema class file from the xsd file with xsd.exe. I see that it’s a much better solution that you suggest, but when I looked at my auto generated class file after reading your answer I see that every partial class has a MyBase = New line in the constructor. I can use this in a way, like you suggest? Sorry for not understanding this earlier! If I understand the behavior of MyBase correct, I can write
Dim Number = New Number
Number.value = 3
and the Number constructor will call the Info constructor an the Info constructor will call the Schema constructor.
And I can write
Dim PersonName = New PersonName
PersonName.Value = Bob
Dim PersonAdress = New PersonAdress
PersonAdress.Value = New York
Instead of
schema_obj.Info.Person.PersonName = New PersonName
schema_obj.Info.Person.PersonName.value = Bob
But still I have to create many objects in my function. How can I do this in a better way?
And in the end of my function I want to parse the schema object to a memory stream.
I do that like this:
Dim memorystream As New System.IO.MemoryStream
Dim ser As New XmlSerializer(GetType(Schema))
ser.Serialize(memorystream, Schema_obj)
But now I do not have a Schema_obj that holds the information, how can I parse the schema_obj (all the information) to a memorystream?
UPDATE 2
Sorry, now I understand (I think) and I have done as you said and I can write
Schema_obj = New Schema
Schema_obj.Info.Number.Value = 3
Schema_obj.Info.Person.PersonName = New PersonName
Schema_obj.Info.Person.PersonName.value = Bob
And I do not have to create the objects in my function. But instead of adding my own constructors the MyBase takes care of the job? And now I also can serialize my schema_obj.
But is it possible for you to say anything more about how I can solve the problem with Schema_obj.Info.Number.Value = 3
The project I doing is a fest step against vb.net and OOP for my business. I can use entity framework for my data layer, and I can have my business logic in a Business layer. My front end will be in vb6.
UPDATE 3
Now I’m back to being a little bit confused. I thought I got it but I do not… when I try to run my application I get the error: Object reference not set to an instance of an object. It seems like I have to write
Dim schema_obj As Schema
schema_obj = New Schema
schema_obj.Info = New Info
schema_obj.Info.Number = New Number
schema_obj.Info.Number.Value = 3
The MyBase did not do what I thought it did? Can you please explain some more? Thank you!
UPDATE 4
Thanks for your reply.
Take an XML Schema and have VB.NET classes generated from it.
Build objects and fill in some data (property values).
Serialize everything back to XML.
This is exactly what I do. But I thought I had to convert the xsd to a class, build objects and fill the objects with data and then serialize it back to xml. Why is it a better solution to go for what you suggest? I’m new to this so I appreciate your answers. Do you have an example of when it it a good solution to convert the xsd to objects, like I have done? The xsd I use will change once a year, is it easier to adapt my code to the changes in the way you suggest? The xsd schema is more complex than I showed in my example, I do not know if that have anything to say regarding what method I have to choose?
UPDATE 5:
I’m developing an application where I use wcf services . I use the web service the organization offer to:
1.Send an xml schema populated with data
2.Get a list of available web services
3.Get a specific xsd schema
What I have to do is:
1.Get a xsd schema form the authority and use this xsd to generate a xml populated with data
2.Call the webservice where I can specify a number for a specific xsd schema , and get the xsd schema in return. Then I can validate my xml schema against it before I send it to the authority
3.Use a web service where my xml string is in a string property of a method of the wcf service and I send the xml file to the authority
My xsd looks (almost) like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:br="http://www.br.se/or" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!--title='Tittle' lang='E'-->
<xs:element name="Schema">
<xs:annotation>
<xs:documentation>
<br:txt br:lang="E" br:txttype="LEDE">
<p>Some text</p>
</br:txt>
</xs:documentation>
<xs:documentation>
…………………………
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="Information"/>
<xs:element minOccurs="0" ref="Payer"/>
</xs:sequence>
<xs:attribute fixed="105" name="numberr" type="xs:integer" use="required"/>
<xs:attribute fixed="10360" name="externalnumberr" type="xs:integer" use="required"/>
<xs:attribute fixed="Title" name="title" type="xs:string" use="optional"/>
<xs:attribute fixed="4895" name="groupid" type="xs:positiveInteger" use="optional"/>
<xs:attribute name="id" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="761065">
<xs:annotation>
<xs:documentation>Text</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:anyAttribute/>
</xs:complexType>
</xs:element>
<xs:element name="Info">
<xs:annotation>
<xs:documentation>
<br:txt br:lang="E" br:txttype="LEDE">
<p>Some Text</p>
</br:txt>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="Task">
<xs:annotation>
<xs:documentation>
<br:txt br:lang="E" br:txttype="LEDE">
<p>Some text</p>
</br:txt>
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="Year">
<xs:annotation>
<xs:documentation>
<br:txt br:lang="E" br:txttype="LEDE">
<p>Some Text</p>
</br:txt>
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="Taskowner"/>
</xs:sequence>
<xs:attribute fixed="4877" name="id" type="xs:positiveInteger" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="TaskSpesialTask">
<xs:annotation>
<xs:documentation>
<br:info br:type="some txt">1</br:info>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="List1">
<xs:attribute fixed="212" name="schemaid" type="xs:positiveInteger" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="List2">
<xs:annotation>
<xs:documentation>
<br:info br:type="id">2</br:info>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:length value="1"/>
<xs:enumeration value="1">
<xs:annotation>
<xs:documentation>
<br:txt br:lang="E" br:txttype="LEDE">
<p>Some text</p>
</br:txt>
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="2">
<xs:annotation>
<xs:documentation>
<br:txt br:lang="E" br:txttype="LEDE">
<p>Some text</p>
</br:txt>
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:element name="Year">
<xs:annotation>
<xs:documentation>
<br:info br:type="pl">2</br:info>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="Format">
<xs:attribute fixed="692" name="schemaid" type="xs:positiveInteger" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="Format">
<xs:annotation>
<xs:documentation>
<br:info br:type="id">6</br:info>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:gYear"/>
</xs:simpleType>
<xs:element name="TaskOwner">
<xs:annotation>
<xs:documentation>
<br:txt br:lang="E" br:txttype="LEDE">
<p>Some Text</p>
</br:txt>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="TaskoOwnerNumber">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="TaskOwnerName">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="TaskOwnerAdress
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="TaskOwnerPhone">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="TaskOwnerEmail">
<xs:annotation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute fixed="48" name="id" type="xs:positiveInteger" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="TaskOwnerNumber">
<xs:annotation>
</xs:annotation>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="TextFormat">
<xs:attribute fixed="21" name="id" type="xs:positiveInteger" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="TextFormat">
<xs:annotation>
<xs:documentation>
<br:info br:type="id">1</br:info>
</xs:documentation>
<xs:documentation>
<br:txt br:lang="E" br:txttype="F">
<p>Wrong number</p>
</brreg:tekst>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:length value="9"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="TaskOwner name">
<xs:annotation>
</xs:annotation>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="TextFormat">
<xs:attribute fixed="2" name="id" type="xs:positiveInteger" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="TaskOwner Adress">
<xs:annotation>
</xs:annotation>
</xs:element>
And so on for phone and email
<xs:element name="Payers">
<xs:annotation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="20000" minOccurs="0" ref="PayersInfo"/>
<xs:element minOccurs="0" ref="PaymentTotal">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="NumberOfPayers">
<xs:annotation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute fixed="410" name="id" type="xs:positiveInteger" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="PayersInfo">
<xs:annotation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="PayerBirthNumber">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="PayerNumber">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="PayerBirthDay">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="PayerName">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="PayerAdress">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="PayerPhone">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="PayerEmail">
<xs:annotation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" ref="PayerSum">
<xs:annotation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute fixed="48" name="id" type="xs:positiveInteger" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="PayerBirthNumber">
<xs:annotation>
</xs:annotation>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="TextFormat">
<xs:attribute fixed="2305" name="id" type="xs:positiveInteger" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="TextFormat">
<xs:annotation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:length value="11"/>
</xs:restriction>
</xs:simpleType>
And som on for PayerNumber, PayerBirthDay, PAYerNAMe, PayerAdress, PayerPhone, PayerEmail…..
</xs:schema>
The elements in the xsd are structured as this:
Schema
Info
Year
TaskOwner
TaskOwnerName
TaskOwnerAdress
TaskOwnerPhone
TaskOwnerEmail
TaskOwnerNumber
Task
TaskSpecialTask
TaskOrdinaryTask
Payers
PaymentTotal
NumberOfPayers
PayersInfo (list of payers)
PayerBirtNumber
PayerBirthDay
PayerName
PayerAdress
PayerPhone
PayerEmail
(Pleas ignore if something is left out in the xsd - it is there just so I can explain my problem better)
My question is, how should I generate the xml based on the xsd? I want to do this for multiple xsd schemas. Isn't it the a good solution to deserialize the xsd (with xsd.exe) to a class, create object of that class and populate it with data, and then serialize the object back to xml? Or is it still better the way you suggest. I really want to learn and do it the best way, and not do it the easiest way for me.. I hope this makes it easier for you to give me an answer.
Thanks!

Howto use BizTalk TestableReceivePipeline when having a schema which has an imported schema

Under Microsoft BizTalk 2009, we want to test the ReceivePipeline(which has a Flat file disassembler) with the built-in TestableReceivePipeline class.
It works fine if we use one single Schema, but it throws an error (System.Xml.Schema.XmlSchemaException: The 'ABC' element is not declared.) when we try to use a schema(Schema1) which has an imported schema(Schema2) inside.
Why I'm getting this error?
code for testing pipeline:
StringCollection documents = new StringCollection();
documents.Add(#"c:\Test.dat");
StringCollection parts = new StringCollection();
Dictionary<string, string> schemas = new Dictionary<string, string>();
schemas.Add("MyCompany.Schema2", #"C:\Schema2.xsd");
schemas.Add("MyCompany.Schema1", #"C:\Schema1.xsd");
Microsoft.BizTalk.TestTools.Pipeline.TestableReceivePipeline pipeline = new MyReceivePipeline();
pipeline.TestPipeline(documents, parts, schemas);
Schema1.xsd source:
<xs:import schemaLocation=".\Schema2.xsd" namespace="http://MyCompany.Schema2" />
<xs:element name="Schema1">
<xs:complexType>
<xs:sequence>
<xs:element name="Header">
<xs:complexType>
<xs:sequence>
<xs:element name="ClientRef" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" wrap_char_type="default" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element ref="ns1:Data" />
<xs:element name="Tail">
<xs:complexType>
<xs:sequence>
<xs:element name="RecordCount" type="xs:int">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" wrap_char_type="default" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Schema2.xsd source:
<xs:element name="Data">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" type="xs:string" nillable="true">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" wrap_char_type="default" sequence_number="2" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Surname" type="xs:string" nillable="true">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" wrap_char_type="default" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
AFAIK this is currently not supported in BizTalk 2009.

Can we add new attribute or change type of existing attribute to a "Referenced Element"?

In my XML schema I have an element being referenced tens of times by other elements but with different enumerated values for one of its attribute.
For now, instead of creating this element in global space and referencing it later, I am creating a new instance wherever it is needed. This approach has increased my schema size enormously because of repeated creation of almost same element many times. It also may have adverse effect on efficiency of the schema.
The only way that I see is to create element once and then reference it many times but my problem is: one of the attribute of this referenced element is required to have a different set of enumerations for each referencing element.
My question is:
Is it possible to to add an attribute to a "Referenced Element" in XML Schema?
Something like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.myDomain.com" xmlns="http://www.myDomain.com" elementFormDefault="qualified">
<xs:simpleType name="myValues1">
<xs:restriction base="xs:string">
<xs:enumeration value="value1" />
<xs:enumeration value="value2" />
</xs:restriction>
</xs:simpleType>
<xs:element name="myElement">
<xs:complexType mixed="true">
<xs:attribute name="attr1" type="xs:string" />
<xs:attribute name="attr2" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="MainElement1">
<xs:complexType>
<xs:sequence>
<xs:element ref="myElement">
<xs:complexType>
<xs:attribute name="myAtt" type="myValues1" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="mainAtt1" />
</xs:complexType>
</xs:element>
</xs:schema>
Or can we change type of an existing attribute of a "Referenced Element" in XML Schema?
something like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.myDomain.com" xmlns="http://www.myDomain.com" elementFormDefault="qualified">
<xs:simpleType name="myValues1">
<xs:restriction base="xs:string">
<xs:enumeration value="value1" />
<xs:enumeration value="value2" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="myValues2">
<xs:restriction base="xs:string">
<xs:enumeration value="value3" />
<xs:enumeration value="value4" />
</xs:restriction>
</xs:simpleType>
<xs:element name="myElement">
<xs:complexType mixed="true">
<xs:attribute name="attr1" type="xs:string" />
<xs:attribute name="attr2" type="xs:string" />
<xs:attribute name="myAtt" type="myValues1" />
</xs:complexType>
</xs:element>
<xs:element name="MainElement1">
<xs:complexType>
<xs:sequence>
<xs:element ref="myElement">
<xs:complexType>
<xs:attribute name="myAtt" type="myValues2" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="mainAtt1" />
</xs:complexType>
</xs:element>
</xs:schema>
You cannot override the content model of a referenced element. The point of the reference is that it points to exactly the same element every time.
If you really want the element to have different content, you are better off defining multiple global complex types and using them, rather than using an element reference:
<xs:complexType name="Type1" mixed="true">
<xs:attribute name="attr1" type="xs:string" />
<xs:attribute name="attr2" type="xs:string" />
<xs:attribute name="myAtt" type="myValues1" />
</xs:complexType>
<xs:complexType name="Type2" mixed="true">
<xs:complexContent>
<xs:extension base="Type1">
<xs:attribute name="myAtt2" type="myValues2" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="MainElement1">
<xs:complexType>
<xs:sequence>
<xs:element name="myElement" type="Type1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
I would not worry too much about performance. The reference to the global types will be resolved only once at schema load time.