开发者

Umbraco XSLT - 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:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<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 ">

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:param name="currentPage"/>

<xsl:template match="/">

<!-- The fun starts here -->
<ul id="reports">
<xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:sort select="@createDate" order="descending" />
    <li>
        <img>
            <xsl:attribute name="src">
                <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text>
                <xsl:value-of select="umbraco.library:GetMedia(data[@alias='pageImage'],'true')/data[@alias='umbracoFile']"/>
                <xsl:text>&amp;width=125&amp;height=125&amp;constrain=true&amp;pad=true&amp;BgColor=white&amp;transparent=false</xsl:text>
            </xsl:attribute>
            <xsl:attribute name="alt">
                <xsl:value-of select="something"/>
            </xsl:attribute>
        </img>
       开发者_Python百科 <h2><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></h2>
        <p class="date"><xsl:value-of select="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><img src="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's 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.

Thanks!


The umbraco.library:GetMedia call expects an integer as the first argument. The error seems to occur when the value of data[@alias='pageImage'] is converted to Int32.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜