+ -
当前位置:首页 → 问答吧 → 用Xslt如何来实现单双行的区分

用Xslt如何来实现单双行的区分

时间:2003-05-29

来源:互联网

我这样用
<xsl:template match="record">
<tr>
<xsl:choose>
        <xsl:when test="position() mod 2 = 1">
                        <!--   这里为显示行的颜色 -->
        </xsl:when>
        <xsl:otherwise>
        </xsl:otherwise>
</xsl:choose>
<td><xsl:value-of select="record" /></td>
</tr>
</xsl:template>

结果就说“未指定的错误。。。。。。。
我给<xsl:choose>去掉后是能正常解析的

有什么问题?

作者: debug   发布时间: 2003-05-29

不会啊
我自己的网站里面都是使用这个实现的


<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:zfunc="urn:Snakevil.H.William:pro-func">
        <xsl:include href="./context.xsl" />
        <xsl:include href="./copyright.xsl" />
        <xsl:include href="./func.xsl" />
        <xsl:output encoding="gb2312" indent="yes" media-type="text/html" method="html" standalone="yes" />

        <xsl:template match="/article">
                <html>
                        <head>
                                <title>思绪的湖泊--静夜笔触--<xsl:value-of select="title/text()" /></title>
                                <meta name="Author" content="Snakevil.H.William"></meta>
                                <link rel="stylesheet" type="text/css" href="../_style/wq05a83_.css"></link>
                                <link rel="stylesheet" type="text/css" href="../_style/context.css"></link>
                                <link rel="stylesheet" type="text/css" href="../_style/copyright.css"></link>
                                <script language="jscript" src="../_script/base.js"></script>
                                <script language="jscript" src="../_script/context.js"></script>
                                <script language="jscript" src="../_script/wq05a83r.js"></script>
                        </head>
                        <body onclick="snContext()"
                         oncontextmenu="nwContext()"
                         ondragstart="noEffect()"
                         onhelp="cHelp()"
                         onkeydown="cShortC()"
                         onload="sniffer()"
                         onscroll="snContext()"
                         onselectstart="noEffect()">
                                <xsl:call-template name="selfContext" />
                                <xsl:apply-templates />
                                <xsl:call-template name="copyright" />
                        </body>
                </html>
        </xsl:template>

        <xsl:template match="/article/title">
                <p>沐风听雨——思绪的湖泊<label>&gt;&gt;</label><a class="cTitle" href="../main.htm?wq05a83r/index.xml?x={zfunc:rndstr()}" target="_parent">静夜笔触</a><label>&gt;&gt;</label><xsl:value-of select="text()" /></p>
        </xsl:template>

        <xsl:template match="/article/author">
                <blockquote>作者:<span><xsl:value-of select="text()" /></span></blockquote>
        </xsl:template>

        <xsl:template match="/article/content/graph[1]">
                <div class="g0"><xsl:value-of select="text()" /></div>
        </xsl:template>

        <xsl:template match="/article/content/graph[position()!=1]">
                <div class="g{1 + position() mod 2}"><xsl:value-of select="text()" /></div>
        </xsl:template>
</xsl:stylesheet>

作者: snakevil   发布时间: 2003-06-03