您的位置:程序门 -> web 开发 -> xml/soap



xsl 问题,如何对属性进行判断,变颜色


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


xsl 问题,如何对属性进行判断,变颜色
发表于:2007-12-28 09:26:48 楼主
xml如下:
<tab>
    <colls   usid="naa"   usname="454"   flag="ture"   />
    <colls   usid="bxb"   usname="9p4"   flag="ture"   />    
    <colls   usid="cyc"   usname="ku4"   flag="flase"   />
    <colls   usid="cxc"   usname="9v4"   flag="flase"   />
    <colls   usid="xxa"   usname="bb4"   flag="ture"   />
</tab>


部份xsl如下:

<xsl:template   match="tab"> <!--显示数据列表-->
      <table>
<xsl:apply-templates   select="colls"   order-by="x"   />
      </table>
</xsl:template>


<xsl:template   match="colls"> <!--显示所有colls数据行-->
  <xsl:if   expr="childnumber(this)&gt;=1   &amp;   childnumber(this)&lt;=2">
        <tr>
              <xsl:apply-templates   select="@*"   />
        </tr>

      <xsl:template   match="@*">
              <td> <xsl:value-of   select="."/> </td>
      </xsl:template>
</xsl:if>
</xsl:template>

请教:
如果flag="true"时,   td的font-color显示绿色;
如果flag="flase"时,td的font-color显示红色;就如何做?
发表于:2007-12-28 13:21:341楼 得分:0
orz

老朽如果还记得不错的话,这是陈帖翻新啊。

ft
--
anything   one   man   can   imagine,   other   men   can   make   real.


发表于:2008-01-03 09:53:552楼 得分:0
xslt   1.0正式版的写法:
xml code
<xsl:template match="colls"> <!--显示所有colls数据行--> <xsl:variable name="style"> <xsl:if test="@flag='true'">color: red;</xsl:if> </xsl:variable> <tr style={$style}> <xsl:apply-templates select="@*" /> </tr> </xsl:template>
发表于:2008-01-03 13:02:493楼 得分:0
xml code
<?xml version="1.0" encoding="gb2312"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" > <xsl:template match="/root"> <table style="border: 1px solid black; width: 100px;"> <xsl:apply-templates/> </table> </xsl:template> <xsl:template match="item"> <tr> <xsl:if test="position() mod 2=1"> <xsl:attribute name="style">background-color:yellow;</xsl:attribute> </xsl:if> <td style="text-align: center; width: 100%;"><xsl:value-of select="text()"/></td> </tr> </xsl:template> </xsl:stylesheet>
发表于:2008-01-10 11:05:584楼 得分:0
webhaitao     完全误会我的意思了


快速检索

最新资讯
热门点击