扩展/折叠xslt中的嵌套节点(第2部分)

时间:2011-06-21 19:45:54

标签: xslt

这是我之前的帖子expanding/collapsing nested nodes in xslt

的延续

出于某种原因,我无法在之前的帖子中添加评论。

我尝试了提供的解决方案,只有一个基期时它才有用。如果有多个基期,则不起作用。

请注意,我正在使用IE8。

1 个答案:

答案 0 :(得分:0)

我认为处理多个基期是相当容易的。简单的方法是为subper_expand div容器(及其锚点)添加第二个标识符,以便在各个基本周期中区分它们,即:

subper_expand{base period position}_{periond position}

<强> BasePeriod:

<xsl:apply-templates select="Period">
    <xsl:with-param name="bpPos" select="position()"/>
</xsl:apply-templates>

<强>周期:

<xsl:param name="bpPos"/>

<xsl:variable name="subper">
    <xsl:value-of select="concat('subper_expand', $bpPos, '_', position())"/>
</xsl:variable>
<xsl:variable name="subperiod">
    <xsl:value-of select="concat('subperiod_expand', $bpPos, '_', position())"/>
</xsl:variable>
...
<a href="javascript:expandIt({$subper}, {$subperiod})"
   name="{$subperiod}" class="expandit">Sub Periods</a>
<div id="{$subper}" style="display:none;">

如您所见,使用xsl的变量看起来更具可读性。