+ -
当前位置:首页 → 问答吧 → 用XSL排版的一个问题

用XSL排版的一个问题

时间:2010-06-15

来源:互联网

<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
  <HTML>
  <HEAD><TITLE>成绩表</TITLE></HEAD>
  <BODY> <xsl:apply-templates select="成绩表/成绩"/> </BODY>
  </HTML>
</xsl:template> 
  <xsl:template match="成绩">
  <TABLE border="1" cellspacing="0">
  <TD>姓名</TD><TD><xsl:apply-templates select="姓名"/></TD>
  <TR><TD>语文</TD><TD><xsl:apply-templates select="语文"/></TD></TR>
  <TR><TD>数学</TD><TD><xsl:apply-templates select="数学"/></TD></TR>
  <TD>英语</TD><TD><xsl:apply-templates select="英语"/></TD>
  </TABLE>
  </xsl:template>
  
<xsl:template match="姓名">
<TD><xsl:value-of/></TD>
</xsl:template>

<xsl:template match="语文">
<TD><xsl:value-of/></TD>
</xsl:template>

<xsl:template match="数学">
<TD><xsl:value-of/></TD>
</xsl:template>

<xsl:template match="英语">
<TD><xsl:value-of/></TD>
</xsl:template>

 <!--<xsl:template match="姓名"><xsl:value-of/></xsl:template>
  <xsl:template match="语文|数学|英语">
  <xsl:choose>
  <xsl:when test=".[value()$ge$90]">优秀</xsl:when>
  <xsl:when test=".[value()$ge$80]">良好</xsl:when>
  <xsl:when test=".[value()$ge$70]">中等</xsl:when>
  <xsl:when test=".[value()$ge$60]">及格</xsl:when>
  <xsl:otherwise>不及格</xsl:otherwise>
  </xsl:choose>
  </xsl:template>-->
</xsl:stylesheet> 
若使用XSL排列成以下的表格是非常容易的事﹐也是大部分的范例样式
姓名 数学 语文 英语
那么如果xml档案格式不变之下﹐我想利用xsl样式将数据排列如下 
姓名 1 2 3
数学 1 2 3
语文 1 2 3
英语 1 2 3
请问该怎么改?

作者: chentienran   发布时间: 2010-06-15

把其中的红色增加,试看...

  <xsl:template match="成绩">
  <TABLE border="1" cellspacing="0">
  <TR><TD>姓名</TD><TD><xsl:apply-templates select="姓名"/></TD></TR>
  <TR><TD>语文</TD><TD><xsl:apply-templates select="语文"/></TD></TR>
  <TR><TD>数学</TD><TD><xsl:apply-templates select="数学"/></TD></TR>
  <TR><TD>英语</TD><TD><xsl:apply-templates select="英语"/></TD></TR>
  </TABLE>
  </xsl:template>

作者: shenzhenNBA   发布时间: 2010-06-15

不是这里的问题

作者: chentienran   发布时间: 2010-06-15

麻烦各位高手教教小弟

作者: chentienran   发布时间: 2010-06-15

<xsl:template match="/">
<html>
<head>
<title></title>
</head>
<body>
<table>
<tr>
<th>姓名</th>
<th>语文</th>
<th>数学</th>
<th>英语</th>
</tr>
<xsl:for-each select="成绩">
<tr>
<th><xsl:value-of select=""/></th>
<th><xsl:value-of select=""/></th>
<th><xsl:value-of select=""/></th>
<th><xsl:value-of select=""/></th>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

作者: my0510520   发布时间: 2010-07-29