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
    May 26, 2010 @ 16:42
    trfletch
    0

    Output full image url in XML using XSLT

    Hi All,

    I have an Umbraco 4.0.3 website and if you have been following my other posts you will know I have created an XSLT file to output data from one Umbraco website in XML so that it can be pulled into multiple other Umbraco sites. This is all working ok but I am stuck as to how I output the URL of an image that has been selected using a media picker so that I can show the image on the other websites. I assume I am going to need to output the full URL of the image in XML. If I use the following XSLT code then I get just the Image ID for <sitelogo> which is to be expected:

    <sites>
     <xsl:for-each select="umbraco.library:GetXmlNodeById(1106)/node [string(data [@alias='umbracoNaviHide']) != '1']">
           <site>
                            <sitename><xsl:value-of select="@nodeName" /></sitename>
                            <siteurl><xsl:value-of select="data [@alias = 'websiteurl']" /></siteurl>
                            <sitelogo><xsl:value-of select="data [@alias = 'websitelogo']" /></sitelogo>
                         </site>
            </xsl:for-each>
    </sites>

    So I thought I would try the code that I usually use for showing images in XSLT as follows:

    <sitelogo><xsl:value-of select="umbraco.library:GetMedia(data [@alias='websitelogo'], 'false')/data [@alias='umbracoFile']" /></sitelogo>

    But this seemed to completely screw up my XML and caused the following error on the XML output page:

    The XML page cannot be displayed 
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    --------------------------------------------------------------------------------
    Invalid at the top level of the document. Error processing resource 'http://www.hymnsam.co.uk/hymnsam-sites.aspx'. Line 1,...
    <?xml version="1.0" encoding="UTF-8"?>

    Can anyone see where I am going wrong? Also I assume I am going to need to output the image width and height because I will need that information on the page that is going to be displaying the image?

  • trfletch 598 posts 604 karma points
    May 27, 2010 @ 13:04
    trfletch
    0

    Sorry to pester, just wondered if anyone had any thoughts on this? I thought it was going to be a simple mistake I was making. I can't see why something that would give the URL normally via XSLT would cause a problem when outputting to XML?

  • trfletch 598 posts 604 karma points
    May 27, 2010 @ 14:00
    trfletch
    0

    Please ignore this, I have realised the problem is because I had some nodes that did not have an image so it would have been throwing out an XSLT error which was screwing up the XML output. I just need to put in an IF statement to check whether there is an image available.

Please Sign in or register to post replies

Write your reply to:

Draft