0

xpath でメソッド A のスキーマを使用して、無制限のノード (「詳細」) を読み取ってマップすると、複数のメッセージが出力されます。唯一の問題は、xsd スキーマの設計では、無制限のノードが常に連続している必要があることです。私が使用している Message Assignment オブジェクトで、読み取ってマップしようとしているインスタンス XPath は

XPathVar = System.String.Format(“
    /* [local-name()=’header’ and namespace-uri()=’http://namespace’]
    /* [local-name()=’detail’ and namespace-uri()=’http://namespace’] and 
    position() = {0}]”, nLoopCount)

detailノードの直後にノードがないheader場合、「コンストラクト ブロックの最後に null 値が含まれています」のような例外をスローして失敗します。メソッド B を機能させる方法はありますか? すなわち

この方法はうまくいきます!

    [Method A]
    <schema>
       <header>  (Node)
           <detail> (Node) unbounded
             <child elements> 
           </detail>
           <additional info> (Node)
             <child elements>
           </additional info>
       </header>

しかし、これは機能せず、「構成ブロックの最後に null 値が含まれています」のような例外をスローします。</p>

    [Method B]
    <schema>
      <header> (Node)
         <additional info> (Node)
            <child elements>
         </additional info>
         <detail> (Node) unbounded
            <child elements> 
         </detail>
      </header>

スキーマ内の < ヘッダー > と < 詳細 > を分離する他の要素またはノードがある場合、例外エラーが発生します。

誰でもこの問題に光を当てることができますか?

4

1 に答える 1

1

I think that you want to use this:

XPathVar = System.String.Format(“
    /* [local-name()=’header’ and namespace-uri()=’http://namespace’]
    /* [local-name()=’detail’ and namespace-uri()=’http://namespace’]
       [position() = {0}]”, nLoopCount)

Explanation: The following often select equivalent sets:

/*[condition1 and condition2]
/*[condition1][condition2]

However, this breaks down when using position. Consider this expression:

/*[condition1 and position()=1]

It selects all elements for which both of the following are true:

  • condition1 is true
  • the element's context position is equal to one

However, this expression:

/*[condition1][position()=1]

...first selects all elements for which condition1 is true and then takes the first such element.

It's a subtle but important difference.

于 2011-12-28T19:52:41.787 に答える