【发布时间】:2014-06-26 02:31:24
【问题描述】:
这里是我的 XML 的一部分,表示术语的层次结构。 TopTerm 是最外层的 parent, ChildTerm 是 child,它可以有尽可能多的孩子。
<TopTerm ID="1" Entity="Term" Name="ENVIRONMENTAL MANAGEMENT">
<ChildTerm Relationship="narrower" ID="8" Entity="Term" Name="Auditing">
<ChildTerm Relationship="narrower" ID="36" Entity="Term" Name="Environmental audit" />
<ChildTerm Relationship="narrower" ID="46" Entity="Term" Name="Type of audit []" />
</ChildTerm>
<ChildTerm Relationship="narrower" ID="11" Entity="Term" Name="Incidents">
<ChildTerm Relationship="narrower" ID="71" Entity="Term" Name="Bruce Beresford" />
<ChildTerm Relationship="narrower" ID="35" Entity="Term" Name="Case name" />
<ChildTerm Relationship="narrower" ID="83" Entity="Term" Name="Jack Lemmon" />
<ChildTerm Relationship="narrower" ID="87" Entity="Term" Name="Mary Pcikford" />
</ChildTerm>
<ChildTerm Relationship="narrower" ID="16" Entity="Term" Name="Monitoring" />
<ChildTerm Relationship="narrower" ID="18" Entity="Term" Name="Policies and procedures" />
</TopTerm>
我想要一个带有表格的 XSLT 1.0 HTML 输出,结果应该是这样的
<table>
<tr>
<th>Level 1</th>
<th>Level 2</th>
<th>Level 3</th>
<th>Level 4</th>
</tr>
<tr>
<td>ENVIRONMENTAL MANAGEMENT</td>
<td>Auditing</td>
<td>Environmental audit</td>
</tr>
</table>
类似的东西。我的问题是我不知道这个层次结构的深度来添加适当的<th>Level x</th>,其中 x 可以是任何基于深度的数字。并且术语级别应该与表格标题匹配。
【问题讨论】:
-
你能把你尝试过的 XSLT 贴出来吗?
-
我还没有尝试过任何东西,因为我不知道从哪里开始
标签: xml xslt html-table