2

ハイヤス。フラットファイルで注文を送信する顧客がいます。ファイルに複雑さはありませんが、ファイルごとに矛盾がいくつかあります。

ファイルの形式は次のようになります。

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

その構造の周りにスキーマを作成するのに問題はありませんが、時々新しい列が追加されます。

1、2、3、4 [CRLF] 1、2、3、4 [ CRLF ]

残念ながら、変更が逆方向にカスケードされないため、3 列と 4 列の両方の形式をサポートする予定です。両方の形式が同じパイプラインを通過する可能性があるため、個別のスキーマ/パイプラインを作成するオプションは実際にはありません。新しいフィールドは常に行の最後に追加されるため、少なくとも一貫性が保たれます。

私が考えられる唯一のことは、精巧な「どのスキーマが適用されるかを把握し、それに応じてパイプラインコンポーネントをルーティングする」ことです。単一のフラット ファイル スキーマを使用します (オプションの列の minOccurs プロパティを 0 に設定しようとしましたが、うまくいきませんでした)。

アドバイスをよろしくお願いします。

4

1 に答える 1

0

1 つの方法は、「外部」スキーマを定義し、サポートする必要があるさまざまなバージョンのスキーマをインポートすることです。「外部」スキーマは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>

(読みやすくするために一部のデフォルト属性は省略されています)

于 2011-06-03T14:42:48.783 に答える