【发布时间】:2010-01-07 09:44:27
【问题描述】:
以这种格式使用 XML:
<?xml version="1.0"?>
<GetResult version="1.0">
<Fetch>
<StartTime>2004-08-01 00:00:00</StartTime>
<EndTime>2004-08-01 00:00:00</EndTime>
</Fetch>
<Items>
<Item>
<Name>Item Name Number 1</Name>
<Data>
<Datum>
<Timestamp>2004-07-31 16:00:00+00:00</Timestamp>
<Value><![CDATA[25]]></Value>
</Datum>
<Datum>
<Timestamp>2004-07-31 18:00:00+00:00</Timestamp>
<Value><![CDATA[35]]></Value>
</Datum>
</Data>
</Item>
<Item>
<Name>Item Number 2</Name>
<Data>
<Datum>
<Timestamp>2004-07-31 16:00:00+00:00</Timestamp>
<Value><![CDATA[45]]></Value>
</Datum>
<Datum>
<Timestamp>2004-07-31 17:00:00+00:00</Timestamp>
<Value><![CDATA[55]]></Value>
</Datum>
<Datum>
<Timestamp>2004-07-31 18:00:00+00:00</Timestamp>
<Value><![CDATA[65]]></Value>
</Datum>
</Data>
</Item>
</Items>
</GetResult>
我希望能够使用 XSLT 生成这样的表格:
<table>
<tr>
<th>Timestamp</th>
<th>Item Name Number 1</th>
<th>Item Number 2</th>
</tr>
<tr>
<td>2004-07-31 16:00:00+00:00</td>
<td>25</td>
<td>45</td>
</tr>
<tr>
<td>2004-07-31 17:00:00+00:00</td>
<td></td>
<td>55</td>
</tr>
<tr>
<td>2004-07-31 18:00:00+00:00</td>
<td>35</td>
<td>65</td>
</tr>
</table>
无论返回多少项目以及每个项目下有多少基准,这都必须工作。我已经阅读了一些其他类似的答案,但没有任何运气。我对 XSLT 相当陌生,它让我发疯。对此的解决方案将不胜感激。
【问题讨论】:
-
指定 XSLT 的版本?