C#,vb.net,MVC,Jquery,javascript,jscript,vbscript,html,vb,sharepoint,COM,WPF,WCF,Wwf,Asp,Asp.net,questions & answers,

Latest in Sports

Monday, September 10, 2012

Not able to read field value in XSLT while using CQWP


Hi Experts,
We are using CQWP in our application for fetching the data from PageLibrary.
We have used XSLT for formatting the fetched data and displaying it in the page.
As a part of adding more fields in the CQWP, we
Ø  Created SiteColumn (e.g. internal name of site column is TestColumn) and added it in the PageLibrary
Ø  We added the SiteColumn in the CQWP’s DataMappingViewFields property. Please see below highlighted portion which is the newly added SiteColumn
                        DataMappingViewFields="ItemDate,DateTime;Title,Text;TestColumn,Text"
Ø  We did following changes in the existing XSLT file:
<xsl:template name="OuterTemplate.GetTestingData">
                <xsl:param name="TestingData"/>
                <xsl:value-of select="$TestColumn" disable-output-escaping="yes"/>
  </xsl:template>
<xsl:variable name="TestColVal">
        <xsl:call-template  name="OuterTemplate.GetTestingData">
          <xsl:with-param name="TestingData" select="@TestColumn"/>
        </xsl:call-template>
      </xsl:variable>
<div>
<xsl:value-of select="$TestColVal"/>
</div>                  
However, The value returned is blank here. Please let us know where we are going wrong as I am not the XSLT expert.
Appreciate early responses.
Regards,
Deepak

SOLUTION 1:
Use the below XSL template and check what are the internal names of all your fields. Use the internal names of these columns in your XSLT.
<xsl:template name="AllFields" match="Row[@Style='AllFields']" mode="itemstyle">
            <xsl:for-each select="@*">
                P:<xsl:value-of select="name()" />
                <xsl:text>--</xsl:text>
            </xsl:for-each>
    </xsl:template>   
Hope this helps.

SOLUTION 2:
If you have verified your xslt and has no bugs... you need to export cqwp and edit exported xml of cqwp by adding additional field and its data type in commonviewfield tag..

Please refer:  http://msdn.microsoft.com/en-us/library/aa981241.aspx

Regards,
Ankur

No comments:

Post a Comment