2017-09-21 61 views
2

我無法理解如何爲以下類型的平面文件創建架構,因爲標記標識符不在第二個字段上。BizTalk平面文件架構標記不在行首

我從下面的例子中刪除了一些額外的數據,但我的問題是非常多的標籤標識符(HDR/ODR和END)之前是增量數字。

000001 HDR 0000031001 1DP 
000002 ORD 0000031001 0001 
000003 ORD 0000031001 0001 
000004 ORD 0000031001 0001 
000005 ORD 0000031001 0001 
000006 END 

解決方案我看到的谷歌似乎debatching基於假設它是爲所有字段相同的第一要素上線,但並不在這種情況下工作。

有沒有辦法將標籤設置爲第二個元素?

該文件是製表符分隔的。

+0

您是否嘗試過使用抵消?請參閱https://msdn.microsoft.com/en-us/library/aa560980.aspx –

+2

@PieterVandenheede除了這似乎是一個位置記錄,而不是一個定界記錄。 – Dijkgraaf

+0

@Dijkgraaf你說得很對。我應該更關注我在這裏發佈的網頁。 –

回答

3

如果只有這3個標籤,並且HDR和END只出現一次,那麼只需創建一個架構,在該架構中您有三條記錄,1個用於HDR,1個用於可能多次出現的ORD ,另一個用於END。 您還必須將預覽深度從默認3更改爲0(無限)。

例如,以下模式將正確解析。

<?xml version="1.0" encoding="utf-16"?> 
<xs:schema xmlns="http://Scratch.46345356" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.46345356" 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="0" 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="infix" 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="HDR"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0x9" 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="Line" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="1" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="Tag" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="2" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="Data1" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="3" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="Data2" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="4" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     <xs:element minOccurs="0" maxOccurs="unbounded" name="ORD"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0x9" child_order="infix" 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="Line" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="1" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="Tag" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="2" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="Data1" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="3" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="Data2" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="4" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     <xs:element name="END"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0x9" child_order="infix" 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="Line" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="1" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="Tag" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" sequence_number="2" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

<Root xmlns="http://Scratch.46345356"> 
    <HDR xmlns=""> 
     <Line>000001</Line> 
     <Tag>HDR</Tag> 
     <Data1>0000031001</Data1> 
     <Data2>1DP</Data2> 
    </HDR> 
    <ORD xmlns=""> 
     <Line>000002</Line> 
     <Tag>ORD</Tag> 
     <Data1>0000031001</Data1> 
     <Data2>0001</Data2> 
    </ORD> 
    <ORD xmlns=""> 
     <Line>000003</Line> 
     <Tag>ORD</Tag> 
     <Data1>0000031001</Data1> 
     <Data2>0001</Data2> 
    </ORD> 
    <ORD xmlns=""> 
     <Line>000004</Line> 
     <Tag>ORD</Tag> 
     <Data1>0000031001</Data1> 
     <Data2>0001</Data2> 
    </ORD> 
    <ORD xmlns=""> 
     <Line>000005</Line> 
     <Tag>ORD</Tag> 
     <Data1>0000031001</Data1> 
     <Data2>0001</Data2> 
    </ORD> 
    <END xmlns=""> 
     <Line>000006</Line> 
     <Tag>END</Tag> 
    </END> 
</Root> 
+0

一直在測試這個,它的工作原理,但是你在模式中設置了最大值4。這意味着如果有5條線路停止工作。使得maxOccurs無界限使得模式不知道何時停止,並一直試圖向「ORD」添加行,直到錯誤預期爲'\ t'的末尾。是否有可能使這項工作具有可變數量的ORD(並保持HDR和END各爲1) – Andy

+0

@Andy這就是我的,HRD和END發生1,而ORD是無界的,所以它們可以是任何數量的ORD線。所以你必須有其他問題。如果是這樣,請用示例文件和模式來創建一個新問題,以演示問題 – Dijkgraaf

+0

我無法接受此問題作爲答案,因爲我沒有解決您的模式問題,但非常接近。最後,我按時運行並通過使用2個接口進行可怕的破解來修復它,這樣我可以使第一列成爲最後一列,並使用標記標識符。由於客戶將需求改變爲實際上有反覆出現的標籤,因此這個回答也無法幫助我再次接受新的請求。我可以刪除這個問題,但答案確實有幫助,所以我也不確定。 – Andy

1

使用標籤標識和標籤結果偏移你實現你的目標:

<?xml version="1.0" encoding="utf-16"?> 
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://BizTalkMassCopy.FlatFileSchema6" targetNamespace="http://BizTalkMassCopy.FlatFileSchema6" 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="infix" 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="Header"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="positional" tag_name="HDR" tag_offset="8" 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="Count" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="8" sequence_number="1" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="TagId" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="2" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="Item" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="17" sequence_number="3" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     <xs:element minOccurs="4" maxOccurs="4" name="Ord"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="positional" sequence_number="2" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="ORD" tag_offset="8" /> 
      </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="Count" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="8" sequence_number="1" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="TagId" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="2" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="Item" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="17" sequence_number="3" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     <xs:element name="End"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="positional" sequence_number="3" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name="END" tag_offset="8" /> 
      </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="Count" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="8" sequence_number="1" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
       <xs:element name="TagId" type="xs:string"> 
       <xs:annotation> 
        <xs:appinfo> 
        <b:fieldInfo justification="left" pos_offset="0" pos_length="3" sequence_number="2" /> 
        </xs:appinfo> 
       </xs:annotation> 
       </xs:element> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

結果是這樣的:

<Root xmlns="http://BizTalkMassCopy.FlatFileSchema6"> 
    <Header xmlns=""> 
    <Count>000001</Count> 
    <TagId>HDR</TagId> 
    <Item> 0000031001 1DP</Item> 
    </Header> 
    <Ord xmlns=""> 
    <Count>000002</Count> 
    <TagId>ORD</TagId> 
    <Item> 0000031001 0001</Item> 
    </Ord> 
    <Ord xmlns=""> 
    <Count>000003</Count> 
    <TagId>ORD</TagId> 
    <Item> 0000031001 0001</Item> 
    </Ord> 
    <Ord xmlns=""> 
    <Count>000004</Count> 
    <TagId>ORD</TagId> 
    <Item> 0000031001 0001</Item> 
    </Ord> 
    <Ord xmlns=""> 
    <Count>000005</Count> 
    <TagId>ORD</TagId> 
    <Item> 0000031001 0001</Item> 
    </Ord> 
    <End xmlns=""> 
    <Count>000006</Count> 
    <TagId>END</TagId> 
    </End> 
</Root> 
+1

之後,我確實進行了更新。除了該文件是TAB分隔文件而非定位文件之外。所以這不適用於這種情況 – Dijkgraaf

相關問題