Lets say I have an WSDL file like this:
<definitions>
<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>
<service name="StockQuoteService">
<documentation>My first service</documentation>
<port name="StockQuotePort" binding="tns:StockQuoteBinding">
<soap:address location="http://example.com/stockquote"/>
</port>
</service>
</definitions>
I have my xslt like this:
<xsl:for-each select="definitions/service">
</xsl:for-each>
which can find all the service
in the wsdl. However I want to find the bindings of each service. How can I do that?
For example in this case, for the service StockQuoteService
, the binding I need to find is this node (after removing the tns
in the attribute):
<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>
how can I do this in xslt?
答案 0 :(得分: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>