2012-03-05 4 views
1

나는이 모든 기능에 익숙하며 다양한 경로와 변형을 사용하여 테이블에 데이터를 가져 왔지만 두 번째 및 세 번째 차원 노드 속성을 가져올 수 없습니다. 분명히 각 열의 첫 번째 특성을 반복 할 때 속성 값 선택 또는 템플릿 사용에 문제가 있습니다.다중 노드 속성을 사용하는 XSL

<nodes> 
    <node name="Server Dashboard"> 
    <children> 
     <node name="Server Dashboard"> 
     <dimension name="Performance" status="20" id="10" >null</dimension> 
     <dimension name="System" status="10" id="20" >null</dimension> 
     <dimension name="Availability" status="30" id="30" >null</dimension> 
     <children> 
      <node name="SERVER 1"> 
      <dimension name="Performance" status="20" id="10" >null</dimension> 
      <dimension name="System" status="10" id="20" >null</dimension> 
      <dimension name="Availability" status="30" id="30" >null</dimension> 
      <children> 
      </children> 
      </node> 
      <node name="SERVER 2"> 
      <dimension name="Performance" status="20" id="10" >null</dimension> 
      <dimension name="System" status="10" id="20" >null</dimension> 
      <dimension name="Availability" status="30" id="30" >null</dimension> 
      <children> 
      </children> 
      </node> 
     </children> 
     </node> 
    </children> 
    </node> 
</nodes> 

그리고

<html> 
    <body> 
    <table border="1"> 
     <th>System</th> 
     <th>Performance</th> 
     <th>Status</th> 
     <th>Availability</th> 
    </tr> 
    <tr> 
     <td>SERVER 1</td> 
     <td>20</td> 
     <td>10</td> 
     <td>30</td> 
    </tr> 
    <tr> 
     <td>SERVER 2</td> 
     <td>20</td> 
     <td>10</td> 
     <td>30</td> 
    </tr> 
    </table> 
</body> 
</html> 

같은 출력을 얻기 위해 노력하고 있어요 그리고 그것은 보인다 현재 나는 거의 확실히 존재하지만 저를 얻을 수있는의 XSL이 있습니다

내 XML 입력입니다 차원 노드를 루프하지 않습니다.

<xsl:template match="/"> 
<html> 
    <body> 
    <table border="1"> 
     <th>System</th> 
     <th>Performance</th> 
     <th>Status</th> 
     <th>Availability</th> 
     </tr> 
     <xsl:for-each select="nodes/node/children/node/children/node"> 
     <tr> 
     <td><xsl:value-of select="@name"/></td> 
     <td><xsl:value-of select="dimension/@Status[//@id='10']"/></td> 
     <td><xsl:value-of select="dimension/@status[//@id='20']"/></td> 
     <td><xsl:value-of select="dimension/@status[//@id='30']"/></td> 
     </tr> 
     </xsl:for-each> 
    </table> 
    </body> 
    </html> 
</xsl:template> 

최종적인 목표는 상태 번호를 유색 셀 또는 .gif로 바꾸는 것입니다.하지만 순간 아기 단계가 있습니다. 감사의 마음을 보여 주는 모든 도움.

답변

1

다음을 시도해보십시오. 요점은 먼저 ID 속성 값으로 차원을 선택한 다음 상태 속성 값을 선택하는 것입니다.

<xsl:template match="/"> 
    <html> 
     <body> 
      <table border="1"> 
      <tr> 
       <th>System</th> 
       <th>Performance</th> 
       <th>Status</th> 
       <th>Availability</th> 
      </tr> 
      <xsl:for-each select="nodes/node/children/node/children/node"> 
      <tr> 
       <td><xsl:value-of select="@name"/></td> 
       <td><xsl:value-of select="dimension[@id='10']/@status"/></td> 
       <td><xsl:value-of select="dimension[@id='20']/@status"/></td> 
       <td><xsl:value-of select="dimension[@id='30']/@status"/></td> 
      </tr> 
      </xsl:for-each> 
      </table> 
     </body> 
     </html> 
</xsl:template> 
+0

경이롭고 훌륭한 설명입니다. –