2017-01-13 8 views
-1

最初に、私はすでに持っているコードを提供します。 XML:私が持っているXSLTだSOAP応答からのXSL文字列の抽出

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Body> 
     <getUserDataResponse xmlns="http://wtp"> 
     <getUserDataReturn>Matt</getUserDataReturn> 
     <getUserDataReturn>NY</getUserDataReturn> 
     </getUserDataResponse> 
    </soapenv:Body> 
</soapenv:Envelope> 

:私が達成しようとしている何

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope"> 
<xsl:output method="xml" omit-xml-declaration="no" encoding="utf-8" indent="yes" /> 
    <xsl:template match="/"> 
     <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
      <soapenv:Body> 
       <getUserDataResponse xmlns="http://wtp"> 
        <xsl:for-each select="soapenv:Envelope/soapenv:Body/soapenv:getUserDataResponse/soapenv:getUserDataReturn"> 
         <xsl:value-of select="." /> 
        </xsl:for-each> 
       </getUserDataResponse> 
      </soapenv:Body> 
     </soapenv:Envelope> 
    </xsl:template> 
</xsl:stylesheet> 

はそれがあったようにそれを入れて、この場合は文字列「マットでは、配列の最初の要素だけを抽出することですさらにそれを別のエンドポイントに送信するための定期的な応答 "となります。何が間違っているのかわからない。

出力は私がしたい:私は今取得

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Body> 
     <getUserDataResponse xmlns="http://wtp"> 
     <getUserDataReturn>Matt</getUserDataReturn> 
     </getUserDataResponse> 
    </soapenv:Body> 
</soapenv:Envelope> 

出力は、単なるデータのない石鹸テンプレートです。

誰かが助けてくれたら本当に感謝しています:)

乾杯!

答えて

0

したい出力を使用して達成することができます。

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:wtp="http://wtp"> 
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 

<!-- identity transform --> 
<xsl:template match="@*|node()"> 
    <xsl:copy> 
     <xsl:apply-templates select="@*|node()"/> 
    </xsl:copy> 
</xsl:template> 

<xsl:template match="wtp:getUserDataResponse"> 
    <xsl:copy> 
     <xsl:apply-templates select="wtp:getUserDataReturn[1]"/> 
    </xsl:copy> 
</xsl:template> 

</xsl:stylesheet> 

をそれをあなたが開始されている方法を行うには、あなたがしなければならないでしょう:

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:wtp="http://wtp"> 
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 

<xsl:template match="/"> 
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
     <soapenv:Body> 
      <getUserDataResponse xmlns="http://wtp"> 
       <getUserDataReturn> 
        <xsl:value-of select="soapenv:Envelope/soapenv:Body/wtp:getUserDataResponse/wtp:getUserDataReturn[1]" /> 
       </getUserDataReturn> 
      </getUserDataResponse> 
     </soapenv:Body> 
    </soapenv:Envelope> 
</xsl:template> 

</xsl:stylesheet> 

注意プレフィックスを使用してデフォルトの"http://wtp"名前空間の要素を選択します。

関連する問題