8,906
社区成员
发帖
与我相关
我的任务
分享
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html><head></head>
<body>
<table width="100%" border="1">
<tbody>
<tr>
<td width="20%">name</td>
<td width="20%">type</td>
<td width="20%">price1</td>
<td width="20%">price2</td>
<td width="20%">price3</td>
</tr>
<xsl:for-each select="products/product">
<tr>
<td width="20%">
<xsl:value-of select="name"/>
</td>
<td width="20%">
<xsl:value-of select="type"/>
</td>
<td width="20%">
<xsl:value-of select="price/data/price1"/>
</td>
<td width="20%">
<xsl:value-of select="price/data/price2"/>
</td>
<td width="20%">
<xsl:value-of select="price/data/price3"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2006. Progress Software Corporation. All rights reserved.-->
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="lab.xsl" ?>
<products>
<product>
<name>牛奶</name>
<type>食品</type>
<price>
<data>
<price1>23</price1>
<price2>30</price2>
<price3>40</price3>
</data>
</price>
</product>
<product>
<name>面包</name>
<type>食品</type>
<price>
<data>
<price1>203 </price1>
<price2>300 </price2>
<price3>440 </price3>
</data>
</price>
</product>
</products>
....
<xsl:template match="/products">
<table>
<tr>
<td>名称</td>
<td>类别</td>
<td>成本价</td>
<td>出厂价</td>
<td>批发价 </td>
</tr>
<xsl:apply-templates select="product"/>
</table>
</xsl:template>
<xsl:template match="product">
<tr>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="type"/>
</td>
<td>
<xsl:value-of select="price/data/price1"/>
</td>
<td>
<xsl:value-of select="price/data/price2"/>
</td>
<td>
<xsl:value-of select="price/data/price3"/>
</td>
</tr>
</xsl:template>
....