次のようなテーブル構造があります。
| ID | 名前 | 親ID | 
|---|---|---|
| 1 | root_category | ヌル | 
| 2 | あっぱれ | 1 | 
| 3 | 付属品 | 1 | 
| 4 | シャツ | 2 | 
| 5 | パンツ | 2 | 
| 6 | ハンドバッグ | 3 | 
| 7 | ジュエリー | 3 | 
このテーブルから、このtest.xmlのようなXMLファイルを作成しました
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<childrens>
  <child id="1" value="Root Catalog" parent_id="0">
    <child id="2" value="Apparel" parent_id="1">
      <child id="4" value="Shirts" parent_id="2"/>
      <child id="5" value="Pants" parent_id="2"/>
    </child>
    <child id="3" value="Accessories" parent_id="1">
      <child id="6" value="Handbags" parent_id="3"/>
      <child id="7" value="Jewelry" parent_id="3"/>
    </child>
  </child>
</childrens>
このxmlファイルを使用して、このtest.xslのようなXSLファイルを作成しました
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Testing</h2>
  <table border="1">
   <tr bgcolor="#9acd32">
    <th>Id </th>
    <th>Name</th>
  </tr>
  <xsl:for-each select="childrens/child">
  <tr>
    <td><xsl:value-of select="@id"/></td>
    <td><xsl:value-of select="@value"/></td>
  </tr>
  </xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
しかし、それは機能しておらず、データが表示されていません
データは次のようになります
Root Category
 - Apparel 
   -- Shirts
   -- Pants 
 - Accessories
   -- Handbags 
  -- Jewelry