2017-09-21 62 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

相关问题