Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2010, 06:31 PM
Registered User
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default The variable or parameter "isdocument' is either not defined or it is out of scope

I am new to XSL language and I get this error with edited code:
"The variable or parameter "isdocument' is either not defined or it is out of scope"

Here is my line of code I am getting the error in:

<span class="srch-Title">
<a href="{$url}" id="{concat('CSR_',$id)}" title="{$url}">

<!-- this is where the error is -->
<xsl:if test="$isdocument = 1">
<!-- this is where the error ends -->

<xsl:value-of select="filename"/>
</xsl:if>

<!-- this is where the error is -->
<xsl:if test="$isdocument = 0">
<!-- this is where the error ends -->

<xsl:choose>
<xsl:when test="hithighlightedproperties/HHTitle[. != '']">
<xsl:call-template name="HitHighlighting">
<xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</a>

I'm currently stuck on this issue where sharepoint won't display the document titles but it displays the first letter inside of the document such as the title would be: B
instead of providing the documents name.

The reason I want to change this is when I search for a document I get documents that pull the first letter of the document such as when I search for the word example:

B
here is a brief example of you searched for example but the first letter in the document is B so sharepoint pulls B as the title.
www.example.com/folder/example_document.doc

And here's what I want:

Example_document.doc
here is a brief example of you searched for example but the first letter in the document is B so sharepoint pulls B as the title.
www.example.com/folder/example_document.doc

Any ideas where to start? Thanks

Last edited by JDarling; November 17th, 2010 at 08:56 PM..
 
Old November 17th, 2010, 07:08 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The message is saying you can't refer to $isdocument unless you have declared it somewhere (in an xsl:variable or xsl:param), and the declaration is "in scope", which means it is either global, or it is a preceding sibling of the an ancestor of the xsl:if instruction where the variable is referenced.

You haven't shown the whole stylesheet, so I can't tell whether the variable is undeclared, or whether the declaration is out of scope.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old November 17th, 2010, 08:16 PM
Registered User
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry about that Mhkay. Here is the full code attached.

<xsl:param name="ResultsBy" />
<xsl:param name="ViewByUrl" />
<xsl:param name="ViewByValue" />
<xsl:param name="IsNoKeyword" />
<xsl:param name="IsFixedQuery" />
<xsl:param name="ShowActionLinks" />
<xsl:param name="MoreResultsText" />
<xsl:param name="MoreResultsLink" />
<xsl:param name="CollapsingStatusLink" />
<xsl:param name="CollapseDuplicatesText" />
<xsl:param name="AlertMeLink" />
<xsl:param name="AlertMeText" />
<xsl:param name="SrchRSSText" />
<xsl:param name="SrchRSSLink" />
<xsl:param name="ShowMessage" />
<xsl:param name="IsThisListScope" />
<xsl:param name="DisplayDiscoveredDefinition" select="True" />
<xsl:param name="NoFixedQuery" />
<xsl:param name="NoKeyword" />
<xsl:param name="NoResults" />
<xsl:param name="NoResults1" />
<xsl:param name="NoResults2" />
<xsl:param name="NoResults3" />
<xsl:param name="NoResults4" />
<xsl:param name="DefinitionIntro" />

<!-- When there is keywory to issue the search -->
<xsl:template name="dvt_1.noKeyword">
<span class="srch-description">
<xsl:choose>
<xsl:when test="$IsFixedQuery">
<xsl:value-of select="$NoFixedQuery" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$NoKeyword" />
</xsl:otherwise>
</xsl:choose>
</span>
</xsl:template>


<!-- When empty result set is returned from search -->
<xsl:template name="dvt_1.empty">
<div class="srch-sort">
<xsl:if test="$AlertMeLink and $ShowActionLinks">
<span class="srch-alertme" >
<a href ="{$AlertMeLink}" id="CSR_AM1" title="{$AlertMeText}">
<img style="vertical-align: middle;" src="/_layouts/images/bell.gif" alt="" border="0"/>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="$AlertMeText" />
</a>
</span>
</xsl:if>

<xsl:if test="string-length($SrchRSSLink) &gt; 0 and $ShowActionLinks">
<xsl:if test="$AlertMeLink">
|
</xsl:if>
<a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL">
<img style="vertical-align: middle;" border="0" src="/_layouts/images/rss.gif" alt=""/>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="$SrchRSSText"/>
</a>
</xsl:if>
</div>
<br/>
<br/>

<span class="srch-description" id="CSR_NO_RESULTS">
<xsl:value-of select="$NoResults" />

<ol>
<li>
<xsl:value-of select="$NoResults1" />
</li>
<li>
<xsl:value-of select="$NoResults2" />
</li>
<li>
<xsl:value-of select="$NoResults3" />
</li>
<li>
<xsl:value-of select="$NoResults4" />
</li>
</ol>
</span>
</xsl:template>


<!-- Main body template. Sets the Results view (Relevance or date) options -->
<xsl:template name="dvt_1.body">
<div class="srch-results">
<xsl:if test="$ShowActionLinks">
<div class="srch-sort">
<xsl:value-of select="$ResultsBy" />
<xsl:if test="$ViewByUrl">
|
<a href ="{$ViewByUrl}" id="CSR_RV" title="{$ViewByValue}">
<xsl:value-of select="$ViewByValue" />
</a>
</xsl:if>
<xsl:if test="$AlertMeLink">
|
<span class="srch-alertme" >
<a href ="{$AlertMeLink}" id="CSR_AM2" title="{$AlertMeText}">
<img style="vertical-align: middle;" src="/_layouts/images/bell.gif" alt="" border="0"/>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="$AlertMeText" />
</a>
</span>
</xsl:if>
<xsl:if test="string-length($SrchRSSLink) &gt; 0">
|
<a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL">
<img style="vertical-align: middle;" border="0" src="/_layouts/images/rss.gif" alt=""/>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="$SrchRSSText"/>
</a>
</xsl:if>
</div>
<br />
<br />
</xsl:if>
<xsl:apply-templates />

</div>
<xsl:call-template name="DisplayMoreResultsAnchor" />
</xsl:template>
<!-- This template is called for each result -->
<xsl:template match="Result">
<xsl:variable name="id" select="id"/>
<xsl:variable name="filename" select="filename" />
<xsl:variable name="url" select="url"/>
<span class="srch-Icon">
<a href="{$url}" id="{concat('CSR_IMG_',$id)}" title="{$url}">
<img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" />
</a>
</span>
<span class="srch-Title">
<a href="{$url}" id="{concat('CSR_',$id)}" title="{$url}">
<xsl:if test="$isdocument = 1">
<xsl:value-of select="filename"/>
</xsl:if>
<xsl:if test="$isdocument = 0">
<xsl:choose>
<xsl:when test="hithighlightedproperties/HHTitle[. != '']">
<xsl:call-template name="HitHighlighting">
<xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</a>
<br/>
</span>

<xsl:choose>
<xsl:when test="$IsThisListScope = 'True' and contentclass[. = 'STS_ListItem_PictureLibrary'] and picturethumbnailurl[. != '']">
<div style="padding-top: 2px; padding-bottom: 2px;">
<a href="{$url}" id="{concat('CSR_P',$id)}" title="{title}">
<img src="{picturethumbnailurl}" alt="" />
</a>
</div>
</xsl:when>
</xsl:choose>
<div class="srch-Description">
<xsl:choose>
<xsl:when test="hithighlightedsummary[. != '']">
<xsl:call-template name="HitHighlighting">
<xsl:with-param name="hh" select="hithighlightedsummary" />
</xsl:call-template>
</xsl:when>
<xsl:when test="description[. != '']">
<xsl:value-of select="description"/>
</xsl:when>
</xsl:choose>
</div >
<p class="srch-Metadata">
<span class="srch-URL">
<a href="{$url}" id="{concat('CSR_U_',$id)}" title="{$url}" dir="ltr">
<xsl:choose>
<xsl:when test="hithighlightedproperties/HHUrl[. != '']">
<xsl:call-template name="HitHighlighting">
<xsl:with-param name="hh" select="hithighlightedproperties/HHUrl" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="url"/>
</xsl:otherwise>
</xsl:choose>
</a>
</span>
<xsl:call-template name="DisplaySize">
<xsl:with-param name="size" select="size" />
</xsl:call-template>
<xsl:call-template name="DisplayString">
<xsl:with-param name="str" select="author" />
</xsl:call-template>
<xsl:call-template name="DisplayString">
<xsl:with-param name="str" select="write" />
</xsl:call-template>
<xsl:call-template name="DisplayCollapsingStatusLink">
<xsl:with-param name="status" select="collapsingstatus"/>
<xsl:with-param name="urlEncoded" select="urlEncoded"/>
<xsl:with-param name="id" select="concat('CSR_CS_',$id)"/>
</xsl:call-template>
</p>
</xsl:template>

<xsl:template name="HitHighlighting">
<xsl:param name="hh" />
<xsl:apply-templates select="$hh"/>
</xsl:template>

<xsl:template match="ddd">

</xsl:template>
<xsl:template match="c0">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c1">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c2">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c3">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c4">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c5">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c6">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c7">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c8">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c9">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>


<!-- The size attribute for each result is prepared here -->
<xsl:template name="DisplaySize">
<xsl:param name="size" />
<xsl:if test='string-length($size) &gt; 0'>
<xsl:if test="number($size) &gt; 0">
-
<xsl:choose>
<xsl:when test="round($size div 1024) &lt; 1">
<xsl:value-of select="$size" /> Bytes
</xsl:when>
<xsl:when test="round($size div (1024 *1024)) &lt; 1">
<xsl:value-of select="round($size div 1024)" />KB
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="round($size div (1024 * 1024))"/>MB
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>
</xsl:template>



<!-- A generic template to display string with non 0 string length (used for author and lastmodified time -->
<xsl:template name="DisplayString">
<xsl:param name="str" />
<xsl:if test='string-length($str) &gt; 0'>
-
<xsl:value-of select="$str" />
</xsl:if>
</xsl:template>

<!-- document collapsing link setup -->
<xsl:template name="DisplayCollapsingStatusLink">
<xsl:param name="status"/>
<xsl:param name="urlEncoded"/>
<xsl:param name="id"/>
<xsl:if test="$CollapsingStatusLink">
<xsl:choose>
<xsl:when test="$status=1">
<br/>
<xsl:variable name="CollapsingStatusHref" select="concat(substring-before($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'), 'duplicates:&quot;', $urlEncoded, '&quot;', substring-after($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'))"/>
<span class="srch-dup">
[<a href="{$CollapsingStatusHref}" id="$id" title="{$CollapseDuplicatesText}">
<xsl:value-of select="$CollapseDuplicatesText"/>
</a>]
</span>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:template>
<!-- The "view more results" for fixed query -->
<xsl:template name="DisplayMoreResultsAnchor">
<xsl:if test="$MoreResultsLink">
<a href="{$MoreResultsLink}" id="CSR_MRL">
<xsl:value-of select="$MoreResultsText"/>
</a>
</xsl:if>
</xsl:template>

<xsl:template match="All_Results/DiscoveredDefinitions">
<xsl:variable name="FoundIn" select="DDFoundIn" />
<xsl:variable name="DDSearchTerm" select="DDSearchTerm" />
<xsl:if test="$DisplayDiscoveredDefinition = 'True' and string-length($DDSearchTerm) &gt; 0">
<script language="javascript">
function ToggleDefinitionSelection()
{
var selection = document.getElementById("definitionSelection");
if (selection.style.display == "none")
{
selection.style.display = "inline";
}
else
{
selection.style.display = "none";
}
}
</script>
<div>
<a href="#" onclick="ToggleDefinitionSelection(); return false;">
<xsl:value-of select="$DefinitionIntro" />
<b>
<xsl:value-of select="$DDSearchTerm"/>
</b>
</a>
<div id="definitionSelection" class="srch-Description" style="display:none;">
<xsl:for-each select="DDefinitions/DDefinition">
<br/>
<xsl:variable name="DDUrl" select="DDUrl" />
<xsl:value-of select="DDStart"/>
<b>
<xsl:value-of select="DDBold"/>
</b>
<xsl:value-of select="DDEnd"/>
<br/>
<xsl:value-of select="$FoundIn"/>
<a href="{$DDUrl}">
<xsl:value-of select="DDTitle"/>
</a>
</xsl:for-each>
</div>
</div>
</xsl:if>
</xsl:template>

<!-- XSL transformation starts here -->
<xsl:template match="/">
<xsl:if test="$AlertMeLink">
<input type="hidden" name="P_Query" />
<input type="hidden" name="P_LastNotificationTime" />
</xsl:if>
<xsl:choose>
<xsl:when test="$IsNoKeyword = 'True'" >
<xsl:call-template name="dvt_1.noKeyword" />
</xsl:when>
<xsl:when test="$ShowMessage = 'True'">
<xsl:call-template name="dvt_1.empty" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="dvt_1.body"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- End of Stylesheet -->
</xsl:stylesheet>
 
Old November 18th, 2010, 03:16 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You never declare a variable or parameter called "isdocument" anywhere.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old June 6th, 2011, 06:22 AM
Registered User
 
Join Date: Jun 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by samjudson View Post
You never declare a variable or parameter called "isdocument" anywhere.
I had the same issue when trying to follow the instructions in this post. I eventually resolved it by adding the following line:

Code:
<xsl:variable name="isdocument" select="isdocument"/>
under the existing lines:

Code:
<xsl:variable name="id" select="id"/>
<xsl:variable name="filename" select="filename"/>
Hope that helps!
 
Old June 6th, 2011, 06:40 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

That isn't going to solve your problem, mealy mask the error - you've just creating a blank variable called isdocument which makes the error go away, but neither of the two xsl:if statements containing that variable will ever be true if you do that.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old June 6th, 2011, 07:00 AM
Registered User
 
Join Date: Jun 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by samjudson View Post
That isn't going to solve your problem, mealy mask the error - you've just creating a blank variable called isdocument which makes the error go away, but neither of the two xsl:if statements containing that variable will ever be true if you do that.
I think SharePoint somehow provides the value for isdocument, as it does for filename and id.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need code corrections "get sub or function not defined" error" bluesboytoo Excel VBA 1 October 22nd, 2009 11:12 PM
"Add Variable" - Chap 14 ArtP2 BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 4 May 30th, 2009 04:02 PM
Variable scope in XSLT? trufla XSLT 3 October 24th, 2008 01:45 PM
the scope of variable ccj_999 C++ Programming 9 October 26th, 2006 10:35 AM
Variable with application scope madhukp PHP How-To 0 January 8th, 2005 12:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.