2013-09-26 26 views
2

鑑於豎線分隔的文件:的BizTalk平面文件拆裝忽略記錄歇

HDR|A 
PSN|CCC|111|00|111111111|DOE|JOHN||M 
PSN|CCC|111|01|111111111|DOE|JANE|A|F|07/30/1975 
ADR|CCC|111|00|U|100 S 1ST #11||ANYTOWN|US|XX|55555|09/24/2013| 
PHN|CCC|111|00|U|US|5551111111||09/24/2013| 

和BizTalk架構:

<?xml version="1.0" encoding="utf-16"?> 
<xs:schema xmlns="http://xxxx.com/schemas/test1" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://xxxx.com/schemas/test1" 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="complexity" lookahead_depth="0" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="true" early_terminate_optional_fields="true" 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_order="postfix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="true" child_delimiter="0x0D 0x0A" /> 
     </xs:appinfo> 
    </xs:annotation> 
    <xs:complexType> 
     <xs:choice minOccurs="0" maxOccurs="unbounded"> 
     <xs:annotation> 
      <xs:appinfo> 
      <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" /> 
      </xs:appinfo> 
     </xs:annotation> 
     <xs:element minOccurs="1" maxOccurs="1" name="Header" type="HeaderType"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="delimited" child_delimiter_type="char" child_delimiter="|" child_order="infix" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="HDR" tag_offset="0" sequence_number="1" /> 
      </xs:appinfo> 
      </xs:annotation> 
     </xs:element> 
     <xs:element minOccurs="0" maxOccurs="unbounded" name="Person" type="PersonType"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="delimited" tag_name="PSN" tag_offset="0" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="char" child_delimiter="|" sequence_number="2" /> 
      </xs:appinfo> 
      </xs:annotation> 
     </xs:element> 
     <xs:element minOccurs="0" maxOccurs="unbounded" name="Address" type="AddressType"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="delimited" tag_name="ADR" tag_offset="0" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="char" child_delimiter="|" sequence_number="3" /> 
      </xs:appinfo> 
      </xs:annotation> 
     </xs:element> 
     <xs:element minOccurs="0" maxOccurs="unbounded" name="Phone" type="PhoneType"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="delimited" tag_name="PHN" tag_offset="0" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" child_delimiter_type="char" child_delimiter="|" sequence_number="4" /> 
      </xs:appinfo> 
      </xs:annotation> 
     </xs:element> 
     </xs:choice> 
    </xs:complexType> 
    </xs:element> 
    <xs:complexType name="HeaderType"> 
    <xs:attribute default="" name="type" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="1" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="description" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="2" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    </xs:complexType> 
    <xs:complexType name="PersonType"> 
    <xs:attribute name="group" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="1" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="id" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="2" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="seq" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="3" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="ssn" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="4" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="last" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="5" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="first" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="6" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="mi" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="7" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="gender" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="8" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="dob" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="9" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    </xs:complexType> 
    <xs:complexType name="AddressType"> 
    <xs:attribute name="group" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="1" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="id" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="2" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="seq" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="3" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="type" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="4" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="addr1" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="5" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="addr2" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="6" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="city" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="7" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="country" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="8" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="state" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="9" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="zip" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="10" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="date" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="11" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="filler" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="12" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    </xs:complexType> 
    <xs:complexType name="PhoneType"> 
    <xs:attribute name="client_code" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="1" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="id" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="2" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="seq" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="3" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute name="type" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="4" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="country" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="5" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="number" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="6" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="extension" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="7" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="date" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="8" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    <xs:attribute default="" name="filler" type="xs:string"> 
     <xs:annotation> 
     <xs:appinfo> 
      <b:fieldInfo justification="left" sequence_number="9" /> 
     </xs:appinfo> 
     </xs:annotation> 
    </xs:attribute> 
    </xs:complexType> 
</xs:schema> 

其中「選擇」是的根(使用,因爲子記錄可以以任何順序),並且其中「tag_name」用於將記錄匹配到模式元素。

,並通過fadsm程序運行

ffdasm "test1.psv" -bs "test1.xsd" -s -m "test1.xml" -v -s 

得到這個

- <Root xmlns="http://xxxx.com/schemas/test1"> 
    <Header type="" description="A" xmlns="" /> 
    <Person group="CCC" id="111" seq="00" ssn="111111111" last="DOE" first="JOHN" mi="" gender="M PSN" dob="CCC|111|01|111111111|DOE|JANE|A|F|07/30/1975" xmlns="" /> 
    <Address group="CCC" id="111" seq="00" type="U" addr1="100 S 1ST #11" addr2="" city="ANYTOWN" country="US" state="XX" zip="55555" date="09/24/2013" filler="" xmlns="" /> 
    <Phone client_code="CCC" id="111" seq="00" type="U" country="US" number="5551111111" extension="" date="09/24/2013" filler="" xmlns="" /> 
    </Root> 
  • 爲什麼頭(HDR)記錄的第一個字段值( 「A」)進入了錯誤的輸出XML的 (秒)屬性?

  • 爲什麼記錄分隔符(CRLF/0X0D ox0A)越來越忽略這樣 即第二(PSN)記錄的內容進入的 在生成的XML的前科當架構設置 提前終止可選屬性記錄和可選字段?

和BTW

  • 爲什麼出現 「TAG_NAME」 匹配的內容從輸出中獲取 XML用於分隔的文件省略?固定長度的平面文件不會發生這種情況;在那些 中,tag_name數據保留在輸出中。

任何有識之士都非常感謝。

回答

1

由於您定義的Infix的child_order,HDR中的第一個字段將進入第二個字段。 有三個子訂單,前綴,中綴,後綴。

前綴表示分隔符出現在每個字段之前。 |1|2|3

Infix意味着它發生在每個字段之間。 1|2|3

Postfix表示它發生在每個字段之後。 1|2|3|

現在您已經選擇了Infix。 所以讓我們看看你的線。

HDR|A

你告訴它的標籤是HDR,所以這條是的,並留下

|A

因爲它是中綴,什麼是前|是字段1,之後是字段2.

你想要的是前綴。

正如您觀察到的標籤名稱被剝離出來一樣,它們被視爲記錄名稱。

至於記錄分隔符被忽略,這是平面文件拆裝者的壞習慣,如果它確實期望另一個字段,它不會找到,然後它消耗下一行,使其進入該字段。 再次檢查您正在做什麼類型的子訂單以及字段是否正確匹配。