我有一些输入XML是XSLT计数位置和组项目相应
<collection>
<content>
<id>10</id>
<type>xx</type>
<title>xx</title>
<quicklink>xx</quicklink>
<teaser><p>xxx</p></teaser>
<root>
<thumb><img src="/xxx/xxx.jpg" /></thumb>
<link>http://www.foo.com</link>
</root>
<startDate></startDate>
<enddate></enddate>
<hyperlink><a href="http://www.foo.com">some text</a></hyperlink>
</content>
<content>
<id>10</id>
<type>xx</type>
<title>xx</title>
<quicklink>xx</quicklink>
<teaser><p>xxx</p></teaser>
<root>
<thumb><img src="/xxx/xxx.jpg" /></thumb>
<link>http://www.foo.com</link>
</root>
<startDate></startDate>
<enddate></enddate>
<hyperlink><a href="http://www.foo.com">some text</a></hyperlink>
</content>
<content>
<id>10</id>
<type>xx</type>
<title>xx</title>
<quicklink>xx</quicklink>
<teaser><p>xxx</p></teaser>
<root>
<thumb><img src="/xxx/xxx.jpg" /></thumb>
<link>http://www.foo.com</link>
</root>
<startDate></startDate>
<enddate></enddate>
<hyperlink><a href="http://www.foo.com">some text</a></hyperlink>
</content>
</collection>
XSLT写入格式化无序列表如下
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ul id="case-study-icons">
<xsl:for-each select="collection/content">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="Html/root/Link"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="title"/>
</xsl:attribute>
<img>
<xsl:attribute name="src">
<xsl:value-of select="Html/root/thumb/img/@src"/>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="title"/>
</xsl:attribute>
<xsl:attribute name="width">92</xsl:attribute>
<xsl:attribute name="height">46</xsl:attribute>
</img>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
我想改变这个有3个图像在一个li and grounp every 3 item occurance into 3 image links groups wrapped with
李`里面的链接。因此,在改造结束的HTML必须看起来像下面
<ul id="case-study-icons">
<li>
<a href="#"><img src="/foo.jpg" /></a>
<a href="#"><img src="/foo.jpg" /></a>
<a href="#"><img src="/foo.jpg" /></a>
</li>
<li>
<a href="#"><img src="/foo.jpg" /></a>
<a href="#"><img src="/foo.jpg" /></a>
<a href="#"><img src="/foo.jpg" /></a>
</li>
<li>
<a href="#"><img src="/foo.jpg" /></a>
<a href="#"><img src="/foo.jpg" /></a>
<a href="#"><img src="/foo.jpg" /></a>
</li>
</ul>
我曾尝试使用position()
不知我的逻辑似乎不工作该做我自己。有人可以看看吗?非常感谢提前..
我有一个当前的XSLT已经写成如上。目前,它每个“li”输出1个图像链接。我想将其更改为每个“li”3个图像链接。输入到XSL是一个.NET对象列表。 – Chin 2012-03-22 10:22:24
我指的是应用转换的XML输入。 – 2012-03-22 10:27:52
我不幸没有这些信息。这些项目通过我无法访问的控件呈现。 :-( – Chin 2012-03-22 10:29:59