Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Following is the XSLT transformation sample code described in Step 3: Create the XSLT Transformation Code for Walkthrough: Creating an ASP.NET Web Part for the AdventureWorks Business Data Application Sample.
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<xsl:variable name="Rows" select="/All_Results/Result" />
<xsl:variable name="RowCount" select="count($Rows)" />
<xsl:variable name="IsEmpty" select="$RowCount = 0" />
<xsl:choose>
<xsl:when test="$IsEmpty">
<xsl:call-template name="dvt_1.empty" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="dvt_1.body"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="dvt_1.empty">
<span class="srch-description" id="CSR_NO_RESULTS">
No results matching your search were found. <ol>
<li>Check your spelling. Are the words in your query spelled correctly?</li>
<li>Try using synonyms. Maybe what you're looking for uses slightly different words.</li>
<li>Make your search more general. Try more general terms in place of specific ones.</li>
<li>Try your search in a different scope. Different scopes can return different results.</li>
</ol>
</span>
</xsl:template>
<xsl:template name="dvt_1.body">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="Result">
<xsl:variable name="id" select="PRODUCTID"/>
<xsl:variable name="url" select="PATH"/>
<span class="srch-Title">
<a href="{$url}" id="{concat('CSR_',$id)}" title="{$url}">
<xsl:value-of select="PRODUCTNAME"/></a>
<br/>
</span>
<span class="srch-Metadata">
<xsl:call-template name="DisplayString">
<xsl:with-param name="str" select="PRODUCTID" />
<xsl:with-param name="prop">Product ID:</xsl:with-param>
</xsl:call-template>
<br/>
</span>
<span class="srch-URL">
<a href="{$url}" id="{concat('CSR_U_',$id)}" title="{$url}">
<xsl:value-of select="PATH"/>
</a><br/><br/>
</span>
</xsl:template>
<xsl:template name="DisplayString">
<xsl:param name="str" />
<xsl:param name="prop" />
<xsl:if test='string-length($str) > 0'>
<xsl:value-of select="$prop" /> <xsl:value-of select="$str" />
</xsl:if>
</xsl:template>
</xsl:stylesheet>
See Also
Tasks
Step 3: Create the XSLT Transformation Code
Walkthrough: Creating an ASP.NET Web Part for the AdventureWorks Business Data Application Sample