Biztalk模式变量在分隔文件中允许的列数吗?

问题描述

| 希亚斯我有一个客户以平面文件的形式向我们发送订单。文件确实没有任何复杂性,但是文件之间存在一些不一致之处。 该文件的格式如下: 1,2,3 [CRLF] 1,3 [CRLF] 围绕该结构创建模式没有问题,但是它们会不时添加一个新列。 1,3,4 [CRLF] 1,4 [CRLF] 不幸的是,它们不会使更改反向层叠,因此我们希望同时支持3列和4列格式。两种格式都可能会通过同一管道,所以我实际上没有创建单独的架构/管道的选择。他们总是将新字段添加到行的末尾,以便至少保持一致。 我唯一能想到的事情是创建一个精心设计的“确定适用的模式并相应地路由管道组件”,但是在我走这条路之前,我想看看是否有人对实现该方法有任何想法它可以与单个平面文件架构一起使用(我试图将可选列的minOccurs属性设置为0,但这不好)。 在此先感谢您的任何建议。     

解决方法

        一种方法是定义一个“外部”模式,并为您需要支持的不同版本导入模式。 \“外部\”模式将提供一个“ 0”块,其中包含对导入的版本模式的引用。 如果您需要添加下一个版本,只需导入一个新模式并将其添加到“ 0”中。 当然,最困难的部分是如何确定如何处理不同的版本。也许最简单的方法是为您需要处理的每种专用类型创建一个映射。另一方面,您可以扩展“最新和最大”内部消息类型并根据消息内容进行确定。 \“外部\”架构
<!-- language: xml-schema -->

<?xml version=\"1.0\" encoding=\"utf-16\"?>
<xs:schema xmlns:ns0=\"http://ACME.Version_001\" xmlns:b=\"http://schemas.microsoft.com/BizTalk/2003\" xmlns=\"http://ACME.Outer\" xmlns:ns1=\"http://ACME.Version_002\" targetNamespace=\"http://ACME.Outer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">
    <xs:import schemaLocation=\".\\version_002.xsd\" namespace=\"http://ACME.Version_002\" />
    <xs:import schemaLocation=\".\\version_001.xsd\" namespace=\"http://ACME.Version_001\" />
    <xs:annotation>
        <xs:appinfo>
            <b:schemaInfo standard=\"Flat File\" root_reference=\"Root\" />
            <schemaEditorExtension:schemaInfo namespaceAlias=\"b\" extensionClass=\"Microsoft.BizTalk.FlatFileExtension.FlatFileExtension\" standardName=\"Flat File\" xmlns:schemaEditorExtension=\"http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions\" />
            <b:references>
                <b:reference targetNamespace=\"http://ACME.Version_001\" />
                <b:reference targetNamespace=\"http://ACME.Version_002\" />
            </b:references>
        </xs:appinfo>
    </xs:annotation>
    <xs:element name=\"Root\">
        <xs:annotation>
            <xs:appinfo>
                <b:recordInfo structure=\"delimited\" sequence_number=\"1\" child_delimiter_type=\"hex\" child_order=\"postfix\" child_delimiter=\"0x0D 0x0A\" />
            </xs:appinfo>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:choice minOccurs=\"1\">
                    <xs:element ref=\"ns0:Version_001\">
                        <xs:annotation>
                            <xs:appinfo>
                                <b:recordInfo sequence_number=\"1\" structure=\"delimited\" />
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:element>
                    <xs:element ref=\"ns1:Version_002\">
                        <xs:annotation>
                            <xs:appinfo>
                                <b:recordInfo sequence_number=\"2\" structure=\"delimited\" />
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:element>
                </xs:choice>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
导入的模式\“ Version_001 \”
<!-- language: xml-schema -->

<?xml version=\"1.0\" encoding=\"utf-16\"?>
<xs:schema xmlns:b=\"http://schemas.microsoft.com/BizTalk/2003\" xmlns=\"http://ACME.Version_001\" targetNamespace=\"http://ACME.Version_001\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">
    <xs:annotation>
        <xs:appinfo>
            <b:schemaInfo standard=\"Flat File\" root_reference=\"Version_001\" />
            <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=\"Version_001\">
       <xs:annotation>
           <xs:appinfo>
               <b:recordInfo structure=\"delimited\" child_delimiter_type=\"char\" child_order=\"infix\" rootTypeName=\"Version_001\" child_delimiter=\",\" />
           </xs:appinfo>
       </xs:annotation>
       <xs:complexType>
           <xs:sequence>
               <xs:element name=\"Col1\" type=\"xs:string\" />
               <xs:element name=\"Col2\" type=\"xs:string\" />
               <xs:element name=\"Col3\" type=\"xs:string\" />
           </xs:sequence>
       </xs:complexType>
   </xs:element>
</xs:schema>
导入的架构\“ Version_002 \”
<!-- language: xml-schema -->

<?xml version=\"1.0\" encoding=\"utf-16\"?>
<xs:schema xmlns:b=\"http://schemas.microsoft.com/BizTalk/2003\" xmlns=\"http://ACME.Version_002\" targetNamespace=\"http://ACME.Version_002\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">
    <xs:annotation>
        <xs:appinfo>
            <b:schemaInfo standard=\"Flat File\" root_reference=\"Version_002\" />
            <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=\"Version_002\">
       <xs:annotation>
           <xs:appinfo>
               <b:recordInfo structure=\"delimited\" child_delimiter_type=\"char\" child_order=\"infix\" rootTypeName=\"Version_001\" child_delimiter=\",\" />
           </xs:appinfo>
       </xs:annotation>
       <xs:complexType>
           <xs:sequence>
               <xs:element name=\"Col1\" type=\"xs:string\" />
               <xs:element name=\"Col2\" type=\"xs:string\" />
               <xs:element name=\"Col3\" type=\"xs:string\" />
               <xs:element name=\"Col4\" type=\"xs:string\" />
           </xs:sequence>
       </xs:complexType>
   </xs:element>
</xs:schema>
(为便于阅读,省略了一些默认属性)