2012-05-25 3 views
0

아버지 요소 당 노드를 그룹화하고 싶습니다.아버지 요소 당 노드를 그룹화하는 방법 (XSLT)

여기에 아버지 소자입니다 FDDCell 자료 = "AAA"METHOD = 아버지 요소가 두 번 반복

  • "수정".

  • "FDDCell id"를 한 번만 표시하고 싶습니다. 당신을 위해 너무 많은

    <?xml version="1.0" encoding="UTF-8"?> 
    <start> 
    
    <FDDCell id="AAA" method="modify"> 
        <UMTSFddNeighbouringCell id="FAR_AWAY" method="create"> 
        <attributes> 
         <mbmsNeighbouringWeight>0.0</mbmsNeighbouringWeight> 
        </attributes> 
    </UMTSFddNeighbouringCell> 
    
    <attributes> 
        <cacConfId>RadioAccessService/0 DedicatedConf/0 CacConfClass/10</cacConfId> 
        <layerPreferredForR99>true</layerPreferredForR99> 
        <reserved0>1398341632</reserved0> 
        <reserved1>1398352896</reserved1> 
        <reserved2>1616994144</reserved2> 
        <reserved3>1616994144</reserved3> 
    </attributes> 
    
    </FDDCell> 
    </start> 
    

    감사 : 여기

    <?xml version="1.0" encoding="UTF-8"?> 
    <start> 
    
    <FDDCell id="AAA" method="modify"> 
    <UMTSFddNeighbouringCell id="FAR_AWAY" method="create"> 
        <attributes> 
         <mbmsNeighbouringWeight>0.0</mbmsNeighbouringWeight> 
        </attributes> 
    </UMTSFddNeighbouringCell> 
    </FDDCell> 
    
    <FDDCell id="AAA" method="modify"> 
    <attributes> 
        <cacConfId>RadioAccessService/0 DedicatedConf/0 CacConfClass/10</cacConfId> 
        <layerPreferredForR99>true</layerPreferredForR99> 
        <reserved0>1398341632</reserved0> 
        <reserved1>1398352896</reserved1> 
        <reserved2>1616994144</reserved2> 
        <reserved3>1616994144</reserved3> 
    </attributes> 
    </FDDCell> 
    
    </start> 
    

    원하는 출력 파일입니다 및 "FDDCell ID가"아래 그룹의 모든 노드가 여기에

은 XML 입력 파일입니다 지원

답변

1

다음은 XSLT 2.0 스타일 시트입니다.

<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    exclude-result-prefixes="xs" 
    version="2.0"> 

    <xsl:output indent="yes"/> 
    <xsl:strip-space elements="*"/> 

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

    <xsl:template match="start"> 
    <xsl:copy> 
     <xsl:for-each-group select="FDDCell" group-by="@id"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*, current-group()/node()"/> 
     </xsl:copy> 
     </xsl:for-each-group> 
    </xsl:copy> 
    </xsl:template> 

</xsl:stylesheet> 

Saxon 9, AltovaXML 도구, XMLPrime과 같은 XSLT 2.0 프로세서로 실행할 수 있습니다.

+0

작동합니다! 감사 !!!! – laurentngu