質問

Sitecoreノードのセットがあります:

<item>
  <item>
    <item />    
  </item>
  <item /> <!-- (1) -->
  <item />
</item>
<item>
  <item />
  <item />
</item>

関数sc:path(。)を使用してこれらのパスを取得できます。関数sc:path(。)は、(1)とマークされたポイントに対して '/ item / item'のようなものを返します。

できることは、パスに基づいてアイテムをグループ化することです。

したがって、私の出力は次のようになります:

<ul>
  <li>in item
    <ul>
...
    </ul>
  </li>
  <li>in item/item
    <ul>
...
    </ul>
  </li>
</ul>

現在、次のコードのように、先行する軸で遊んでいます:

<xsl:for-each select="exsl:node-set($processedResult)/item">
  <xsl:sort 
    select="substring-before(substring-after(sc:path(.),'/sitecore/media library/'),'.aspx')"
    data-type="text"
    order="ascending" />
  <xsl:variable 
    name="path" 
    select="search:GetFriendlyPath('/sitecore/media library/',sc:path(.))" />
    <!-- returns: item/item from /sitecore/media library/item/item/item.aspx -->                    
  <xsl:variable name="lastPath">
    <xsl:choose>
      <xsl:when test="sc:path(preceding)">
        <xsl:value-of 
          select="search:GetFriendlyPath('sitecore/media library',sc:path(preceding))" />
      </xsl:when>
      <xsl:otherwise>none</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>               
  <xsl:if test="$path != $lastPath"> <!-- grouping test -->
    <li>
      <strong>in <xsl:value-of select="$path" /></strong>
    </li>
  </xsl:if>
  <li>
  <!-- render detail -->
  </li>
</xsl:for-each>

...ただしsc:path(preceding)は何も返しません。したがって、私のチェックは機能しません。

何が間違っているのですか?

役に立ちましたか?

解決

あなたが何をするつもりなのか分かりません

<xsl:when test="sc:path(preceding)">

これは、<!> quot;と読み、<preceding>という名前の子をノードセットとしてsc:path() function <!> quot;にフィードします。

入力を見ると、その名前の子要素はありません。

それはあなたのようなものですか?

<xsl:when test="sc:path(preceding-sibling::item[1])">

Sitecoreについて何も知らないので、試してみましょう:

<xsl:for-each select="exsl:node-set($processedResult)/item">
  <xsl:sort select="
    substring-before(
      substring-after(sc:path(.), '/sitecore/media library/'),
      '.aspx'
    )"
    data-type="text"
    order="ascending"
  />
  <xsl:variable name="path" select="
    search:GetFriendlyPath(
      '/sitecore/media library/', sc:path(.)
    )
  " />
  <xsl:variable name="lastPath">
    <xsl:choose>
      <xsl:when test="preceding-sibling::item[1]">
        <xsl:value-of select="
          search:GetFriendlyPath(
            'sitecore/media library', sc:path(preceding-sibling::item[1])
          )"
        />
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>none</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <!-- grouping test -->
  <xsl:if test="$path != $lastPath">
    <li>
      <strong>
        <xsl:text>in </xsl:text>
        <xsl:value-of select="$path" />
      </strong>
    </li>
  </xsl:if>

  <li>
    <!-- render detail -->
  </li>
</xsl:for-each>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top