Click here to Skip to main content
15,891,757 members
Articles / Programming Languages / XML

Preserve trailing spaces in a flat file schema

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
2 May 2009CPOL 17.8K   5   1
If the trailing spaces of your flat file message is being truncated by BizTalk, here is a workaround.

If the trailing spaces of your flat file message is being truncated by BizTalk, then the workaround to this is to add the pad_char_type="none" attribute to the schemainfo and fieldinfo tags. I used the flat file schema wizard to generate the schema. Before modification, my schema looked like this:

XML
<xs:schema xmlns="" targetNamespace=" ">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo standard="Flat File" codepage="65001" 
        default_pad_char=" " pad_char_type="char" 
        count_positions_by_byte="false" parser_optimization="complexity" 
        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="false" 
        compile_parse_tables="false" root_reference="RecordNode" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="RecordNode">
    <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>
            <b:groupInfo sequence_number="0" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element maxOccurs="unbounded" name="RecordField" type="xs:string">
          <xs:annotation>
            <xs:appinfo>
              <b:fieldInfo justification="" sequence_number="1" />
            </xs:appinfo>
          </xs:annotation>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

After modification my schema changed to this:

XML
<xs:annotation>
    <xs:appinfo>
     <b:schemaInfo standard="Flat File" codepage="65001" pad_char_type="none" 
       count_positions_by_byte="false" parser_optimization="complexity" 
       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="false" 
       compile_parse_tables="false" root_reference="RecordNode" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="RecordNode">
    <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>
            <b:groupInfo sequence_number="0" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element maxOccurs="unbounded" 
             name="RecordField" type="xs:string">
          <xs:annotation>
            <xs:appinfo>
              <b:fieldInfo justification="" 
                sequence_number="1" pad_char_type="none" />
            </xs:appinfo>
          </xs:annotation>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
This article was originally posted at http://abdulrafaysbiztalk.wordpress.com?p=26

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Qatar Qatar
I am a BizTalk Server MVP for 2010 and an active blogger and a participant on the MSDN BizTalk Server Forums. I am currently working as a BizTalk Architect at a Bank in Qatar. Before this position I worked as a Sharepoint Consultant in UAE , BizTalk Architect in Bank Saudi Fransi in Saudi Arabia and United Bank Ltd in Pakistan.

I also achieved MCTS certification in BizTalk Application development in June 2008.

Click here to check out my Blog.

SQL Server Query Notification with BizTalk Server 2009 WCF SQL Adapter.

Envelope Wrapper.

Aggregator (Sequential Convoy)

Splitter (Debatching multiple records)
Resequencer
Recipient List
Scatter and Gather using Self Correlating Port

Comments and Discussions

 
QuestionQuestion about truncated spaces but in a bistalk mapper. Pin
Henkhell Pedroza25-Jun-09 9:37
Henkhell Pedroza25-Jun-09 9:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.