1

biztalk 2009を使用していますが、マッピングについてサポートが必要です。私は次のような入力をしました:

<root>
    <shop>
        <product>
            <type>1</type>
            <code>ab</code>
            <desc></desc>
        </product>
        <product>
            <type>2</type>
            <code>cd</code>
            <desc></desc>
        </product>
    </shop>
    <address />
    <names />
</root>

製品のコレクションを、次のようなxmlの文字列としてターゲット要素にマップしたいと思います。 <products><product type="1" code="ab" /><product type="2" code="cd" /></products>

カスタムxsltを使用した解決策を見つけましたが、非常に気まぐれであることがわかったため、使用したくありません。カスタムスクリプトを使用してこれを実行できるFunctoidはありますか?私もac鋭い開発者のおかげです!

4

2 に答える 2

2

これは、単純なマップを使用して、箱から出して完全に実行できます。

以下は、不正確な XML ファイルです。

<root>
    <shop>
        <product>
            <type>1</type>
            <code>ab</code>
            <desc></desc>
        </product>
        <product>
            <type>2</type>
            <code>cd</code>
            <desc></desc>
        </product>
    </shop>
    <address />
    <names />
</root>

ソーススキーマは次のとおりです。

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="shop">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="1" maxOccurs="unbounded" name="product">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="type" type="xs:string" />
                    <xs:element name="code" type="xs:string" />
                    <xs:element name="desc" type="xs:string" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="address">
          <xs:complexType />
        </xs:element>
        <xs:element name="names">
          <xs:complexType />
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

ターゲット スキーマは次のとおりです。

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="products">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="unbounded" name="product">
          <xs:complexType mixed="true">
            <xs:attribute name="type" type="xs:string" />
            <xs:attribute name="code" type="xs:string" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

そして、ここに地図があります:

ソース スキーマと宛先スキーマの BizTalk マップ

出力は次のとおりです。

<products>
    <product type="1" code="ab" /> 
    <product type="2" code="cd" /> 
</products>

彼の結果を利用して、Mark Brimble が彼のブログで概説している 2 つの提案のいずれかに従うことができます。

ノード全体をマップ内の文字列型の要素にコピーする方法

于 2011-03-31T19:45:45.247 に答える
0

申し訳ありませんが、マッピングが複雑になりすぎて、マッパーでこれを行う明確な方法がない場合は、出力メッセージを作成する割り当てメッセージ内の .net ヘルパー メソッドに頼ります。

ヘルパー メソッドは、biztalk メッセージを XLANGMessage 型の引数として受け取り、ターゲット メッセージ型に変換される XMLDocument の型を返すことができます。これは、内部の xml が型を正しくレンダリングする場合に提供されます。

例えば:

public static XmlDocument HelperMethod (XLANGMessage message)
{
    var sourceType = (SourceType)message[0].RetrieveAs(typeof(SourceType));
    var targetType = new TargetType();

    // ... Do target type population and serialization to XmlDocument here

    return targetAsXmlDoc;
}

.net 内でこれを行うのは簡単なので、.net に取り込んで実行してください。そこにいるすべてのマッピングの達人に申し訳ありません!

于 2011-04-04T11:07:00.227 に答える