views:

423

answers:

1

Hi,

I have a Content Query Webpart (CQWP) pulling the URL and title from a NewsLinks list. The CQWP uses the XSLT style LVIS.News.Links defined in ItemStyle.xsl.

I need to sort the title @Title0 field as commented out below because it causes an error.

Does anyone know whats causing this error? - Many Thanks. The XSLT code is below:

<xsl:template name="LVIS.News.Links" match="Row[@Style='LVIS.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  A: 

I need to sort the title @Title0 field as commented out below because it causes an error.

Does anyone know whats causing this error?

Yes, <xsl:sort/> can only be a child node of either <xsl:apply-templates> or <xsl:for-each> (and of <xsl:perform-sort> in XSLT 2.0).

Recommendation: Take at least a mini-course in XSLT and XPath so that you at least grok the fundamental concepts.

Dimitre Novatchev
up voted for the use of the word grok.
nav