Jump to content

Exception raised from XslCompiledTransformation


lionfish

Recommended Posts

Hi, AllI am new to XSLT. I got an exception when running XslCompiledTransformation to load a testing XSL style sheet in ASP.NET 4.0 environment.Following is the style sheet and the error message. What is wrong with it?Thanks.

<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"	xmlns:ContextState="urn:contextstate"	xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl ContextState">  <xsl:output version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" media-type="text/html"/>  <xsl:template match="/">test</xsl:template>  <xsl:template match="/Inputs" mode="cmpm_affildata" priority="10">	<xsl:text>ip=</xsl:text><xsl:value-of select="$ip"/>	<xsl:text>&ua=</xsl:text>	<xsl:value-of select="$useragent"/>	<xsl:text>&xfip=</xsl:text>  </xsl:template>  <xsl:template match="/Inputs" mode="dm_affildata" priority="10">	<xsl:text>ip=</xsl:text><xsl:value-of select="$ip"/>&xfip=&ua=<xsl:value-of select="$useragent"/>&al=<xsl:value-of select="language"/>&ur=<xsl:value-of select="$userreferrer"/>  </xsl:template>  <xsl:template match="/Inputs" mode="shieldsfxenabled" priority="10">false</xsl:template>  <xsl:template match="/Inputs" mode="typetag_global_logic" priority="10">	<xsl:choose>	  <xsl:when test="$visitortype>0">TYPE10</xsl:when>	  <xsl:otherwise>		<xsl:variable name="localAdsource"><xsl:value-of select="InputUsageMapper:ToLower($adsource)"/></xsl:variable>		<xsl:variable name="localTrafficType"><xsl:value-of select="InputUsageMapper:ToLower($traffictype)"/></xsl:variable>		<xsl:choose>		  <xsl:when test="starts-with($localAdsource, 'email')">TYPE128</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adwordsca') and starts-with($localTrafficType, 'content')">TYPE17</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adwordsca') and starts-with($localTrafficType, 'search')">TYPE16</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adwords') and starts-with($usercountry, 'ca') and starts-with($localTrafficType, 'content')">TYPE17</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adwords') and starts-with($usercountry, 'ca') and starts-with($localTrafficType, 'search')">TYPE16</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adwords') and starts-with($localTrafficType, 'content')">TYPE9</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adwords')">TYPE2</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'yahoo-content')">TYPE70</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'ov') or starts-with($localAdsource, 'yahoo')">TYPE3</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'msnca') or starts-with($localAdsource, 'msn-ca') or starts-with($localAdsource, 'msn-canada')">TYPE11</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'msn-content')">TYPE12</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'msn')">TYPE4</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'ak-a')">TYPE121</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'ak-b')">TYPE122</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'ak-c')">TYPE123</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'ak') or starts-with($localAdsource, 'aj')">TYPE5</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'superpages') or starts-with($localAdsource, 'spages') or starts-with($localAdsource, 'verizon')">TYPE6</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'industrybrains')">TYPE13</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'kaboose')">TYPE15</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'textlink')">TYPE18</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'ask')">TYPE19</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'yieldy')">TYPE20</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo21')">TYPE21</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo22')">TYPE22</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo23')">TYPE23</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo24')">TYPE24</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo25')">TYPE25</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'ydr')">TYPE26</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'padwords-content')">TYPE67</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'padwords') and starts-with($localTrafficType, 'content')">TYPE67</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'padwords')">TYPE40</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'pyahoo-content')">TYPE68</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'pyahoo') and starts-with($localTrafficType, 'content')">TYPE68</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'pyahoo')">TYPE41</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'pmsn-content')">TYPE69</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'pmsn') and starts-with($localTrafficType, 'content')">TYPE69</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'pmsn')">TYPE42</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo43')">TYPE43</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo44')">TYPE44</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo45')">TYPE45</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo46')">TYPE46</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo47')">TYPE47</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo48')">TYPE48</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo49')">TYPE49</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo50')">TYPE50</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo51')">TYPE51</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo52')">TYPE52</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo53')">TYPE53</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo54')">TYPE54</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo55')">TYPE55</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo56')">TYPE56</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tsavo57')">TYPE57</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'looksmart-a')">TYPE58</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'looksmart-b')">TYPE59</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'looksmart-c')">TYPE60</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'looksmart-d')">TYPE61</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'looksmart-e')">TYPE62</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'looksmart')">TYPE14</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'miva-a')">TYPE63</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'miva-b')">TYPE64</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'miva-c')">TYPE65</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'miva-d')">TYPE66</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'miva')">TYPE7</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'rmx')">TYPE71</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'gnation')">TYPE80</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adcom-1')">TYPE97</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adcom-2')">TYPE35</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adcom-3')">TYPE162</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adcom-4')">TYPE140</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adcom-5')">TYPE133</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adcom-6')">TYPE126</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'adcom')">TYPE81</xsl:when>		  <xsl:when test="starts-with($localAdsource, '207media')">TYPE84</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tv-text')">TYPE85</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'tv-display')">TYPE86</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'infolinks')">TYPE90</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'kontera')">TYPE91</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'vibrant')">TYPE92</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'reply-com')">TYPE93</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'ezanga')">TYPE94</xsl:when>		  <xsl:when test="starts-with($localAdsource, 'carepages')">TYPE8</xsl:when>		  <xsl:when test="string-length($adsource)>0">TYPE8</xsl:when>		  <xsl:otherwise>TYPE1</xsl:otherwise>		</xsl:choose>	  </xsl:otherwise>	</xsl:choose>  </xsl:template>  <xsl:template match="/Inputs" mode="isinternalrequest" priority="10">	<xsl:variable name="isinternal"><xsl:value-of select="InputUsageMapper:IsInternalRequest()" /></xsl:variable>	<xsl:choose>	  <xsl:when test="$isinternal='true' and string-length(/Inputs/QueryStringParameters/userhostaddress)>0">false</xsl:when>	  <xsl:otherwise><xsl:value-of select="$isinternal"/></xsl:otherwise>	</xsl:choose>  </xsl:template>  <xsl:template match="/Inputs[Blocks/Block/@type='WebFx.Blocks.ClickTrack']" mode="logsession" priority="10">false</xsl:template>  <xsl:template match="/Inputs[Blocks/Block/@type='WebFx.Blocks.DisabledCookieTracker']" mode="logsession" priority="10">false</xsl:template>  <xsl:template match="/Inputs[contains(/Inputs/ServerVariables/path_info, 'favicon.ico')]" mode="logsession" priority="9">false</xsl:template>  <xsl:template match="/Inputs[contains(/Inputs/ServerVariables/path_info, 'robots.txt')]" mode="logsession" priority="9">false</xsl:template>  <xsl:template match="/Inputs[contains(/Inputs/ServerVariables/path_info, '.jpg')]" mode="logsession" priority="9">false</xsl:template>  <xsl:template match="/Inputs[contains(/Inputs/ServerVariables/path_info, '.gif')]" mode="logsession" priority="9">false</xsl:template>  <xsl:template match="/Inputs[contains(/Inputs/ServerVariables/path_info, '.css')]" mode="logsession" priority="9">false</xsl:template>  <xsl:template match="/Inputs" mode="enablescriptinsertswebtrends" priority="10">false</xsl:template></xsl:stylesheet>

exception:

{"The variable or parameter 'ip' is either not defined or it is out of scope."}
System.Exception {System.Xml.Xsl.XslLoadException}
Link to comment
Share on other sites

You have code like

<xsl:value-of select="$ip"/>

referencing a variable or parameter named "ip" that is not defined in your stylesheet.I also note you are using version="2.0" on your stylesheet though you say you use XslCompiledTransform which is an XSLT 1.0 processor. I strongly suggest you use version="1.0" as otherwise XslCompiledTransform runs in forwards compatible mode. But that suggestion is a general one, it is not related to that error you get.

Link to comment
Share on other sites

Thanks, you are right. That's the problem.There is another part of the file was missing which including the definition.

<xsl:variable name="ip">

You have code like
<xsl:value-of select="$ip"/>

referencing a variable or parameter named "ip" that is not defined in your stylesheet.I also note you are using version="2.0" on your stylesheet though you say you use XslCompiledTransform which is an XSLT 1.0 processor. I strongly suggest you use version="1.0" as otherwise XslCompiledTransform runs in forwards compatible mode. But that suggestion is a general one, it is not related to that error you get.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...