2012-03-05 10 views
1

私はこれまでに新しく、さまざまなルートとバリエーションを使用してテーブルにデータを取得しましたが、2次元と3次元のノード属性を取得できません。私は明らかに属性値の選択とテンプレートの使用のどちらかに間違っているのですが、各列の最初の属性の繰り返しを取得するだけです。複数のノード属性を使用するXSL

私のXML入力は次のとおりです。

<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を持っていますディメンションノードをループしないようにします。

<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

以下を試してください。要点は、最初に次元の属性値を選択してから、ステータス属性の値を選択することです。

<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

素晴らしく素晴らしい説明です。 –

関連する問題