2015-04-01 42 views
1

我有一個位置平面文件,其中包含重複序列的記錄,就像這樣;如何使用重複序列爲記錄定義平面文件模式?

TOKEN NAME LABEL VALUE LABEL VALUE LABEL VALUE LABEL VALUE .. 

令牌識別記錄的類型,名稱是一個名稱值,並且標籤(10點的位置)和值(50位)對可重複的時間不固定數目(1 .. * )。

我已經定義瞭如下的平面文件架構;它含有(1 .. *),具有LABEL,並與正確的位置數據的值:

repeating sequence schema

兩個標籤和值具有的minOccursmaxOccurs的 1.

我遇到的問題是BizTalk不縫以能夠處理這種情況。當我生成這個模式我碰到下面的輸出(本地)實例:

TOKEN NAME  LABEL  VALUE            

(只生成標籤值的單個實例)。

當我嘗試讀取一個標籤值對(5)多次出現的一個文件,它給了我下面的XML:

<FILE xmlns="http://schemas.demo/2015/01"> 
    <RepeatingRecord xmlns=""> 
     <NAME>NAME</NAME> 
     <LABEL>LABEL</LABEL> 
     <LABEL>VALUE</LABEL> 
     <LABEL>LABEL</LABEL> 
     <LABEL>VALUE</LABEL> 
     <LABEL>LABEL</LABEL> 
     <LABEL>VALUE</LABEL> 
     <LABEL>LABEL</LABEL> 
     <LABEL>VALUE</LABEL> 
     <LABEL>LABEL</LABEL> 
     <LABEL>VALUE</LABEL> 
    </RepeatingRecord> 
</FILE> 

所以我只得到LABEL標籤,但沒有值標籤。 VALUE部分的內容錯誤地放置在LABEL標籤中。

我希望下面的XML:

<FILE xmlns="http://schemas.demo/2015/01"> 
    <RepeatingRecord xmlns=""> 
     <NAME>NAME</NAME> 
     <LABEL>LABEL</LABEL> 
     <VALUE>VALUE</VALUE> 
     <LABEL>LABEL</LABEL> 
     <VALUE>VALUE</VALUE> 
     <LABEL>LABEL</LABEL> 
     <VALUE>VALUE</VALUE> 
     <LABEL>LABEL</LABEL> 
     <VALUE>VALUE</VALUE> 
     <LABEL>LABEL</LABEL> 
     <VALUE>VALUE</VALUE> 
    </RepeatingRecord> 
</FILE> 

我如何定義與記錄重複序列的平面文件架構?

我現在有以下模式:

<?xml version="1.0" encoding="utf-16"?> 
<xs:schema xmlns="http://schemas.goudse.nl/irma/adapter/2015/01" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.goudse.nl/irma/adapter/2015/01" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:annotation> 
    <xs:appinfo> 
     <b:schemaInfo standard="Flat File" root_reference="FILE" default_pad_char="0x20" pad_char_type="hex" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="true" generate_empty_nodes="false" allow_early_termination="true" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" document_type="ASFBatchFlatFileSchema" version="2015.01" schema_type="document" default_child_order="postfix" child_delimiter_type="hex" default_child_delimiter="0x0D 0x0A" /> 
     <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" /> 
    </xs:appinfo> 
    </xs:annotation> 
    <xs:element name="FILE"> 
    <xs:annotation> 
     <xs:appinfo> 
     <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="default" notes="Een compleet bestand" /> 
     </xs:appinfo> 
    </xs:annotation> 
    <xs:complexType> 
     <xs:sequence minOccurs="1" maxOccurs="1"> 
     <xs:annotation> 
      <xs:appinfo> 
      <b:groupInfo sequence_number="0" /> 
      </xs:appinfo> 
     </xs:annotation> 
     <xs:element minOccurs="1" maxOccurs="unbounded" name="RepeatingRecord"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="TOKEN " notes="Data behorende bij de schadebrief" sequence_number="1" /> 
      </xs:appinfo> 
      </xs:annotation> 
      <xs:complexType> 
      <xs:sequence> 
       <xs:annotation> 
       <xs:appinfo> 
        <b:groupInfo sequence_number="0" /> 
       </xs:appinfo> 
       </xs:annotation> 
       <xs:element name="NAME" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="1" pos_length="12" pos_offset="6" pad_char_type="hex" pad_char="0x20" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:sequence minOccurs="1" maxOccurs="unbounded"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:groupInfo sequence_number="2" /> 
        </xs:appinfo> 
       </xs:annotation> 
       <xs:element minOccurs="1" maxOccurs="1" name="LABEL" type="xs:string"> 
        <xs:annotation> 
        <xs:appinfo> 
         <b:fieldInfo justification="left" pos_length="10" pad_char_type="hex" pad_char="0x20" sequence_number="1" /> 
        </xs:appinfo> 
        </xs:annotation> 
       </xs:element> 
       <xs:element minOccurs="1" maxOccurs="1" name="VALUE" type="xs:string"> 
        <xs:annotation> 
        <xs:appinfo> 
         <b:fieldInfo justification="left" pos_length="50" pad_char_type="hex" pad_char="0x20" sequence_number="2" /> 
        </xs:appinfo> 
        </xs:annotation> 
       </xs:element> 
       </xs:sequence> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

和以下測試數據文件(替換空間爲清楚起見期間,模式定義爲空間填充)。

TOKEN.NAME........LABEL.....VALUE.............................................LABEL.....VALUE.............................................LABEL.....VALUE.............................................LABEL.....VALUE.............................................LABEL.....VALUE............................................. 

UPDATE

我沒有在這個問題(爲簡單起見)提什麼,這個記錄在多種類型的不同記錄的平面文件使用,因此分裂這個記錄成兒童記錄不是一個可行的解決方案。

+1

你是否已經嘗試過在一個架構的東西嗎?你可以發佈嗎?謝謝。 – potame 2015-04-01 09:05:26

+0

您可以發佈您的平面文件的相關示例嗎?如果沒有關於文件中所有結構/記錄的信息,很難知道您需要什麼 – 2015-04-01 14:32:20

回答

2

我能夠驗證從您的文章用下面的頂部輸入,希望它可以讓你ONT他正確的軌道:

<?xml version="1.0" encoding="utf-16"?> 
<xs:schema xmlns="http://BizTalk_Server_Project2.FlatFileSchema2" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalk_Server_Project2.FlatFileSchema2" 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="FILE" /> 
    </xs:appinfo> 
    </xs:annotation> 
    <xs:element name="FILE"> 
    <xs:annotation> 
     <xs:appinfo> 
     <b:recordInfo structure="positional" 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="FILE_Child1" type="xs:string"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:fieldInfo justification="left" pos_offset="0" pos_length="6" sequence_number="1" /> 
      </xs:appinfo> 
      </xs:annotation> 
     </xs:element> 
     <xs:element name="FILE_Child2" type="xs:string"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:fieldInfo justification="left" pos_offset="0" pos_length="5" sequence_number="2" /> 
      </xs:appinfo> 
      </xs:annotation> 
     </xs:element> 
     <xs:element maxOccurs="unbounded" name="FILE_Child3"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="positional" sequence_number="3" 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="FILE_Child3_Child1" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="6" sequence_number="1" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="FILE_Child3_Child2" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="6" sequence_number="2" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 
+1

您是否願意解釋此解決方案? – 2015-04-01 14:25:32

+0

它在TOKEN記錄中爲LABEL和VALUE創建重複記錄。你說這是行不通的,因爲你的文檔的其他功能,但我不知道我可以做什麼,沒有看到更多的文件。 – 2015-04-02 13:04:41

相關問題