プレ
私はこのXMLを持っています
<root>
<subscribers nullDays="5">
<subscriber>
<ThumbURL>
http://cs323321.userapi.com/v323321550/eea/iakdB20fx20.jpg
</ThumbURL>
</subscriber>
<subscriber>
<ThumbURL>
http://cs323321.userapi.com/v323321550/f24/CQ-Zm0_BWnQ.jpg
</ThumbURL>
</subscriber>
...
<subscriber>
<ThumbURL>...</ThumbURL>
</subscriber>
</subscribers>
</root>
XSLT の後、サブスクライバーがimgタグを含む各divに分割されるHTML を取得します。
質問
xsl:for-eachを使用してdiv equals nullDays属性を生成するにはどうすればよいですか? 次のコードには、 nullDaysよりも多くのサブスクライバーノードが必要ですが、存在することはできません。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"xml:base="http://www.w3.org/1999/xhtml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" indent="yes"/>
<xsl:template match="root">
<xsl:element name="html">
<xsl:element name="head"/>
<xsl:element name="body">
<xsl:variable name="nullDays" select="subscribers/@nullDays"/>
<xsl:for-each select="subscribers/subscriber">
<xsl:if test="(position() mod $nullDays) = 0">
<xsl:element name="div">
<xsl:attribute name="class">empty-div</xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
ありがとうございました!