Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / XML

Preserve trailing spaces in a flat file schema

0.00/5 (No votes)
2 May 2009CPOL 18K  
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>

License

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