2011-05-31 48 views
2

Hiyas。我有一位客户以平面文件向我们发送订单。文件没有真正的复杂性,但是文件之间存在一些不一致之处。Biztalk架构变量允许在分隔文件中的列数?

的文件的格式是这样的:

1,2,3 [CRLF]
1,2,3 [CRLF]

没有问题从创建围绕结构的模式,但是他们不时会添加一个新的专栏。

1,2,3, [CRLF]
1,2,3, [CRLF]

不幸的是,他们没有让自己改变级联倒退,所以我们野兔预期支持3和4列格式。这两种格式都可能通过相同的管道传输,所以我实际上没有选择创建独立的模式/管道。他们总是将新的字段添加到行的末尾,这样至少是一致的。

我能想到的唯一办法是创建一个详细的“找出哪个模式适用并根据路由组件进行路由”,但在我走下那条路之前,我想看看是否有人在想办法使它与单个平面文件模式一起工作(我尝试将可选列的minOccurs属性设置为0,但那不太好)。

在此先感谢您的任何建议。

+1

有没有什么能够识别记录前端的不同类型的记录?如果有的话,你可以使用标签标识符。 – aceinthehole 2011-06-01 20:09:07

回答

0

一种方法是为您需要支持的不同版本定义“外部”模式和导入模式。 “外部”模式将提供包含对导入的版本模式的引用的choice块。

如果您需要添加下一个版本,您只需导入新架构并将其添加到choice

难的部分当然是你如何确定如何处理不同的版本。也许最简单的方法是为每个需要处理的专用类型创建一张地图。另一方面,您可以扩展“最新最好”的内部消息类型,并根据消息内容进行决策。

“外” 模式

<!-- 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> 

(为便于阅读,省略了一些默认属性)

+0

感谢Filburt,“选择”模式听起来像是最好的解决方案。 – 2011-06-07 22:02:46