Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Antony Doyle 6 posts 26 karma points
    Nov 30, 2012 @ 16:50
    Antony Doyle
    0

    XSLT stopped working (mediapicker)

    Hi.

    I'm completely baffled by this, as it was working until today and I haven't touched it. Whether my client has done something, I don't know.

    Basically, I'm using the Embedded Content extension to add a testimonials block to their website.

    It needs an image, a name, link and the quote itself.

    Here's my XSLT;

    <?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" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets PS.XSLTsearch ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    <xsl:for-each select="$siteRoot//*/data/item">
    <li class="testimonial">
    <div class="testimonial-widget-info">
    <img>
    <xsl:attribute name="src">
    <xsl:value-of select="umbraco.library:GetMedia(clientImage, 'false')/umbracoFile"/>
    </xsl:attribute>
    <xsl:attribute name="alt">
    <xsl:value-of select="umbraco.library:GetMedia(clientImage, 'false')/@nodeName"/>
    </xsl:attribute>
    </img>
    <div class="testimonial-widget-meta">
    <span><xsl:value-of select="clientName" /></span>
    <a href="#"><xsl:value-of select="urlClient" /></a>
    </div>
    </div>
    <blockquote><xsl:value-of select="testimonialContent" /></blockquote>
    </li>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    The part that fails is the image. If I remove it, it works. I honestly don't know enough about this to see if anything has changed / what is wrong (I usually work with PHP, .NET is completely alien to me!).

    Can anyone point out where I'm going wrong or what I've missed?

    Thank you!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 30, 2012 @ 19:31
    Jan Skovgaard
    0

    Hi Anthony

    The reason why this sometimes fails is because of the GetMedia extension. If some of your embedded content entries do not have an image the extension is receiving an empty value hence the error.

    To avoid this you can make a check around the code like this:

    <xsl:if test="clientImage">
         <!--<img> stuff here -->
    </xsl:if>

    This should fix it.

    Btw you should use either true() or false() as the second parameter without the pling/single quotes, since that actually evaluates to true in this context. You could also just add either 0 or 1.

    Hope this helps.

    /Jan

  • Antony Doyle 6 posts 26 karma points
    Dec 03, 2012 @ 13:08
    Antony Doyle
    0

    Hi Jan.

    Thank you for your reply.

    I tried your suggestion, but I'm still getting an error. But, if I ignore the error and save, it now works. For referrence, this is the error;

    Error occured
    System.OverflowException: Value was either too large or too small for an Int32.
       at System.Convert.ToInt32(Double value)
       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 System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, 
    XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter 
    writer)
       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)

    I'm a little concerned about leaving it without fixing the error. Is this going to cause me problems down the line?

     

    Thanks again for your help! :)

  • Fergus Davidson 309 posts 588 karma points
    Dec 03, 2012 @ 13:16
    Fergus Davidson
    0

    I agree with Jan - this looks like a GetMedia issue.

    enclosing the <img>...</img> with an if:

    <xsl:if test="normalize-space(clientImage) != ''">
         <!--<img> stuff here -->
    </xsl:if>

    should sort it out.

    you could also just check that all the testimonials have valid entries for the image property - i.e. they actually link to a media item with an image, not to a folder or an empty media item.

    F

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 03, 2012 @ 19:52
    Jan Skovgaard
    0

    Hi Anthony

    Oh you're using the XSLT editor in Umbraco...the reason why it happens when you save the XSLT file is because the gemedia extension does not receive a value untill runtime, which is why it gives an error when you save it within Umbraco.

    But you will see the same error at some point at your site if you don't make the suggested check if one of the entries has an empty image field.

    I will urge you to edit your code in a proper editor like Sublime text or visual studio rather than using Umbraco to do this :)

    Hope the above makes any sense.

    /Jan

  • Antony Doyle 6 posts 26 karma points
    Dec 04, 2012 @ 15:09
    Antony Doyle
    0

    Hi guys,

    That makes sense. I would use another text editor, I usually do, but I don't actually have FTP access, which just makes everything more difficult. It's probably tarnished my impression of Umbraco a little, though I do love how clean the markup is. :)

    Thank you both for your help though. It is very much appreciated.

    Antony.

Please Sign in or register to post replies

Write your reply to:

Draft