我有 xml 文件,它是
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="test1.xsl"?>
<products>
<node>
<node>
<dist_value>
<node> 55 </node>
<node> 59 </node>
<node> 72 </node>
</dist_value>
<reg_str_dt>
<node> 2013-08-03 17:29:00 </node>
</reg_str_dt>
<product_id> 1 </product_id>
</node>
</node>
<node>
<node>
<dist_value>
<node> 72 </node>
<node> 19 </node>
<node> 49 </node>
</dist_value>
<reg_str_dt>
<node> 2013-10-25 17:29:00 </node>
</reg_str_dt>
<product_id> 2 </product_id>
</node>
</node>
<node>
<node>
<dist_value>
<node> 12 </node>
<node> 548 </node>
<node> 112 </node>
</dist_value>
<reg_str_dt>
<node> 2013-08-12 17:29:00 </node>
</reg_str_dt>
<name> test </name>
<product_id> 3 </product_id>
</node>
</node>
</products>
我已经编写了这个 xslt 来显示产品的所有数据,其中dist_value\node < 50
将给出产品的输出数据2 & 3
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<html>
<body>
<table border="1">
<tr><th>Product ID</th><th>Product DATA</th></tr>
<xsl:apply-templates select="products/node/node" />
</table>
</body>
</html>
</xsl:template>
<xsl:template match="products/node/node/dist_value[node < 50]">
<tr>
<td><xsl:value-of select="//product_id" /></td>
<td><xsl:value-of select="products/node/node/*" /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
我是 xslt 的初学者,这里有些问题
我想输出这样的东西
Product ID | Product DATA
--------------------------------
2 |dist_value => 72
| 19
| 79
|reg_str_dt => 2013-10-25 17:29:00
|product_id => 2
产品 3 包含名称