2011-05-31 33 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