求一个样式表文件,实现分行显示数据,帮忙up!

火电 2005-03-02 09:25:48
xml文件:
<DataSet>
<Column id="CHAJLY" desc="案件来源" >来自外地</Column>
<Column id="SARQ" desc="涉案时间" >2004-12-12</Column>
<Column id="CHSAAY" desc="涉案案由" >贪污罪</Column>
<Column id="CCRQ" desc="初查日期" >2004-12-12</Column>
<Column id="CHCCJG" desc="初查机关" >检察院</Column>
<Column id="YSLARQ" desc="以事立案日期" >2004-12-12</Column>
<Column id="QDXYRRQ" desc="确定嫌疑人日期" >2004-12-12</Column>
<Column id="LARQ" desc="立案日期" >2004-12-12</Column>
<Column id="QLASE" desc="全立案数额" >10000</Column>
<Column id="ZJRQ" desc="侦结日期" >2004-12-12</Column>

</DataSet>

我想按每行4列显示,包括两列字段描述和对应的值,共4个td

案件来源 来自外地 涉案时间 2004-12-12
涉案案由 贪污罪 初查日期 2004-12-12

就是类似上面的结构

我写了一个大致的xsl,但是不能满足
清帮忙修改或者重新提供一个
非常感谢!!!

<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
<xsl:template match="/">
<html>
<body>
<table border="1" width="100%" align="center" style="BORDER-COLLAPSE: collapse" cellSpacing="0" cellPadding="2" rules="all">
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Column">
<xsl:choose>
<xsl:when test="position() mod 3 = 0">
<tr>
<xsl:call-template name="LoopFun"/>
</tr>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="LoopFun"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="LoopFun">
<td align="center" width="25%" noWrap="true">
<label style="WIDTH:150px" bgcolor="#f6f6f6">
<xsl:value-of select="@desc"/>
</label>
</td>
<td bgcolor="#ffffff" width="25%">

<label style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 楷体_GB2312">
<xsl:value-of select="."/>
</label>

</td>
</xsl:template>
</xsl:stylesheet>
...全文
90 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ssm1226 2005-03-02
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
<xsl:template match="/">
<html>
<body>
<table border="1" width="100%" align="center" style="BORDER-COLLAPSE: collapse" cellSpacing="0" cellPadding="2" rules="all">
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Column">
<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:template>
<xsl:template name="LoopFun">
<xsl:param name="node"></xsl:param>
<td align="center" width="25%" noWrap="true">
<label style="WIDTH:150px" bgcolor="#f6f6f6">
<xsl:value-of select="$node/@desc"/>
</label>
</td>
<td bgcolor="#ffffff" width="25%">

<label style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 楷体_GB2312">
<xsl:value-of select="$node"/>
</label>

</td>
</xsl:template>
</xsl:stylesheet>
gu1dai 2005-03-02
  • 打赏
  • 举报
回复
好,up
ssm1226 2005-03-02
  • 打赏
  • 举报
回复
?什么情况下报的?
火电 2005-03-02
  • 打赏
  • 举报
回复
为什么提示编码格式不正确呢?

8,906

社区成员

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

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