传递给模板的变量被篡改

时间:2012-02-15 13:09:03

标签: xslt xpath umbraco

<xsl:param name="currentPage"/>

<xsl:param name="group-size" select="'2'" />

<xsl:template match="/">

<xsl:variable name="userBlogSource" select="umbraco.library:GetXmlNodeById(umbraco.library:GetDictionaryItem('WeblogNode'))/node [string(data [@alias='umbracoNaviHide']) != '1' and data[@alias='author'] = $currentPage/@id]" />
<xsl:for-each select="$userBlogSource">
  <xsl:sort select="data[@alias='dato']" order="descending" />
</xsl:for-each>

<xsl:if test="count($userBlogSource) &gt; 0">

  <h3><xsl:value-of select="umbraco.library:GetDictionaryItem('BlogpostsWrittenBy')"/>&nbsp;<xsl:value-of select="$currentPage/@nodeName" />:</h3>

  <xsl:apply-templates select="$userBlogSource[(position() mod $group-size) = 1]" />

  <ul>
    <xsl:for-each select="$userBlogSource">
      <li>
        <a rel="bookmark" href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}">
          <xsl:value-of select="@nodeName" />
        </a>
      </li>
    </xsl:for-each>
  </ul>

</xsl:if>

</xsl:template>

<xsl:template match="node">
  <xsl:variable name="postnum" select="position()" />
  <div class="weblog-posts-wrap">
    <ul>

      <xsl:for-each select=". | following-sibling::node[position() &lt; $group-size]">
        <li>
          <a rel="bookmark" href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}">
            <xsl:value-of select="@nodeName" />
          </a>
        </li>
      </xsl:for-each>

    </ul>
  </div>
</xsl:template>

当我检查$ userBlogSource的计数时,它包含三个元素。当我尝试在常规XSLT for循环中打印时,它会打印正确的元素。但是当变量传递给第二个模板匹配节点时,内容突然不同。它不应包含它应包含的三个节点,而是由完全不同的作者包含4个节点。

知道我可能做错了什么?

0 个答案:

没有答案