Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Mar 16, 2009 @ 18:03
    trfletch
    0

    Displaying image IF one is available

    I have the following code in an XSLT file that works well in displaying an image that can be selected using a media picker. The problem is when an image is not selected I get the following error: "Error parsing XSLT file: \xslt\place-image.xslt".

    Is there a way to modify my code so that if an image is not selected then it just doesn't show anything rather than the error text. Many thanks. My code so far is as follows:
    [code]


    [/code]

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 16, 2009 @ 18:15
    Dirk De Grave
    0

    Hi Tony,

    Should use an if statement to check for a value:



    (Part after != should read as quote-quote-double quote", quote-quote for empty string and double quote to end the test attribute of the xsl:if statement)

    Regards,
    /Dirk

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 16, 2009 @ 18:16
    Dirk De Grave
    0

    Hi Tony,

    Should use an if statement to check for a value:
    [code]
    [/code]

    (Part after != should read as quote-quote-double quote", quote-quote for empty string and double quote to end the test attribute of the xsl:if statement)

    Regards,
    /Dirk

  • trfletch 598 posts 604 karma points
    Mar 16, 2009 @ 18:48
    trfletch
    0

    Sorry Dirk,

    I'm not 100% sure where that part would go, would it replace

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 16, 2009 @ 20:32
    Dirk De Grave
    0

    Hi tony,

    I should have read your post more carefully. Apparantly, you already have the if test in place, which looks ok to me... Have any info on the trace? (Append ?umbdebugshowtrace=true to the current url)

    Regards,
    /Dirk

  • trfletch 598 posts 604 karma points
    Mar 16, 2009 @ 22:02
    trfletch
    0

    Hi Dirk,

    This is what shows up:

    umbracoMacro Error parsing XSLT System.Xml.Xsl.XslCompiledTransform
    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, IList1[] args)<br /> at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in D:\Webpub\wonderfulprojects.co.uk\SubDomains\nhs\www\xslt\place-image.xslt:line 25
    at System.Xml.Xsl.CompiledQuery.Query.

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Mar 16, 2009 @ 22:15
    Peter Dijksterhuis
    0

    Tony, Dirk,

    you're both right here.
    Tony checks for a value being empty, Dirk uses the right value to check for.

    So, yes Tony, replace

  • trfletch 598 posts 604 karma points
    Mar 16, 2009 @ 23:11
    trfletch
    0

    Thank you Peter and Dirk,

    That is now working perfectly.

Please Sign in or register to post replies

Write your reply to:

Draft