2011-11-09 20 views
2

XMLタグを含むすべてのものをSOAPメッセージの本文から取得する方法を理解しようとしています。ここでXSLTを使用してSOAPメッセージの本文からXMLを取得する

は、私がこれまで持っているものです。

<?xml version="1.0" encoding="utf-8"?> 
    <xsl:stylesheet version="1.0" 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
     xmlns:soap="http://soap/envelope/" 
    > 
    <xsl:output method="xml" indent="no"/> 

    <xsl:template match="//soap:Body/*"> 
    </xsl:template> 
</xsl:stylesheet> 

答えて

4

次のスタイルシート:

ウィキペディアから this SOAP exampleに適用
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
    xmlns:m="http://www.example.org/stock"> 
    <xsl:template match="/"> 
     <xsl:apply-templates select="soap:Envelope/soap:Body/*"/> 
    </xsl:template> 
    <xsl:template match="@*|node()"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*|node()"/> 
     </xsl:copy> 
    </xsl:template> 
</xsl:stylesheet> 

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> 
    <soap:Header></soap:Header> 
    <soap:Body> 
     <m:GetStockPrice xmlns:m="http://www.example.org/stock"> 
      <m:StockName>IBM</m:StockName> 
     </m:GetStockPrice> 
    </soap:Body> 
</soap:Envelope> 

出力SOAPボディの内容は、 (body要素自体を含まない):

<m:GetStockPrice xmlns:m="http://www.example.org/stock" 
       xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> 
    <m:StockName>IBM</m:StockName> 
</m:GetStockPrice>