<!-- The fun starts here --> <ulid="reports"> <xsl:for-eachselect="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']"> <xsl:sortselect="@createDate"order="descending"/> <li> <img> <xsl:attributename="src"> <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text> <xsl:value-ofselect="umbraco.library:GetMedia(data[@alias='pageImage'],'true')/data[@alias='umbracoFile']"/> <xsl:text>&width=125&height=125&constrain=true&pad=true&BgColor=white&transparent=false</xsl:text> </xsl:attribute> <xsl:attributename="alt"> <xsl:value-ofselect="something"/> </xsl:attribute> </img> <h2><ahref="{umbraco.library:NiceUrl(@id)}"><xsl:value-ofselect="@nodeName"/></a></h2> <pclass="date"><xsl:value-ofselect="data [@alias = 'date']"disable-output-escaping="yes"/></p> <p>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.</p> <p><a><imgsrc="images/pdf.gif"alt="Download/view PDF"align="left"/> Download/View PDF</a> - 82kb</p> </li> </xsl:for-each> </ul>
</xsl:template>
</xsl:stylesheet>
And the error it is giving me is:
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
Anybody have any idea what's going wrong? I know it's something to do with the <xsl:value-of select="umbraco.library:GetMedia(data[@alias='pageImage'],'true')/data[@alias='umbracoFile']"/> line as if I hardcode an image URL, it works fine.
I'd prefer the xsl:choose for having a fall-back image.
Use xsl:choose for testing if there is a value. If there is one, set the value, otherwise use a default value. So you allways will have a image, and the layout will not be broken. Create a xsl:variable within the img tag so the img attribute can be set dynamically.
Ah that's solved my problem! It was only breaking if a node didn't have an image, so doing that check has gotten rid of the errors. Thank you very much!
And yes, I will be doing an xsl:choose rather than xsl:if so I can put the fallback image in the xsl:otherwise
Fot those scenarios, I allways create a 'default' directory in my media section. In this folder I upload default images for all kind of doc types in my project.
Retrieving a nodes pageImage when listing
I've got a news page on my site, which lists all the subpages (news articles) in a macro.
Each of the subpages has an image (alias pageImage)
I've got the following XSLT code, but It's not working:
And the error it is giving me is:
Anybody have any idea what's going wrong? I know it's something to do with the
<xsl:value-of select="umbraco.library:GetMedia(data[@alias='pageImage'],'true')/data[@alias='umbracoFile']"/>
line as if I hardcode an image URL, it works fine.Thanks!
Try to check if the pageImage contains a value first.
use xsl:choose for getting the value, use default value if there is no image value.
Would you do the <xsl:choose> within the <xsl:attribute="src">?
I'd probably just do something along the lines of
This just checks to see if the 'pageImage' has a value, and if it does, displays the image, if not, no image is displayed.
Matt
I'd prefer the xsl:choose for having a fall-back image.
Use xsl:choose for testing if there is a value. If there is one, set the value, otherwise use a default value. So you allways will have a image, and the layout will not be broken.
Create a xsl:variable within the img tag so the img attribute can be set dynamically.
[pseudocode]
<img>
<xsl:variable name="imageSource" ...
<xsl:choose ...etc...
</xsl:variable>
<xsl:attribute name="src" value="$imageSource"/>
</img>
Ah that's solved my problem! It was only breaking if a node didn't have an image, so doing that check has gotten rid of the errors. Thank you very much!
And yes, I will be doing an xsl:choose rather than xsl:if so I can put the fallback image in the xsl:otherwise
Fot those scenarios, I allways create a 'default' directory in my media section. In this folder I upload default images for all kind of doc types in my project.
is working on a reply...