1

SoapUI を使用して xml 応答データを検証しているときに問題が発生しました。問題を解決できるように、問題を XPath Visualizer に転送しました。

Xpath クエリを使用して、子ノードb:ActivityDescription値が '7.75000%10/30-11-10 $1602' に等しい b:AccountActivityノードを、以下の xml の抜粋から返したいと考えています。

これは私のxpathクエリです:

//b:AccountActivity[b:ActivityDescription = "7.75000%10/30-11/10    $1602"]

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <RetrieveAccountActivityResponse xmlns="http://tempuri.org/">
         <RetrieveAccountActivityResult xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:key xmlns:b="http://schemas.datacontract.org/2004/07/IntegratorSuite.DataContracts">
               <b:CurrentPage>0</b:CurrentPage>
               <b:Direction>Ascending</b:Direction>
               <b:PageSize>50</b:PageSize>
               <b:SortByParameter i:nil="true"/>
               <b:TotalEntries>4</b:TotalEntries>
               <b:TotalPages>1</b:TotalPages>
            </a:key>
            <a:value xmlns:b="http://schemas.datacontract.org/2004/07/IntegratorSuite.DataContracts">
               <b:AccountActivity>
                  <b:AccountNumber>11111111</b:AccountNumber>
                  <b:AccountType>2</b:AccountType>
                  <b:ActivityDescription>7.75000%10/30-11/10    $1602</b:ActivityDescription>
                  <b:Amount>4.1200000000</b:Amount>
                  <b:CallPut_HasValue>false</b:CallPut_HasValue>
                  <b:CallPut_Value>ALL</b:CallPut_Value>
                  <b:CmpQualCode i:nil="true"/>
                  <b:Currency>USD</b:Currency>
                  <b:Cusip></b:Cusip>
                  <b:Description1/>
                  <b:Description2/>
                  <b:EntryType>DC</b:EntryType>
                  <b:ExpirationDate>9999-12-31T23:59:59.9999999</b:ExpirationDate>
                  <b:JournalDescription i:nil="true"/>
                  <b:NetAmount>-4.1200000000</b:NetAmount>
                  <b:Price>0.000000</b:Price>
                  <b:PrincipalAmount>-4.1200000000</b:PrincipalAmount>
                  <b:Quantity>0.000000</b:Quantity>
                  <b:RecordType>H</b:RecordType>
                  <b:RootSymbol i:nil="true"/>
                  <b:SecQualCode i:nil="true"/>
                  <b:SecurityDescription>Cash</b:SecurityDescription>
                  <b:SecurityGroupCategoryID>0</b:SecurityGroupCategoryID>
                  <b:SecurityGroupDescription i:nil="true"/>
                  <b:SecurityQuantityConversion>0</b:SecurityQuantityConversion>
                  <b:SecurityTypeCode i:nil="true"/>
                  <b:StockConversionFactor>0</b:StockConversionFactor>
                  <b:StrikePrice>0.0</b:StrikePrice>
                  <b:Symbol/>
                  <b:SymbolCusip i:nil="true"/>
                  <b:TableID i:nil="true"/>
                  <b:TradeDate_HasValue>true</b:TradeDate_HasValue>
                  <b:TradeDate_Value>2010-11-11T00:00:00</b:TradeDate_Value>
                  <b:TradeDetailID_HasValue>false</b:TradeDetailID_HasValue>
                  <b:TradeDetailID_Value>0</b:TradeDetailID_Value>
                  <b:TradeNumber i:nil="true"/>
                  <b:TransactionType>Interest Collected</b:TransactionType>
                  <b:UnderlyingCusip i:nil="true"/>
                  <b:UnderlyingSymbol i:nil="true"/>
               </b:AccountActivity>
               <b:AccountActivity>
               ...

ノード値のスラッシュが一致の失敗の原因となっているようです。xml および xpath クエリからそれらを削除すると、一致します。ノード値のスラッシュの一致に問題はありますか? 根本的な質問のように思えますが、答えが見つかりません。

4

3 に答える 3

3

問題は、私が投稿した部分 (アレハンドロが示唆したように) の下 (かなり下) の xml ドキュメントにあったことが判明しました。クエリされている要素の名前空間 URI は、ドキュメントの後半で別の URI に再定義されていました。2 番目の名前空間が別の一意の名前に変更されると、xpath は期待どおりに機能します。何らかの理由で、ドキュメントの後半で URI を再定義すると、目的のノードの上のフィールド データにスラッシュが含まれている場合に、一部の xpath ツールで異常な動作が発生し、他のツールでは異常な動作が発生しませんでした。皆様のご意見をお寄せいただきありがとうございます。次回はドキュメント全体を投稿します:)。

于 2011-01-25T17:51:48.600 に答える
1

これを再現することはできません

代替テキスト

于 2010-11-16T20:49:52.793 に答える
0

Alejandroが質問に対するコメントで指摘したように、名前空間バインディングは、このxpathのテストに使用したすべてのツール(xmlspyを除く)で機能しているわけではありません。ただし、次のxpathは機能しました(名前空間を単に無視しました)。

//*[local-name()='AccountActivity' and ./*[local-name()='ActivityDescription' and text()='7.75000%10/30-11/10    $1602']]
于 2010-11-16T23:29:18.070 に答える