|
|
Rank: Devotee
Joined: 9/7/2007 Posts: 32
|
After setting a variable which gets the rootFolderId from a page parameter the following code: Code:<xsl:apply-templates select="umbraco.library:GetMedia($rootFolderId, 'true')/node"/> returns this error: Code:ErrorsError occured System.Xml.XPath.XPathException: Function 'umbraco.library:GetMedia()' has failed. ---> 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, TypeCode typeCode, IFormatProvider provider) at System.Xml.Xsl.XsltOld.XsltCompileContext.XsltFunctionImpl.ToNumeric(Object argument, TypeCode typeCode) at System.Xml.Xsl.XsltOld.XsltCompileContext.XsltFunctionImpl.ConvertToXPathType(Object val, XPathResultType xt, TypeCode typeCode) at System.Xml.Xsl.XsltOld.XsltCompileContext.FuncExtension.Invoke(XsltContext xsltContext, Object[] args, XPathNavigator docContext) at MS.Internal.Xml.XPath.FunctionQuery.Evaluate(XPathNodeIterator nodeIterator) --- End of inner exception stack trace --- at MS.Internal.Xml.XPath.FunctionQuery.Evaluate(XPathNodeIterator nodeIterator) at MS.Internal.Xml.XPath.BaseAxisQuery.Evaluate(XPathNodeIterator nodeIterator) at System.Xml.Xsl.XsltOld.Processor.StartQuery(XPathNodeIterator context, Int32 key) at System.Xml.Xsl.XsltOld.ApplyTemplatesAction.Execute(Processor processor, ActionFrame frame) at System.Xml.Xsl.XsltOld.ActionFrame.Execute(Processor processor) at System.Xml.Xsl.XsltOld.Processor.Execute() at System.Xml.Xsl.XsltOld.Processor.Execute(TextWriter writer) at System.Xml.Xsl.XslTransform.Transform(XPathNavigator input, XsltArgumentList args, TextWriter output, XmlResolver resolver) at System.Xml.Xsl.XslTransform.Transform(IXPathNavigable input, XsltArgumentList args, TextWriter output, XmlResolver resolver) at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String fileContents, Boolean ignoreDebugging) However if I select skip testing the code works perfectly. If I use a hard coded value in place of the variable it saves ok.
|
|
 Rank: Aficionado
Joined: 8/12/2006 Posts: 136 Location: Norway
|
Wrap the whole schabong in a Code: <xsl:if test="$rootFolderId != ''">
code goes here
</xsl:if>
Kenneth Solberg - xeed* - core dev - level 2 cert pro - my blog
|
|
Rank: Devotee
Joined: 9/7/2007 Posts: 32
|
Perfect! Works a treat. Thanks.
|
|
Rank: Newbie
Joined: 9/26/2007 Posts: 10
|
Hi Im trying to understand this error also. can u see what im doing wrong here?
I get
System.Xml.XPath.XPathException: Function 'umbraco.library:NiceUrl()' has failed. ---> System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value)
when i try this
<xsl:if test="string($currentPage/data [@alias='mediaID']) != '' ">
<xsl:value-of select="umbraco.library:NiceUrl(umbraco.library:GetXmlNodeById(/macro/mediaID))" />
</xsl:if>
in the template
<Media> <?UMBRACO_GETITEM field="imgMedia"/> <-- this works ok outputs my ID Correctly 1116 <?UMBRACO_MACRO macroAlias="GetImage" currentID="[#pageID]" mediaID="1116"> </?UMBRACO_MACRO> </Media>
Ideally mediaID isnt a hardcoded value but I havent quite sussed the passing of field values into the variable
any assistance would be awesome..banged my head for a day already :tease:
|
|
Rank: Devotee
Joined: 9/7/2007 Posts: 32
|
I can't remember the specfics but here is the code that I settled on to get it work - hope it helps... Code:<xsl:variable name="rootFolderId"> <xsl:choose> <xsl:when test="/macro/rootFolderId != ''"> <xsl:value-of select="/macro/rootFolderId"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$currentPage/data [@alias = 'fundDocumentsID']"/> </xsl:otherwise> </xsl:choose> </xsl:variable>
<xsl:template match="/"> <xsl:if test="$rootFolderId != ''"> <xsl:apply-templates select="umbraco.library:GetMedia($rootFolderId, 'true')/node"/> </xsl:if> </xsl:template>
<xsl:template match="node">
<!--template content here-->
</xsl:template> And the macro called in the template: Code:<?UMBRACO_MACRO macroAlias="RenderAllFundDocumentsWithArchive" rootFolderId="" fundToDisplay=""></?UMBRACO_MACRO>
|
|
Rank: Newbie
Joined: 9/26/2007 Posts: 10
|
Bruce this was a huge help, thanks a bunch for that :) All working now :w00t:
|
|
|
Guest |