2017-01-13 2 views
-1

먼저 코드를 제공 할 것입니다. XML :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> 

XSLT이야 내가 가지고 내가 뭘 달성하기 위해 노력하고있어이 경우 문자열 "매트에서, 배열의 첫 번째 요소를 추출하는 것입니다

<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" 네임 스페이스의 요소를 선택합니다.

관련 문제