想用xslt实现这样的功能该怎么做?
静态情况下:
<tr>
<td></td>
<td></td>
</tr>
现在有一个List怎么让他动态出现上面的情况,就是 position mod 2= 0 的时候要写下: <tr> 当position mod 2 !=0 时候写下:</tr>
我尝试了好几种办法都没有用。
问题点数:0、回复次数:2Top
1 楼moonpiazza(月光易水)回复于 2003-08-27 11:31:37 得分 0
try:
/*** a.xml ***/
<?xml version="1.0" encoding="gb2312" ?>
<?xml-stylesheet type="text/xsl" href="a.xsl" ?>
<moonpiazza>
<book ID="1">
<title>基于XML 的 ASP.NET开发</title>
<price>42</price>
<author>Dan Wahlin/王宝良</author>
</book>
<book ID="2">
<title>XML应用的UML建模技术</title>
<price>32</price>
<author>David Carlson/周靖 侯奕萌 沈金河等</author>
</book>
<book ID="3">
<title>极限编程研究</title>
<price>70</price>
<author>Giancarrio Succi/Michele Marchesi/张辉(译)</author>
</book>
<book ID="4">
<title>Design Patterns</title>
<price>38</price>
<author>Erich Gamma/Richard Helm/Ralph Johnson/John Vlissides</author>
</book>
</moonpiazza>
/*** a.xsl ***/
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="moonpiazza" >
<table border="1">
<xsl:apply-templates select="book"/>
</table>
</xsl:template>
<xsl:template match="book" >
<xsl:if test="(position() mod 2) != 0">
<xsl:text disable-output-escaping="yes">
<![CDATA[ <tr> ]]>
</xsl:text>
</xsl:if>
<td><xsl:value-of select="title" /></td>
<xsl:if test="(position() mod 2) = 0">
<xsl:text disable-output-escaping="yes">
<![CDATA[ </tr> ]]>
</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
:_)Top
2 楼net_lover(【孟子E章】)回复于 2003-08-27 16:09:13 得分 0
http://www.erp800.com/net_lover/ShowDetail.asp?id=YAWO3QGM-XD53-4D3D-OYBR-BLSBX5BNGAYM
用XSL把XML的数据转换成完美的多列表格形式Top





