XSLT error with umbraco.library:GetMedia() method Options
bruceb
Posted: Thursday, September 20, 2007 3:03:12 PM
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.
kenny
Posted: Sunday, September 23, 2007 2:37:51 PM

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
bruceb
Posted: Monday, September 24, 2007 10:23:47 AM
Rank: Devotee

Joined: 9/7/2007
Posts: 32
Perfect! Works a treat. Thanks.
mikew909
Posted: Thursday, February 07, 2008 9:52:17 AM
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:
bruceb
Posted: Thursday, February 07, 2008 10:17:24 AM
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>
mikew909
Posted: Tuesday, March 04, 2008 1:23:31 PM
Rank: Newbie

Joined: 9/26/2007
Posts: 10
Bruce this was a huge help, thanks a bunch for that :) All working now :w00t:
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.