再问:在xsl里可以通过为同一个Topic建立多种模板吗?

jeskee 2003-10-16 02:39:06
之前的问题:
http://expert.csdn.net/Expert/topic/2361/2361674.xml?temp=.9865991
现在不管mode用什么,item它都自动地套用<xsl:template match="item" mode="Whatever">



<div id="xmldata">
<xsl:apply-templates select="Topic/item" mode="only"/>-->
</div>
<div id="Layer1" name="Layer1">
<xsl:apply-templates select="Topic"/>
</div>



<xsl:template match="Topic" >
<table width="500" border="1" align="center" cellpadding="1" cellspacing="1" bordercolordark="#ffffff" bordercolorlight="#ADAAAD">
<tr bgcolor="#FFCC99" align="center">
<td style="cursor:hand" onClick="taxis('blue_ID')">编号</td>
<td style="cursor:hand" onClick="taxis('blue_name')">作者</td>
<td style="cursor:hand" onClick="taxis('blue_text')">主题</td>
<td style="cursor:hand" onClick="taxis('blue_time')">发表时间</td>
</tr>
<xsl:apply-templates select="item" mode="Whatever"/>
</table>
</xsl:template>
<xsl:template match="item" mode="only">
<xsl:element name="item">
<xsl:element name="author">
<xsl:attribute name="xh"><xsl:value-of select="author/@xh"/></xsl:attribute>
<xsl:value-of select="author" />
</xsl:element>
<xsl:element name="title">
<xsl:value-of select="title" />
</xsl:element>
<xsl:element name="time">
<xsl:value-of select="time" />
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="item" mode="Whatever">
<tr align="center">
<td><xsl:value-of select="author/@xh"/></td>
<td>
<xsl:value-of select="author"/>
</td>
<td><xsl:value-of select="title"/></td>
<td><SPAN STYLE="font-style:italic"><xsl:value-of select="time"/></SPAN></td>
</tr>
</xsl:template>
请求继续帮助!
...全文
81 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wolf004 2003-10-16
  • 打赏
  • 举报
回复
可以用个断判语句啊!
<xsl:choose> <!--创建分支结构-->
<!--如果document/page/page2=''为空成立则-->
<xsl:when test="page2[.='']">123</xsl:when>
<xsl:when test="page2[.='中国']">456</xsl:when>
<xsl:otherwise>789</xsl:otherwise> <!--所有when不成立则输出789-->
</xsl:choose>
123可以改为你的Topic样式
jeskee 2003-10-16
  • 打赏
  • 举报
回复
就是套用最后一个item的模板

8,906

社区成员

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

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