2017-03-16 1 views
0

XML 문서에서 다음 출력을 보여 드리고 싶지만 어떻게해야할지 모르겠습니다. 누군가 제발 도와 드릴까요?XML에서 다음을 어떻게 출력합니까?

원하는 출력 :

<?xml version="1.0" encoding="UTF-8"?> 
<Integration> 
    <ProtectionOrderStatus> 
     <ProtectionOrderStatusCode>DELETED</ext:ProtectionOrderStatusCode> 
    </ProtectionOrderStatus> 
</Integration> 

XML 문서 :

<?xml version="1.0" encoding="UTF-8"?> 
<Integration> 
    <ProtectionOrder> 
     <Deleted>true</Deleted> 
     <ProtectionOrderNumber>12</ProtectionOrderNumber> 
     <Statuses> 
      <Status> 
       <Current>true</Current> 
       <Active>Yes</Active> 
       <Date>03/16/2017</Date> 
       <Type Word="SBJO">Signed By Judicial Officer</Type> 
      </Status> 
     </Statuses> 
    </ProtectionOrder> 
</Integration> 

답변

1

내가 당신의 처리 언어가 무엇인지 모른다.

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

    <xsl:template match="/Integration"> 
     <Integration> 
     <xsl:apply-templates /> 
     </Integration> 
    </xsl:template> 

    <xsl:template match="ProtectionOrder[Deleted = 'true']"> 
     <ProtectionOrderStatus> 
     <ProtectionOrderStatusCode>DELETED</ProtectionOrderStatusCode> 
     </ProtectionOrderStatus> 
    </xsl:template> 

</xsl:stylesheet> 

출력은 다음과 같습니다 :

<?xml version="1.0"?> 
<Integration> 
    <ProtectionOrderStatus> 
     <ProtectionOrderStatusCode>DELETED</ProtectionOrderStatusCode> 
    </ProtectionOrderStatus> 
</Integration> 

이 코드는이있는 소스 XML의 각 <ProtectionOrder> 요소에 대한 ProtectionOrderStatus 요소를 생성
그래서 난 그냥이 달성의 XSLT - 1.0 방법을 제공합니다 과 같은 값인 text() 값을 가진 하위 요소.

관련 문제