《report.xml文件》
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet type="text/xsl" href="report.xsl"?>
<document>
<report>
<class>
甲班
</class>
<q1> 50 </q1>
<q2> 70 </q2>
<q3> 30 </q3>
<q4> 10 </q4>
</report>
<report>
<class>
乙班
</class>
<q1> 20 </q1>
<q2> 30 </q2>
<q3> 40 </q3> 数据挖掘研究院
<q4> 50 </q4>
</report>
<report>
<class>
丙班
</class>
<q1> 70 </q1>
<q2> 40 </q2>
<q3> 20 </q3>
<q4> 10 </q4>
</report>
</document> 《xsl转换文件》
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head> 数据挖掘实验室
<title> 1999年生产统计 </title>
</head>
<body>
<xsl:apply-templates select="document"/>
</body>
</html>
</xsl:template>
<xsl:template match="document">
<h3> 1999年生产统计 </h3>
<table border="1" cellspacing="0">
<th> 班组 </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<xsl:apply-templates select="report"/>
</table>
</xsl:template>
<xsl:template match="report">
<tr>
<td>
<xsl:value-of select="class"/>
</td>
<td>
<xsl:apply-templates select="q1"/>
</td>
<td> 数据挖掘研究院
<xsl:apply-templates select="q2"/>
</td>
<td>
<xsl:apply-templates select="q3"/>
</td>
<td>
<xsl:apply-templates select="q4"/>
</td>
</tr>
</xsl:template>
<xsl:template match="q1 ¦q2 ¦q3 ¦q4">
<!--此处测试产量,如小于等于20则添加一STYLE属性color,其值为red(红色)--> 数据挖掘研究院
<xsl:if test="[value() $le$ 20]">
<xsl:attribute name="style"> color:red </xsl:attribute>
</xsl:if>
</xsl:template>
<xsl:template match="report">
<TR>
<TD>
</TD>
<TD>
<xsl:eval>
total(this,"q1")
</xsl:eval>
</TD> 数据挖掘实验室
<TD>
<xsl:eval>
total(this,"q2")
</xsl:eval>
</TD>
<TD>
<xsl:eval>
total(this,"q3")
</xsl:eval>
</TD >
<TD>
<xsl:eval>
total(this,"q4")
</xsl:eval>
</TD>
</TR>
</xsl:template>
<xsl:javascript>
function total(node,q)
{
temp = 0;
mark = '/document/report/' + q;
v = node.selectNodes(mark);
for( t = v.nextNode(); t ; t = v.nextNode())
{
temp += Number(t.text);
}
return temp;
}
</xsl:javascript>
</xsl:stylesheet> 运行看不到结果,向各位高手请教!你的目的是?想 通过,xsl 格式化输出,rss文件,并且给其中的每条信息,写入javascript脚本参数,然后在程序中打开,这样我就能知道我到底是选择与读了那条新闻,qq:383585946这个例子是学习,试验这种方法,的可行性

