title: Umbraco XSLT - Retrieving a nodes 'pageImage' when listing
body: <p>I've got a news page on my site, which lists all the subpages (news articles) in a macro.</p>
  
  <p>Each of the subpages has an image (alias pageImage)</p>
  
  <p>I've got the following XSLT code, but It's not working:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE xsl:stylesheet [ &lt;!ENTITY nbsp "&amp;#x00A0;"&gt; ]&gt;
  &lt;xsl:stylesheet 
      version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:msxml="urn:schemas-microsoft-com:xslt" 
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "&gt;
  
  &lt;xsl:output method="xml" omit-xml-declaration="yes"/&gt;
  
  &lt;xsl:param name="currentPage"/&gt;
  
  &lt;xsl:template match="/"&gt;
  
  &lt;!-- The fun starts here --&gt;
  &lt;ul id="reports"&gt;
  &lt;xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']"&gt;
  &lt;xsl:sort select="@createDate" order="descending" /&gt;
      &lt;li&gt;
          &lt;img&gt;
              &lt;xsl:attribute name="src"&gt;
                  &lt;xsl:text&gt;/umbraco/ImageGen.ashx?image=&lt;/xsl:text&gt;
                  &lt;xsl:value-of select="umbraco.library:GetMedia(data[@alias='pageImage'],'true')/data[@alias='umbracoFile']"/&gt;
                  &lt;xsl:text&gt;&amp;amp;width=125&amp;amp;height=125&amp;amp;constrain=true&amp;amp;pad=true&amp;amp;BgColor=white&amp;amp;transparent=false&lt;/xsl:text&gt;
              &lt;/xsl:attribute&gt;
              &lt;xsl:attribute name="alt"&gt;
                  &lt;xsl:value-of select="something"/&gt;
              &lt;/xsl:attribute&gt;
          &lt;/img&gt;
          &lt;h2&gt;&lt;a href="{umbraco.library:NiceUrl(@id)}"&gt;&lt;xsl:value-of select="@nodeName"/&gt;&lt;/a&gt;&lt;/h2&gt;
          &lt;p class="date"&gt;&lt;xsl:value-of select="data [@alias = 'date']" disable-output-escaping="yes"/&gt;&lt;/p&gt;
          &lt;p&gt;Mauris sit amet augue ut felis blandit placerat. Sed tempus gravida libero. Donec placerat lacus 
          eget neque. Mauris sit amet augue ut felis blandit placerat. Sed tempus gravida libero.&lt;/p&gt;
          &lt;p&gt;&lt;a&gt;&lt;img src="images/pdf.gif" alt="Download/view PDF" align="left" /&gt; Download/View PDF&lt;/a&gt; - 82kb&lt;/p&gt;
      &lt;/li&gt;
  &lt;/xsl:for-each&gt;
  &lt;/ul&gt;
  
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>And the error it's giving me is:</p>
  
  <pre><code>Error occured
  
  System.OverflowException: Value was either too large or too small for an Int32. 
  at System.Convert.ToInt32(Double value) 
  at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) 
  at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) 
  at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType) 
  at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) 
  at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
  at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
  at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
  at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) 
  at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter) 
  at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results) 
  at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results) 
  at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) 
  at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\umbraco\presentation\umbraco\webservices\codeEditorSave.asmx.cs:line 124
  </code></pre>
  
  <p>Anybody have any idea what's going wrong? I know it's something to do with the <code>&lt;xsl:value-of select="umbraco.library:GetMedia(data[@alias='pageImage'],'true')/data[@alias='umbracoFile']"/&gt;</code> line as if I hardcode an image URL, it works fine.</p>
  
  <p>Thanks!</p>