急,关于XSL分页得问题!!!!!!!!

singnet 2004-09-15 09:14:47
我有下面得XML文件,请问我怎么通过xsl对里面得star/specials/special节点进行分页,并且每行显示两个,而且相邻的两行背景颜色不同,希望大伙帮帮忙,急死我了
<?xml version="1.0" encoding="gb2312" ?>
- <star>
- <info>
<kind_id>1</kind_id>
<kind_name>中国星</kind_name>
</info>
- <specials>
- <special>
<id>78</id>
<name>Twins《少女情怀》写真(二)</name>
<photo>0101.jpg</photo>
<cent>100</cent>
<photodb>78</photodb>
<date>2004-4-22 15:55:14</date>
</special>
- <special>
<id>103</id>
<name>Twins</name>
<photo>0655.jpg</photo>
<cent>100</cent>
<photodb>59</photodb>
<date>2003-1-20 10:22:41</date>
</special>
- <special>
<id>419</id>
<name>Twins《少女情怀》写真(一)</name>
<photo>1187.jpg</photo>
<cent>100</cent>
<photodb>75</photodb>
<date>2002-10-25 12:56:40</date>
</special>
- <special>
<id>78</id>
<name>Twins《少女情怀》写真(二)</name>
<photo>0101.jpg</photo>
<cent>100</cent>
<photodb>78</photodb>
<date>2004-4-22 15:55:14</date>
</special>
- <special>
<id>103</id>
<name>Twins</name>
<photo>0655.jpg</photo>
<cent>100</cent>
<photodb>59</photodb>
<date>2003-1-20 10:22:41</date>
</special>
- <special>
<id>419</id>
<name>Twins《少女情怀》写真(一)</name>
<photo>1187.jpg</photo>
<cent>100</cent>
<photodb>75</photodb>
<date>2002-10-25 12:56:40</date>
</special>
- <special>
<id>78</id>
<name>Twins《少女情怀》写真(二)</name>
<photo>0101.jpg</photo>
<cent>100</cent>
<photodb>78</photodb>
<date>2004-4-22 15:55:14</date>
</special>
- <special>
<id>103</id>
<name>Twins</name>
<photo>0655.jpg</photo>
<cent>100</cent>
<photodb>59</photodb>
<date>2003-1-20 10:22:41</date>
</special>
- <special>
<id>419</id>
<name>Twins《少女情怀》写真(一)</name>
<photo>1187.jpg</photo>
<cent>100</cent>
<photodb>75</photodb>
<date>2002-10-25 12:56:40</date>
</special>
- <special>
<id>78</id>
<name>Twins《少女情怀》写真(二)</name>
<photo>0101.jpg</photo>
<cent>100</cent>
<photodb>78</photodb>
<date>2004-4-22 15:55:14</date>
</special>
- <special>
<id>103</id>
<name>Twins</name>
<photo>0655.jpg</photo>
<cent>100</cent>
<photodb>59</photodb>
<date>2003-1-20 10:22:41</date>
</special>
- <special>
<id>419</id>
<name>Twins《少女情怀》写真(一)</name>
<photo>1187.jpg</photo>
<cent>100</cent>
<photodb>75</photodb>
<date>2002-10-25 12:56:40</date>
</special>
- <special>
<id>78</id>
<name>Twins《少女情怀》写真(二)</name>
<photo>0101.jpg</photo>
<cent>100</cent>
<photodb>78</photodb>
<date>2004-4-22 15:55:14</date>
</special>
- <special>
<id>103</id>
<name>Twins</name>
<photo>0655.jpg</photo>
<cent>100</cent>
<photodb>59</photodb>
<date>2003-1-20 10:22:41</date>
</special>
- <special>
<id>419</id>
<name>Twins《少女情怀》写真(一)</name>
<photo>1187.jpg</photo>
<cent>100</cent>
<photodb>75</photodb>
<date>2002-10-25 12:56:40</date>
</special>
- <special>
<id>78</id>
<name>Twins《少女情怀》写真(二)</name>
<photo>0101.jpg</photo>
<cent>100</cent>
<photodb>78</photodb>
<date>2004-4-22 15:55:14</date>
</special>
- <special>
<id>103</id>
<name>Twins</name>
<photo>0655.jpg</photo>
<cent>100</cent>
<photodb>59</photodb>
<date>2003-1-20 10:22:41</date>
</special>
- <special>
<id>419</id>
<name>Twins《少女情怀》写真(一)</name>
<photo>1187.jpg</photo>
<cent>100</cent>
<photodb>75</photodb>
<date>2002-10-25 12:56:40</date>
</special>
</specials>
</star>
...全文
177 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
singnet 2004-09-15
  • 打赏
  • 举报
回复
客户端,我不想最后显示的时候用htm的形式哈
孟子E章 2004-09-15
  • 打赏
  • 举报
回复
http://dotnet.aspx.cc/ShowDetail.aspx?id=YAWO3QGM-XD53-4D3D-OYBR-BLSBX5BNGAYM

用XSL把XML的数据转换成完美的多列表格形式
孟子E章 2004-09-15
  • 打赏
  • 举报
回复
客户端分页还是服务器段??
客户端参考
http://lucky.myrice.com/xml/xpathexam2.htm
singnet 2004-09-15
  • 打赏
  • 举报
回复
谢谢楼上的,但是怎么和分页结合起来呢
kisslan 2004-09-15
  • 打赏
  • 举报
回复
分两行实现了,但背景色不太好弄
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="star">
<xsl:variable name="strTrLeft" select="'<tr>'"/>
<xsl:variable name="strTrRight" select="'</tr>'"/>
<xsl:variable name="recordsPerRow" select="'2'"/>
<table border="1" cellpadding="0" cellspacing="0">
<tr align="">
<!--dd-->
<xsl:for-each select="specials/special">
<xsl:if test="(position()-1) mod $recordsPerRow=0">
<xsl:if test="position()>1">
<xsl:value-of select="$strTrRight" disable-output-escaping="yes"/>
<xsl:value-of select="$strTrLeft" disable-output-escaping="yes"/>
</xsl:if>
</xsl:if>
<td width="20%">
<xsl:value-of select="name"/>
</td>
</xsl:for-each>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
singnet 2004-09-15
  • 打赏
  • 举报
回复
现在分页可以实现了,但是每行显示两个,而且相邻的两行背景颜色不同,始终实现不了~~

<?xml version="1.0" encoding="gb2312" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
<style>
body,BlueIdea,team,blue_ID,blue_name,blue_text,blue_time,blue_class{ font: 12px "宋体", "Arial", "Times New Roman"; }
table { font-size: 12px; border: 0px double; border-color: #99CC99 #99CC99 #CCCCCC #CCCCCC; cellpadding:3;cellspacing:3; bgcolor:#eeeeee; text-decoration: blink}
span { font-size: 12px; color: red; }
.keybutton { cursor:hand; font-size: 12px; color: #003300; background: #ffffff; border: 0px solid;}
</style>
<script>
<xsl:comment>
<![CDATA[
var OnePageNum=4;
var PageNum=1;
var XMLPageNum=1;
function pages(Num)
{
stylesheet=document.XSLDocument;
source=document.XMLDocument;
nodes=source.documentElement.childNodes[1].childNodes;
len=nodes.length;
for(i=1;i<=(len/OnePageNum);i++);
XMLPageNum=i;
var firstNum=0;
var lastNume=0;

if (Num=="first") {PageNum=1;}
if (Num=="previous") {if (PageNum>1) PageNum -=1;}
if (Num=="next") {if (PageNum<XMLPageNum) PageNum +=1;}
if (Num=="last") {PageNum =XMLPageNum;}

sortField=document.XSLDocument.selectSingleNode("//@expr");
firstNum=OnePageNum*(PageNum-1)+1;
lastNum=OnePageNum*(PageNum-1)+OnePageNum;
text="childnumber(this)>="+firstNum+" & childnumber(this)<="+lastNum;
sortField.value=text;
Layer1.innerHTML=source.documentElement.transformNode(stylesheet);
}
]]>
</xsl:comment>
</script>
</head>

<body>
<table align="center" width="500" >
<tr>
<td>
<button id="cmdfirstPage" class="keybutton" onclick="pages('first');" >首页</button>
<button id="cmdpreviousPage" class="keybutton" onclick="pages('previous');" >上一页</button>
<button id="cmdnextPage" class="keybutton" onclick="pages('next');">下一页</button>
<button id="cmdlastPage" class="keybutton" onclick="pages('last');">尾页</button>
</td>
</tr>
</table>
<div id="Layer1" name="Layer1"> <xsl:apply-templates select="star"/></div>
</body>

</html>
</xsl:template>
<xsl:template match="star">
<table width="500" border="1" align="center" cellpadding="1" cellspacing="1">
<tr align="center">
<xsl:apply-templates select="specials/special" />
</tr>
</table>
</xsl:template>
<xsl:template match="specials/special" >
<xsl:if expr="childnumber(this)>=1&childnumber(this)<=4 ">
<xsl:apply-templates select="id" />
<xsl:apply-templates select="name" />
</xsl:if>

</xsl:template>
<xsl:template match="id">
<td bgcolor="#eeeeee">
<xsl:value-of />
</td>
</xsl:template>
<xsl:template match="name">
<td>
<xsl:value-of />
</td>
</xsl:template>
</xsl:stylesheet>
singnet 2004-09-15
  • 打赏
  • 举报
回复
晕,老大们帮帮忙哈
singnet 2004-09-15
  • 打赏
  • 举报
回复
我用了孟老大的程序,但是怎么也调不出来~~

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧