2016-04-07 2 views
0

でXSLTを使用して、XML文書内の検索は、私はこのようなWSDLファイルを持っているとしましょうが実行

内のすべての serviceを見つけることができます
<xsl:for-each select="definitions/service"> 
</xsl:for-each> 

wsdl。しかし、私は各サービスのバインディングを見つけたいと思っています。どうやってやるの?この場合、例えば

は、サービスStockQuoteServiceのために、私が見つける必要がある結合は、(属性にtnsを取り除いた後)このノードである:

<binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType"> 
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
      <operation name="GetLastTradePrice"> 
       <soap:operation soapAction="http://example.com/GetLastTradePrice"/> 
       <input> 
        <soap:body use="literal"/> 
       </input> 
       <output> 
        <soap:body use="literal"/> 
       </output> 
      </operation> 
     </binding> 

私は、XSLTでこれを行うことができますか?

+1

一つの深刻な問題は、 'StockQuoteBinding'( 'TNS:' なし)であるあなたのサービスで' @のbinding'が、ということである試みることが、一致していません。あなたの ''の '@ name'を' StockQuoteSoapBinding'の値で置き換えます。どのようにそれを処理したいですか? 'Binding'の前に 'Soap'を挿入しますか? – zx485

+0

'tns'を削除してから検索することはできませんか? –

答えて

1

あなたはこの

<xsl:template match="/definitions/service"> 
    <xsl:variable name="this" select="." /> 

    <xsl:copy-of 
     select="/definitions/binding[substring-after($this/port/@binding,':') = 
            concat(substring-before(@name,'Soap'),'Binding')]" /> 
</xsl:template>