8,906
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2013 (http://www.altova.com) by () -->
<Students xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Students.xsd">
<Student Id="14001" Class="软工1401">
<Name>张三</Name>
<Sex>男</Sex>
<Birth>1995-05-01</Birth>
<City>上海</City>
<Mobile>18980018001</Mobile>
</Student>
<Student Id="14002" Class="软工1401">
<Name>李四</Name>
<Sex>女</Sex>
<Birth>1995-08-01</Birth>
<City>北京</City>
<Mobile>18980028002</Mobile>
</Student>
</Students>
<html>
<head>
<title>Students Information in Students.xml文件</title>
</head>
<body>
<xml id="dso" src="Students.xml"/>
<h1>学生列表</h1>
<button onclick="mytable.firstPage()">首页</button>
<button onclick="mytable.previousPage()">上页</button>
<button onclick="mytable.nextPage()">下页</button>
<button onclick="mytable.lastPage()">尾页</button>
<p/>
<table id="mytable" datasrc="#dso" datapagesize="2" border="1" cellpadding="5">
<thead>
<th>ID</th>
<th>Class</th>
<th>Name</th>
<th>Birth</th>
<th>City</th>
<th>Mobile</th>
</thead>
<tr align="center">
<td><span datafld="Id" style="font-style:italic"></span></td>
<td><span datafld="Class"></span></td>
<td><span datafld="Name"></span></td>
<td><span datafld="Birth"></span></td>
<td><span datafld="City"></span></td>
<td><span datafld="Mobile"></span></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="GB2312"?>
<Students xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Students.xsd">
<Student Id="14001" Class="软工1401">
<Name>张三</Name>
<Sex>男</Sex>
<Birth>1995-05-01</Birth>
<City>上海</City>
<Mobile>18980018001</Mobile>
</Student>
<Student Id="14002" Class="软工1401">
<Name>李四</Name>
<Sex>女</Sex>
<Birth>1995-08-01</Birth>
<City>北京</City>
<Mobile>18980028002</Mobile>
</Student>
</Students>
Students.xslt
<?xml version="1.0" encoding="GB2312" standalone="yes"?>
<?xml-stylesheet href="Students.xslt" type="text/xsl"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="source" select="document('Students.xml')/Students/Student"/>
<html>
<head>
<title>Students Information in Students.xml</title>
</head>
<body>
<xml id="dso" src="Students.xml"/>
<h1>学生列表</h1>
<button onclick="mytable.firstPage()">首页</button>
<button onclick="mytable.previousPage()">上页</button>
<button onclick="mytable.nextPage()">下页</button>
<button onclick="mytable.lastPage()">尾页</button>
<p/>
<table id="mytable" datasrc="#dso" datapagesize="2" border="1" cellpadding="5">
<thead>
<th>ID</th>
<th>Class</th>
<th>Name</th>
<th>Birth</th>
<th>City</th>
<th>Mobile</th>
</thead>
<xsl:for-each select="$source">
<tr align="center">
<td><span datafld="Id" style="font-style:italic">
<xsl:value-of select="@Id"/>
</span></td>
<td><span datafld="Class">
<xsl:value-of select="@Class"/>
</span></td>
<td><span datafld="Name">
<xsl:value-of select="Name"/>
</span></td>
<td><span datafld="Birth">
<xsl:value-of select="Birth"/>
</span></td>
<td><span datafld="City">
<xsl:value-of select="City"/>
</span></td>
<td><span datafld="Mobile">
<xsl:value-of select="Mobile"/>
</span></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>