一、给变量赋值我在用xslt格式化xml的时候,想再显示数据时,使用交替的样式显示行。我想通过一个变量:
xsl:variable 或者 xsl:param 然后通过在 xsl:for-each 中动态改变变量的值,来给交替行分别赋样式。但是如何动态改变xsl:variable 或者 xsl:param中的值,以达到我的要求呢?
另外,大家都是如何解决的呢?二、我的xsl格式化我的xml显示时(我是通过在xml中添加<?xml-stylesheet type='text/xsl' href='../logInfo.xsl'?>来直接引用用来格式化的xsl的) 居然经常有两行重叠显示,刷新后会分开,但是在刷新,可能有重叠了。不知道怎么回事。
xsl:variable 或者 xsl:param 然后通过在 xsl:for-each 中动态改变变量的值,来给交替行分别赋样式。但是如何动态改变xsl:variable 或者 xsl:param中的值,以达到我的要求呢?
另外,大家都是如何解决的呢?二、我的xsl格式化我的xml显示时(我是通过在xml中添加<?xml-stylesheet type='text/xsl' href='../logInfo.xsl'?>来直接引用用来格式化的xsl的) 居然经常有两行重叠显示,刷新后会分开,但是在刷新,可能有重叠了。不知道怎么回事。
解决方案 »
- vs2010下MVC3安装成功,但是VS2010开发环境中无法创建MVC3原因何在?
- 跪求 FusionCharts控件资料或demo
- 这种分页效果怎么做
- javascript接收asp.net传递的变量丢失的问题
- WebClient文件上传的类型问题
- 如何将一个page中的所有TextBox控件遍历然后将其Text属性=string.Empty;呢????
- 如何把嵌入资源图片赋给ImageButton图片控件???急急急
- !!!!!!!!!!!!!!!!!!ASP.NET中如何实现 XXPage x=new XXXPage();x.show()!!!!!!!!!!!!!!!!!!
- 主/明细表中怎么传送多个值?
- DataGrid更新数据的问题!100分相送
- 求救:浏览器出错:stack overflow at line 268
- 读写文件 中文变成乱码,谁能给出解决方案
<?xml-stylesheet type='text/xsl' href='../logInfo.xsl'?>
<syslog><log><username>匿名</username><operate>浏览主界面</operate><userip>192.168.22.205</userip><opdate>2004-12-27 17:33:41</opdate></log><log><username>匿名</username><operate>浏览主界面</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:06:03</opdate></log><log><username>匿名</username><operate>浏览标准信息--行业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:06:06</opdate></log><log><username>匿名</username><operate>浏览标准信息--行业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:08:11</opdate></log><log><username>匿名</username><operate>浏览标准信息--行业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:08:13</opdate></log><log><username>匿名</username><operate>浏览标准信息--行业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:10:12</opdate></log><log><username>匿名</username><operate>浏览标准信息--行业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:10:16</opdate></log><log><username>匿名</username><operate>浏览标准信息--行业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:10:44</opdate></log><log><username>匿名</username><operate>浏览标准信息--行业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:11:16</opdate></log><log><username>匿名</username><operate>浏览标准信息--行业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:11:17</opdate></log><log><username>匿名</username><operate>浏览标准信息--行业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:11:45</opdate></log><log><username>匿名</username><operate>浏览主界面</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:12:40</opdate></log><log><username>匿名</username><operate>浏览标准信息--企业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:12:44</opdate></log><log><username>匿名</username><operate>浏览标准信息--企业标准</operate><userip>192.168.22.201</userip><opdate>2004-12-27 20:12:58</opdate></log></syslog>
xslt代码:<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><!-- localized strings -->
<xsl:variable name='ColumnHeader_UserName'>用户</xsl:variable>
<xsl:variable name='ColumnHeader_Time'>时间</xsl:variable>
<xsl:variable name='ColumnHeader_Operate'>操作</xsl:variable>
<xsl:variable name='ColumnHeader_Address'>IP地址</xsl:variable><!-- variables -->
<xsl:variable name='TableStyle'>background-color:#DAE6D8;font-family:Simsun, Verdana; font-size:75%; text-align:left; vertical-align:top; table-layout:fixed</xsl:variable>
<xsl:variable name='HeaderStyle'>border-bottom:1 solid black</xsl:variable><xsl:template match="syslog"> <html>
<head>
<title>
日志查看
</title>
</head> <body style='margin:10;background-color:#DAE6D8'>
<div align="center">
<table style="{$TableStyle}" width="100%" align="center" cellspacing='0'>
<thead>
<tr>
<th width="15%" style="{$HeaderStyle}">
<xsl:value-of select="$ColumnHeader_UserName"/>
</th>
<th width="20%" style="{$HeaderStyle}">
<xsl:value-of select="$ColumnHeader_Time"/>
</th>
<th width="50%" style="{$HeaderStyle}">
<xsl:value-of select="$ColumnHeader_Operate"/>
</th>
<th width="15%" style="{$HeaderStyle}">
<xsl:value-of select="$ColumnHeader_Address"/>
</th>
</tr>
</thead>
<tbody style='vertical-align:top'>
<tr ><td colspan="4" height="5"></td></tr>
<xsl:for-each select="log">
<xsl:sort select='opdate' order='ascending'/>
<tr height="23">
<td ><xsl:value-of select="username"/></td>
<td ><xsl:value-of select="opdate"/></td>
<td ><xsl:value-of select="operate"/></td>
<td ><xsl:value-of select="userip"/></td>
</tr>
</xsl:for-each>
<tr bgcolor="#cccccc"><td colspan="4" height="1"></td></tr>
<tr><td colspan="4" align="right">合计:<xsl:value-of select="count(log)"/> </td></tr>
</tbody>
</table>
</div>
</body>
</html></xsl:template>
</xsl:stylesheet>
<xsl:variable name='ColumnHeader_UserName'>用户</xsl:variable>
<xsl:variable name='ColumnHeader_Time'>时间</xsl:variable>
<xsl:variable name='ColumnHeader_Operate'>操作</xsl:variable>
<xsl:variable name='ColumnHeader_Address'>IP地址</xsl:variable><!-- variables -->
<xsl:variable name='TableStyle'>background-color:#DAE6D8;font-family:Simsun, Verdana; font-size:75%; text-align:left; vertical-align:top;</xsl:variable>
<xsl:variable name='HeaderStyle'>border-bottom:1 solid black</xsl:variable><xsl:template match="syslog"> <html>
<head>
<title>
日志查看
</title>
</head> <body style='margin:10;background-color:#DAE6D8'>
<div align="center">
<table style="{$TableStyle}" width="100%" align="center" cellspacing='0'>
<thead>
<tr>
<th width="15%" style="{$HeaderStyle}">
<xsl:value-of select="$ColumnHeader_UserName"/>
</th>
<th width="20%" style="{$HeaderStyle}">
<xsl:value-of select="$ColumnHeader_Time"/>
</th>
<th width="50%" style="{$HeaderStyle}">
<xsl:value-of select="$ColumnHeader_Operate"/>
</th>
<th width="15%" style="{$HeaderStyle}">
<xsl:value-of select="$ColumnHeader_Address"/>
</th>
</tr>
</thead>
<tbody style='vertical-align:top'>
<tr><td colspan="4" height="5"></td></tr>
<xsl:for-each select="log">
<xsl:sort select='opdate' order='ascending'/>
<tr height="23" style="background-color:red">
<xsl:if test="position() mod 2 = 0">
<xsl:attribute name="style">background-color:blue</xsl:attribute>
</xsl:if>
<td ><xsl:value-of select="username"/></td>
<td ><xsl:value-of select="opdate"/></td>
<td ><xsl:value-of select="operate"/></td>
<td ><xsl:value-of select="userip"/></td>
</tr>
</xsl:for-each>
<tr bgcolor="#cccccc"><td colspan="4" height="1"></td></tr>
<tr><td colspan="4" align="right">合计:<xsl:value-of select="count(log)"/> </td></tr>
</tbody>
</table>
</div>
</body>
</html></xsl:template>
</xsl:stylesheet>