Copied to clipboard

Flag this post as spam?

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


  • Nicolai Heilbuth 14 posts 34 karma points
    Oct 29, 2009 @ 13:40
    Nicolai Heilbuth
    0

    GetMedia problem

    Hi

    Im a total beginner at Umbraco and XSLT, but I just dont understand why this doesnt work!


    This works fine and displays the image ID

    <xsl:for-each select="$currentPage/node">
    <xsl:value-of select="data [@alias = 'personImg']"/>
    </xsl:for-each>


    In this case the image ID is 1067. If i hardcode the ID the image displays nicely:

    <img src="{umbraco.library:GetMedia(1067, false)/data [@alias='umbracoFile']}"/>


    ...but if I try the following:

    <xsl:for-each select="$currentPage/node">
    <img src="{umbraco.library:GetMedia(data [@alias='personImg'], false)}"/>
    </xsl:for-each>

    I get the following error when trying to save the XSLT:

    (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    ved Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    ved Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    ved System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    ved System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
    ved System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
    ved System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results)
    ved System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    ved umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

     

    Help appreciated!

    Nicolai

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Oct 29, 2009 @ 13:53
    Jan Skovgaard
    0

    Hi Nicolai

    Try writing something like this:

    <img src="{umbraco.library:GetMedia(@id, 'false')/data [@alias = 'umbracoFile']}" />

    Does this help?

    /Jan

  • dandrayne 1138 posts 2262 karma points
    Oct 29, 2009 @ 13:54
    dandrayne
    0

    You'll probably need to wrap a check around the getMedia call as seen in this thread -> http://our.umbraco.org/forum/using/ui-questions/4685-umbracoLibraryGetMedia%28%29-Problem?p=0#comment16882

    Dan

  • Nicolai Heilbuth 14 posts 34 karma points
    Oct 29, 2009 @ 14:17
    Nicolai Heilbuth
    0

    Thanks for the quick responses!

    Jan:
    @id wont do the trick as im in the parent documenttype (or am i missing something?).

    Dan:
    Thanks a lot that worked out. Guess the check is mandatory! Not a very informative error message!

     Thanks

    Nicolai

     

  • dandrayne 1138 posts 2262 karma points
    Oct 29, 2009 @ 14:35
    dandrayne
    0

    Yeh, the xslt parser checks what you've written against the topmost node. Often the properties you are referencing don't exist on this page, causing the error.  Putting the checks in just allows you to save, but is also best practice as it should prevent any unsightly "error parsing bleh.xslt" errors on your page in the event that the data is not what you expect it to be.

    Dan

  • Nicolai Heilbuth 14 posts 34 karma points
    Oct 29, 2009 @ 14:50
    Nicolai Heilbuth
    0

    Ah that makes sense.

    Thank you Dan

    Nicolai

Please Sign in or register to post replies

Write your reply to:

Draft