xml和xsl专成html表格有关问题
xml和xsl专成html表格问题
P.xml:
<?xml version= "1.0 " encoding= "UTF-8 "?>
<!-- 编辑使用 XMLSpy v2006 U (http://www.altova.com) 由 any (any) -->
<?xml-stylesheet type= "text/xsl " href= "C:\Documents and Settings\leaf\桌面\pro2\P.xsl "?>
<Record_card xmlns= "http://www.worksoft/pro " xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance " xsi:schemaLocation= "http://www.worksoft/pro
P.xsd ">
<Student>
<Name> dog </Name>
<Id> 001 </Id>
<Total> 181 </Total>
<Subject>
<S_name> English </S_name>
<Score> 80 </Score>
</Subject>
<Subject>
<S_name> Math </S_name>
<Score> 10 </Score>
</Subject>
<Subject>
<S_name> Physics </S_name>
<Score> 45 </Score>
</Subject>
<Subject>
<S_name> Politics </S_name>
<Score> 23 </Score>
</Subject>
<Subject>
<S_name> Gym </S_name>
<Score> 23 </Score>
</Subject>
</Student>
</Record_card>
P.xsl:
<?xml version= "1.0 " encoding= "gb2312 "?>
<xsl:stylesheet version= "1.0 " xmlns:xsl= "http://www.w3.org/1999/XSL/Transform " xmlns:fo= "http://www.w3.org/1999/XSL/Format " >
<xsl:output method= "html " encoding= "gb2312 "/>
<xsl:template match= "Report_card ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 "/>
<title> yangzi </title>
</head>
<body>
<h2> 计算机学院2004级2005年第一学期 学生成绩单 </h2>
<table width= "453 " height= "78 " border= "1 " id= "myTable ">
<thead>
<tr bgcolor= "#9acd32 ">
<th> 姓名 </th>
<th> 学号 </th>
<th> 英文 </th>
<th> 数学 </th>
<th> 物理 </th>
<th> 体育 </th>
<th> 政治 </th>
<th> 总分 </th>
</tr>
</thead>
<tbody>
<xsl:for-each select= "./Student ">
<tr>
<td height= "26 ">
<xsl:value-of select= "Id "/> </td>
<td>
<xsl:value-of select= "Name "/>
</td>
<xsl:for-each select= "./Student/Subject ">
<td>
<xsl:value-of select= "Score "/>
</td>
</xsl:for-each>
<td>
<xsl:value-of select= "Total "/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
P.xml:
<?xml version= "1.0 " encoding= "UTF-8 "?>
<!-- 编辑使用 XMLSpy v2006 U (http://www.altova.com) 由 any (any) -->
<?xml-stylesheet type= "text/xsl " href= "C:\Documents and Settings\leaf\桌面\pro2\P.xsl "?>
<Record_card xmlns= "http://www.worksoft/pro " xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance " xsi:schemaLocation= "http://www.worksoft/pro
P.xsd ">
<Student>
<Name> dog </Name>
<Id> 001 </Id>
<Total> 181 </Total>
<Subject>
<S_name> English </S_name>
<Score> 80 </Score>
</Subject>
<Subject>
<S_name> Math </S_name>
<Score> 10 </Score>
</Subject>
<Subject>
<S_name> Physics </S_name>
<Score> 45 </Score>
</Subject>
<Subject>
<S_name> Politics </S_name>
<Score> 23 </Score>
</Subject>
<Subject>
<S_name> Gym </S_name>
<Score> 23 </Score>
</Subject>
</Student>
</Record_card>
P.xsl:
<?xml version= "1.0 " encoding= "gb2312 "?>
<xsl:stylesheet version= "1.0 " xmlns:xsl= "http://www.w3.org/1999/XSL/Transform " xmlns:fo= "http://www.w3.org/1999/XSL/Format " >
<xsl:output method= "html " encoding= "gb2312 "/>
<xsl:template match= "Report_card ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 "/>
<title> yangzi </title>
</head>
<body>
<h2> 计算机学院2004级2005年第一学期 学生成绩单 </h2>
<table width= "453 " height= "78 " border= "1 " id= "myTable ">
<thead>
<tr bgcolor= "#9acd32 ">
<th> 姓名 </th>
<th> 学号 </th>
<th> 英文 </th>
<th> 数学 </th>
<th> 物理 </th>
<th> 体育 </th>
<th> 政治 </th>
<th> 总分 </th>
</tr>
</thead>
<tbody>
<xsl:for-each select= "./Student ">
<tr>
<td height= "26 ">
<xsl:value-of select= "Id "/> </td>
<td>
<xsl:value-of select= "Name "/>
</td>
<xsl:for-each select= "./Student/Subject ">
<td>
<xsl:value-of select= "Score "/>
</td>
</xsl:for-each>
<td>
<xsl:value-of select= "Total "/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>