XML文件:
1
<?xml version="1.0" encoding="utf-8"?>2
<?xml-stylesheet type='text/xsl' href='XSLTFile1.xslt'?>3
<Order>4
<OrderID>OrderID1</OrderID>5
<OrderDate>OrderDate1</OrderDate>6
<list>7
<ProductID>ProductID1</ProductID>8
<ProductName>ProductName1</ProductName>9
</list>10
<list>11
<ProductID>ProductID2</ProductID>12
<ProductName>ProductName2</ProductName>13
</list>14
<list>15
<ProductID>ProductID3</ProductID>16
<ProductName>ProductName3</ProductName>17
</list>18
<list>19
<ProductID>ProductID4</ProductID>20
<ProductName>ProductName4</ProductName>21
</list>22
</Order>xslt文件:
1
<?xml version="1.0" encoding="UTF-8" ?>2
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">3
<xsl:template match ="Order">4
<html dir="">5
<head>6
<title>7
8
</title>9
<body>10
<table width="100%" border="0">11
<tr>12
<td colspan="6">13
<div align="center">公司名称入库单</div>14
</td>15
</tr>16
<tr>17
<td colspan="6">18
<div align="right"></div>19
</td>20
</tr>21
<tr>22
<td width="130">供应商编号:</td>23
<td width="126">24
</td>25
<td width="100">订单号:</td>26
<td width="97">27
<xsl:value-of select ="OrderID"/>28
</td>29
<td width="110">订单日期:</td>30
<td width="110">31
<xsl:value-of select ="OrderDate"/>32
</td>33
</tr>34
<tr>35
<td colspan="6">36
<table width="100%" border="0">37
<tr>38
<td>产品号</td>39
<td>商品名称</td>40
</tr>41
<xsl:apply-templates select ="list"/>42
</table>43
</td>44
</tr>45
</table>46
</body>47
</head>48
</html>49
</xsl:template>50
<xsl:template match="list">51
<tr>52
<td>53
<xsl:value-of select ="ProductID"/>54
</td>55
<td>56
<xsl:value-of select ="ProductName"/>57
</td>58
</tr>59
</xsl:template>60
</xsl:stylesheet>里面的Html元素看起来不太爽。注意41行apply-templates和50行<xsl:template match="list">就比较清楚了。
发觉这个用在打印报表上不错的,如果有图表的话就不行了。