2011-08-08 6 views
-1

다음과 같이 xml이 있습니다. 태그 <hobbies> 내가이 결과 문서에 그대로 취미 섹션 (<hobbies>1.Playaing Games 2.Watching Movies</hobbies>)을 복사 할 필요가 발생할 때마다특정 블록의 xml 복사하기

<emp> 
     <Name>Rice</Name> 
     <Designation>Operator</Designation> 
     <sal>$2000</sal> 
     <hobbies><description>1.Playaing Games 2.Watching Movies</description></hobbies> 
    </emp> 
    <emp> 
     <Name>Jeff</Name> 
     <Designation>Admin</Designation> 
     <sal>$1000</sal> 
     <hobbies><description>1.Listening Music</description></hobbies> 
    </emp> 

내의 requirment. 하나의 XML에서 다른 xml로 변환하기 위해 xsl을 사용하고 있습니다.

<EmployeeDetails> 
    Rice,Operator,$2000 
    <hobbies><description>1.Playaing Games 2.Watching Movies</description></hobbies> 
    </EmployeeDetails> 
    <EmployeeDetails> 
    Jeff,Admin,$1000 
    <hobbies><description>1.Listening Music</description></hobbies> 
    </EmployeeDetails> 

동일하게 적용 할 수있는 포인터를 제공해주십시오.

답변

0

사용이 템플릿 :

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

    <xsl:template match="emp"> 
     <EmployeeDetails> 
      <xsl:value-of select="concat(Name, ',', Designation, ',', sal)"/> 

      <xsl:copy-of select="hobbies"/> 
     </EmployeeDetails> 
    </xsl:template> 

</xsl:stylesheet> 

출력 :

<EmployeeDetails> 
    Rice,Operator,$2000<hobbies> 
     <description>1.Playaing Games 2.Watching Movies</description> 
    </hobbies> 
</EmployeeDetails> 
<EmployeeDetails> 
    Jeff,Admin,$1000<hobbies> 
     <description>1.Listening Music</description> 
    </hobbies> 
</EmployeeDetails>