MOSS内容查询Web部件itemstyle.xsl

时间:2010-04-22 23:53:35

标签: sharepoint xslt sharepoint-2007 web-parts

我有一个内容查询Webpart(CQWP)从新闻链接列表中提取URL和标题。 CQWP使用ItemStyle.xsl中定义的XSLT样式Orange.News.Links。

我需要对标题@ Title0字段进行排序,如下所示,因为它会导致错误。

有谁知道导致此错误的原因是什么? - 非常感谢。 XSLT代码如下:

<xsl:template name="Orange.News.Links" match="Row[@Style='Orange.News.Links']" mode="itemstyle">
     <xsl:param name="CurPos" />
     <xsl:param name="Last" />       

   <xsl:variable name="SafeLinkUrl">
            <xsl:call-template name="OuterTemplate.GetSafeLink">
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="DisplayTitle">
            <xsl:call-template name="OuterTemplate.GetTitle">
                <xsl:with-param name="Title" select="@URL"/>
                <xsl:with-param name="UrlColumnName" select="'URL'"/>
            </xsl:call-template>
        </xsl:variable>

        <xsl:variable name="LinkTarget">
            <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
        </xsl:variable>

        <xsl:variable name="SafeImageUrl">
            <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
                <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
            </xsl:call-template>
        </xsl:variable>

        <xsl:variable name="Header">
  <xsl:if test="$CurPos = 1">
   <![CDATA[<ul class="list_Links">]]>  
  </xsl:if>
  </xsl:variable>

  <xsl:variable name="Footer">
   <xsl:if test="$Last = $CurPos">
    <![CDATA[</ul>]]>   
    </xsl:if>
  </xsl:variable> 

  <xsl:value-of select="$Header" disable-output-escaping="yes" />


  <li> 
   <a>
       <xsl:attribute name="href">
        <xsl:value-of select="substring-before($DisplayTitle,', ')"></xsl:value-of>
       </xsl:attribute>
       <xsl:attribute name="title">
        <xsl:value-of select="@Description"/>
           </xsl:attribute>
        <!--    <xsl:sort select="@Title0"/> -->
       <xsl:value-of select="@Title0">
       </xsl:value-of>
   </a>
  </li>


  <xsl:value-of select="$Footer" disable-output-escaping="yes" />


    </xsl:template> 

1 个答案:

答案 0 :(得分:1)

  

我需要对标题@ Title0字段进行排序   如下所述,因为它   导致错误。

     

有谁知道造成这种情况的原因   错误?

是的, <xsl:sort/>只能是<xsl:apply-templates><xsl:for-each>(以及XSLT 2.0中的<xsl:perform-sort>)的子节点。 / p>

推荐:至少参加XSLT和XPath中的小型课程,以便至少了解基本概念。