level 1
武鬼冰圣
楼主
xsl文件:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:e="http://www.ambow.com">
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css"/>
<style type="text/css">
span.highlight
{
background-color:yellow
}
span.lowlight
{
background-color:blue
}
</style>
</head>
<body>
<table border="1" align="center">
<tr>
<th co
lsp
an="8">
图书列表
</th>
</tr>
<tr>
<th>
<span class="highlight">
书名
</span>
</th>
<th>
<span class="highlight">
作者
</span>
</th>
<th>
<span class="highlight">
价格
</span>
</th>
<th>
<span class="highlight">
出版社
</span>
</th>
<th>
<span class="highlight">
出版日期
</span>
</th>
<th>
<span class="highlight">
出版号
</span>
</th>
<th>
<span class="highlight">
种类
</span>
</th>
<th>
<span class="highlight">
类别
</span>
</th>
</tr>
<xsl:for-each select="e:图书列表/e:书籍">
<xsl:sort select="e:价格" order="ascending"></xsl:sort>
<xsl:if test="@种类='计算机类'">
<tr>
<td>
<xsl:value-of select="e:书名"/>
</td>
<td>
<xsl:value-of select="e:作者"/>
</td>
<xsl:choose>
<xsl:when test="e:价格 > 100">
<td class="lowhight">
<xsl:value-of select="e:价格"/>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="e:价格"/>
</td>
</xsl:otherwise>
</xsl:choose>
<td>
<xsl:value-of select="e:出版社"/>
</td>
<td>
<xsl:value-of select="e:出版日期"/>
</td>
<td>
<xsl:value-of select="e:出版号"/>
</td>
<td bgcolor="green">
<xsl:value-of select="e:种类"/>
</td>
<td bgcolor="blue">
<xsl:value-of select="e:类别"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="e:bookList/e:book">
<xsl:sort select="e:price" order="ascending"></xsl:sort>
<xsl:if test="@种类='社科类'">
<tr>
<td>
<xsl:value-of select="e:书名"></xsl:value-of>
</td>
<td>
<xsl:value-of select="e:作者"/>
</td>
<xsl:choose>
<xsl:when test="e:价格 > 100">
<td class="lowhight">
<xsl:value-of select="e:价格"/>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="e:价格"/>
</td>
</xsl:otherwise>
</xsl:choose>
<td>
<xsl:value-of select="e:出版社"/>
</td>
<td>
<xsl:value-of select="e:出版日期"/>
</td>
<td>
<xsl:value-of select="e:出版号"/>
</td>
<td bgcolor="green">
<xsl:value-of select="e:种类"/>
</td>
<td bgcolor="blue">
<xsl:value-of select="e:类别"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML文件:
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="book.xsl"?>
<书籍列表 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.ambow.com"
xsi:schemaLoction="http://www.ambow.com text.xsd">
<书籍>
<书名>c++</书名>
<作者></作者>
<价格>20.00</价格>
<出版社>新华出版社</出版社>
<出版日期>2006-4-12</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>编程</类别>
</书籍>
<书籍>
<书名>Java</书名>
<作者></作者>
<价格>60.50</价格>
<出版社>2013-5-22</出版社>
<出版日期>邮电出版社</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>编程</类别>
</书籍>
<书籍>
<书名>积木围城</书名>
<作者>小狮</作者>
<价格>32.80</价格>
<出版社>花火出版社</出版社>
<出版日期>2013-6-4</出版日期>
<出版号></出版号>
<种类>社科类</种类>
<类别>言情小说</类别>
</书籍>
<书籍>
<书名>山海图~转世少女</书名>
<作者>咖啡杯里的茶</作者>
<价格>15.20</价格>
<出版社>天使文学出版社</出版社>
<出版日期>2011-8-12</出版日期>
<出版号></出版号>
<种类>社科类</种类>
<类别>玄幻</类别>
</书籍>
<书籍>
<书名>大主宰</书名>
<作者>天蚕土豆</作者>
<价格>23.60</价格>
<出版社>网络出版社</出版社>
<出版日期>2014-1-15</出版日期>
<出版号></出版号>
<种类>社科类</种类>
<类别>玄幻</类别>
</书籍>
<书籍>
<书名>C语言程序设计</书名>
<作者></作者>
<价格>60.00</价格>
<出版社>商务出版社</出版社>
<出版日期>2005-12-18</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>编程</类别>
</书籍>
<书籍>
<书名>电脑入门基础教程</书名>
<作者></作者>
<价格>50.20</价格>
<出版社>清华大学出版社</出版社>
<出版日期>2003-12-6</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>入门教程</类别>
</书籍>
<书籍>
<书名>编译原理</书名>
<作者>Monica S.Lam</作者>
<价格>80.60</价格>
<出版社>中华书局</出版社>
<出版日期>2001-1-1</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>编译教程</类别>
</书籍>
<书籍>
<书名>代码整洁之道</书名>
<作者>马丁</作者>
<价格>26.00</价格>
<出版社>高等教育出版社</出版社>
<出版日期>2003-8-19</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>代码编写</类别>
</书籍>
<书籍>
<书名>倾城之恋</书名>
<作者>张爱玲</作者>
<价格>59.00</价格>
<出版社>人民出版社</出版社>
<出版日期>1943-12-6</出版日期>
<出版号></出版号>
<种类>社科类</种类>
<类别>爱情短片小说</类别>
</书籍>
</书籍列表>
显示:

2014年11月22日 15点11分
1
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:e="http://www.ambow.com">
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css"/>
<style type="text/css">
span.highlight
{
background-color:yellow
}
span.lowlight
{
background-color:blue
}
</style>
</head>
<body>
<table border="1" align="center">
<tr>
<th co
lsp
an="8">
图书列表
</th>
</tr>
<tr>
<th>
<span class="highlight">
书名
</span>
</th>
<th>
<span class="highlight">
作者
</span>
</th>
<th>
<span class="highlight">
价格
</span>
</th>
<th>
<span class="highlight">
出版社
</span>
</th>
<th>
<span class="highlight">
出版日期
</span>
</th>
<th>
<span class="highlight">
出版号
</span>
</th>
<th>
<span class="highlight">
种类
</span>
</th>
<th>
<span class="highlight">
类别
</span>
</th>
</tr>
<xsl:for-each select="e:图书列表/e:书籍">
<xsl:sort select="e:价格" order="ascending"></xsl:sort>
<xsl:if test="@种类='计算机类'">
<tr>
<td>
<xsl:value-of select="e:书名"/>
</td>
<td>
<xsl:value-of select="e:作者"/>
</td>
<xsl:choose>
<xsl:when test="e:价格 > 100">
<td class="lowhight">
<xsl:value-of select="e:价格"/>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="e:价格"/>
</td>
</xsl:otherwise>
</xsl:choose>
<td>
<xsl:value-of select="e:出版社"/>
</td>
<td>
<xsl:value-of select="e:出版日期"/>
</td>
<td>
<xsl:value-of select="e:出版号"/>
</td>
<td bgcolor="green">
<xsl:value-of select="e:种类"/>
</td>
<td bgcolor="blue">
<xsl:value-of select="e:类别"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="e:bookList/e:book">
<xsl:sort select="e:price" order="ascending"></xsl:sort>
<xsl:if test="@种类='社科类'">
<tr>
<td>
<xsl:value-of select="e:书名"></xsl:value-of>
</td>
<td>
<xsl:value-of select="e:作者"/>
</td>
<xsl:choose>
<xsl:when test="e:价格 > 100">
<td class="lowhight">
<xsl:value-of select="e:价格"/>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="e:价格"/>
</td>
</xsl:otherwise>
</xsl:choose>
<td>
<xsl:value-of select="e:出版社"/>
</td>
<td>
<xsl:value-of select="e:出版日期"/>
</td>
<td>
<xsl:value-of select="e:出版号"/>
</td>
<td bgcolor="green">
<xsl:value-of select="e:种类"/>
</td>
<td bgcolor="blue">
<xsl:value-of select="e:类别"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML文件:
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="book.xsl"?>
<书籍列表 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.ambow.com"
xsi:schemaLoction="http://www.ambow.com text.xsd">
<书籍>
<书名>c++</书名>
<作者></作者>
<价格>20.00</价格>
<出版社>新华出版社</出版社>
<出版日期>2006-4-12</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>编程</类别>
</书籍>
<书籍>
<书名>Java</书名>
<作者></作者>
<价格>60.50</价格>
<出版社>2013-5-22</出版社>
<出版日期>邮电出版社</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>编程</类别>
</书籍>
<书籍>
<书名>积木围城</书名>
<作者>小狮</作者>
<价格>32.80</价格>
<出版社>花火出版社</出版社>
<出版日期>2013-6-4</出版日期>
<出版号></出版号>
<种类>社科类</种类>
<类别>言情小说</类别>
</书籍>
<书籍>
<书名>山海图~转世少女</书名>
<作者>咖啡杯里的茶</作者>
<价格>15.20</价格>
<出版社>天使文学出版社</出版社>
<出版日期>2011-8-12</出版日期>
<出版号></出版号>
<种类>社科类</种类>
<类别>玄幻</类别>
</书籍>
<书籍>
<书名>大主宰</书名>
<作者>天蚕土豆</作者>
<价格>23.60</价格>
<出版社>网络出版社</出版社>
<出版日期>2014-1-15</出版日期>
<出版号></出版号>
<种类>社科类</种类>
<类别>玄幻</类别>
</书籍>
<书籍>
<书名>C语言程序设计</书名>
<作者></作者>
<价格>60.00</价格>
<出版社>商务出版社</出版社>
<出版日期>2005-12-18</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>编程</类别>
</书籍>
<书籍>
<书名>电脑入门基础教程</书名>
<作者></作者>
<价格>50.20</价格>
<出版社>清华大学出版社</出版社>
<出版日期>2003-12-6</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>入门教程</类别>
</书籍>
<书籍>
<书名>编译原理</书名>
<作者>Monica S.Lam</作者>
<价格>80.60</价格>
<出版社>中华书局</出版社>
<出版日期>2001-1-1</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>编译教程</类别>
</书籍>
<书籍>
<书名>代码整洁之道</书名>
<作者>马丁</作者>
<价格>26.00</价格>
<出版社>高等教育出版社</出版社>
<出版日期>2003-8-19</出版日期>
<出版号></出版号>
<种类>计算机类</种类>
<类别>代码编写</类别>
</书籍>
<书籍>
<书名>倾城之恋</书名>
<作者>张爱玲</作者>
<价格>59.00</价格>
<出版社>人民出版社</出版社>
<出版日期>1943-12-6</出版日期>
<出版号></出版号>
<种类>社科类</种类>
<类别>爱情短片小说</类别>
</书籍>
</书籍列表>
显示:
