在xslt中扩展/折叠嵌套节点第2部分

问题描述

| 这是我之前的文章在xslt中扩展/折叠嵌套节点的延续 由于某些原因,我无法在我的上一篇文章添加评论。 我尝试了提供的解决方案,并且在只有一个基准周期的情况下可以使用。如果有多个基准期,则不起作用。 请注意,我正在使用IE8。     

解决方法

        我认为处理多个基期相当容易。一种简单的方法是为“ 0” 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\',position())\"/>
</xsl:variable>
...
<a href=\"javascript:expandIt({$subper},{$subperiod})\"
   name=\"{$subperiod}\" class=\"expandit\">Sub Periods</a>
<div id=\"{$subper}\" style=\"display:none;\">
如您所见,使用xsl \的变量看起来更具可读性。