求高手完善该xsl样式,有源码,帮忙up

火电 2005-06-22 06:28:35
从xml中对应输出每行四列的表格
其中如果type属性=‘bigstring’该列自己站一个tr

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://dotnet.aspx.cc/" exclude-result-prefixes="msxsl user">
<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" />
<msxsl:script language="JavaScript" implements-prefix="user">
<![CDATA[
function getshortDate(date)
{
return date.split(" ")[0];
}
]]>
</msxsl:script>
<xsl:template match="/">
<html>
<body>
<table border="1" bordercolor="#FFFAFA" cellpadding="0" cellspacing="0" width="100%"
bgcolor="#FAFAD2" style="border-left:solid #FAFAD2 1.5px;border-top:solid #FAFAD2 1.5px;border-right:solid #FAFAD2 1.8px;border-bottom:solid #FAFAD2 1.8px;">

<xsl:apply-templates />
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Column">
<xsl:choose>
<xsl:when test="@type='bigstring'">
<xsl:call-template name="LoopFunForBigString">
<xsl:with-param name="node" select="." />
</xsl:call-template>
<xsl:choose>
<xsl:when test="boolean(following-sibling::Column)">
<xsl:call-template name="LoopFunForBigString">
<xsl:with-param name="node" select="following-sibling::Column" />
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<tr>
<xsl:if test="position() mod 2=1">
<xsl:call-template name="LoopFun">
<xsl:with-param name="node" select="." />
</xsl:call-template>
<xsl:choose>
<xsl:when test="boolean(following-sibling::Column)">
<xsl:call-template name="LoopFun">
<xsl:with-param name="node" select="following-sibling::Column" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<td colspan="2"> </td>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="LoopFun">
<xsl:param name="node" />
<td align="left" width="180" noWrap="true">    
<label bgcolor="#f6f6f6">
<xsl:value-of select="$node/@desc" />
</label>
</td>
<td width="180" bgcolor="#ffffff" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#FFE4B5'">
<xsl:choose>
<xsl:when test="$node/@type='int'">
<xsl:if test=".='0'">
<label style="FONT-WEIGHT: bold">否</label>
</xsl:if>
<xsl:if test=".='1'">
<label style="FONT-WEIGHT: bold">是</label>
</xsl:if>
</xsl:when>
<xsl:when test="$node/@type='datetime'">
<label style="FONT-WEIGHT: bold">
<xsl:value-of select="user:getshortDate(string($node))" />
</label>
</xsl:when>
<xsl:otherwise>
<label style="FONT-WEIGHT: bold">
<xsl:value-of select="$node" />
</label>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:template>
<xsl:template name="LoopFunForBigString">
<xsl:param name="node" />
<tr>
<td align="left" width="180" noWrap="true">    
<label bgcolor="#f6f6f6" >
<xsl:value-of select="$node/@desc" />
</label>
</td>
<td bgcolor="#ffffff" width="600" colspan="3" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#FFE4B5'">
<label style="FONT-WEIGHT: bold">
<xsl:value-of select="$node" />
</label>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
...全文
94 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
火电 2005-06-27
  • 打赏
  • 举报
回复
up
火电 2005-06-24
  • 打赏
  • 举报
回复
xml 结构很简单

<xml>

<column type="string">aaa</column>
<column type="string">aaa</column>
<column type="string">aaa</column>
<column type="string">aaa</column>
<column type="bigstring">fasdfasdfasdfasfasdfasdfasfasdf</column>
</xml>

类似
ssm1226 2005-06-23
  • 打赏
  • 举报
回复
xml文件呢?
白夜花寒 2005-06-23
  • 打赏
  • 举报
回复
你有没有图的??给我看看。。
火电 2005-06-23
  • 打赏
  • 举报
回复
事啊。帮忙看看阿
白夜花寒 2005-06-22
  • 打赏
  • 举报
回复
xsl:when test="@type='bigstring'">
<xsl:call-template name="LoopFunForBigString">
<xsl:with-param name="node" select="." />
</xsl:call-template>

<xsl:template name="LoopFunForBigString">
<xsl:param name="node" />
<tr>
<td align="left" width="180" noWrap="true">    
<label bgcolor="#f6f6f6" >
<xsl:value-of select="$node/@desc" />
</label>
</td>
<td bgcolor="#ffffff" width="600" colspan="3" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#FFE4B5'">
<label style="FONT-WEIGHT: bold">
<xsl:value-of select="$node" />
</label>
</td>
</tr>
</xsl:template>
代码太长了,只找到了这个模版,你是这个模版出问题了???
火电 2005-06-22
  • 打赏
  • 举报
回复
现在的处理出现的问题:

1:在type='bigstring' 列位置为偶数时会显示2个该列

2:在type='bigstring' 列位置为奇数时该列可以正常显示,但是下一列也是独占一个tr

8,906

社区成员

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

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