2014-04-14 2 views
0

입력 :네임 스페이스와 비누 태그

<user> 
    <firstName>John</firstName> 
    <lastName>Doe</lastName> 
</user> 

출력 : I는 항등 변환하여 하나 XSL에 네임 스페이스를 추가하여이를 달성 할 수있어 다른 XSL을 사용하여 비누 태그

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.abc.com/v1"> 
<soapenv:Header/> 
<soapenv:Body> 
    <v1:user> 
    <v1:firstName>John</v1:firstName> 
    <v1:lastName>Doe</v1:lastName>   
    </v1:user> 
</soapenv:Body> 
</soapenv:Envelope> 

하지만 단일 xsl에서 수행 할 수 없습니다.

하는 사람이 SOAP 요소를 출력하고, 내부 apply-templates을 수행 / 일치하는 템플릿을 쓰기 나 하나의 XSLT

답변

1

원본 문서가 no-namespace에 속하며 나머지 코드는 정적입니다. 원본 문서의 요소에 접두어를 붙이려면 (*) 접두어가 붙은 복사본을 v1으로 만들고 namespace 특성이있는 네임 스페이스를 적용합니다. 아래 XSLT에서 기대하는 결과를 얻을 수 있습니다.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
    <xsl:output indent="yes"/> 
    <xsl:template match="/"> 
     <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
          xmlns:v1="http://www.abc.com/v1"> 
      <soapenv:Header/> 
      <soapenv:Body> 
       <xsl:apply-templates /> 
      </soapenv:Body> 
     </soapenv:Envelope> 
    </xsl:template> 

    <xsl:template match="*"> 
      <xsl:element name="v1:{name()}" namespace="http://www.abc.com/v1"> 
      <xsl:apply-templates/> 
     </xsl:element> 
    </xsl:template> 
</xsl:stylesheet> 
+0

감사합니다. – mnvbrtn

0

달성하는 데 도움 주실 래요, 당신은 입력 요소의 네임 스페이스를 변경하려면 템플릿을 추가 할 수 있습니다.