Copied to clipboard

Flag this post as spam?

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


  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    May 14, 2010 @ 14:26
    Jeroen Breuer
    0

    XSLT Flickr error

    I’ve used the xslt example from Kasperb (http://old.kasperb.dk/2006/6/26/display-your-flickr-images-on-your-umbraco-driven-website.aspx) to show images from Flickr on my site.

    After setting the url (http://api.flickr.com/services/feeds/photoset.gne?set=72157624035183498&nsid=42415310@N08&lang=en-us) on  the xslt instead of the macro parameter I get the following error on the variable (<xsl:variable name="url" select="http://api.flickr.com/services/feeds/photoset.gne?set=72157624035183498&amp;nsid=42415310@N08&amp;lang=en-us" />): 

    Expected end of the expression, found ‘:’. httpà:ß //api.flickr.com/services/feeds/…

     I’ve also added the <!ENTITY amp  "&#38;"> on the xslt.

    Does somebody knows what's going wrong?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    May 14, 2010 @ 14:30
    Matt Brailsford
    0

    Try putting the url in single quotes?

    <xsl:variable name="" select="'http://api...photoset.gne'" />

    Matt

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    May 14, 2010 @ 15:20
    Jeroen Breuer
    0

    Thank you Matt that helped, but now I don't get an error, but I also don't get any results back. Here is the XSLT my colleague wrote:

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE xsl:stylesheet

      <!ENTITY nbsp "&#x00A0;"> 

    <!ENTITY amp  "&#38;">

    ]>

    <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:media="http://search.yahoo.com/mrss"

      exclude-result-prefixes="msxml umbraco.library media">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <!-- macroparameter with the url of the flickr xmlfeed -->

    <!--<xsl:variable name="url" select="/macro/url" />-->

      <xsl:variable name="url" select="'http://api.flickr.com/services/feeds/photoset.gne?set=72157624035183498&amp;nsid=42415310@N08&amp;lang=en-us'" /> 

      <xsl:template match="/">

    <xsl:if test="$url != ''">

      <!--

      fetch xmlsource from url - we are unable to use select=document($url)

      but umbraco has a static function library available in xsl where there exists a

      method of fetching a xmldocument given an url  -->

      <xsl:variable name="flickrxml" select="umbraco.library:GetXmlDocumentByUrl($url)" />

      <ul>

        <xsl:apply-templates select="$flickrxml//item" />

      </ul>

    </xsl:if>

    </xsl:template>

    <xsl:template match="item">

      <li>

        <a href="{link}" title="{title}"><img src="{media:thumbnail/@url}" alt="{title}"/></a>

      </li>

    </xsl:template>

    </xsl:stylesheet>

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    May 14, 2010 @ 16:42
    Matt Brailsford
    0

    Couple of things.

    1) The XML seems to be a different format from what you are expecting, ie nodes are called entry with different attributes so i'm guessing it's changed since the demo you are following.

    2) You need to include the atom namespace so that you can access the nodes and attributes

    Try the following:

    <?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:CommerceLibrary="urn:CommerceLibrary"
     xmlns:atom="http://www.w3.org/2005/Atom"
     exclude-result-prefixes="msxml umbraco.library CommerceLibrary atom">



    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:variable name="url" select="'http://api.flickr.com/services/feeds/photoset.gne?set=72157624035183498&amp;nsid=42415310@N08&amp;lang=en-us'" />
    <xsl:template match="/">
      <xsl:if test="$url != ''">
        <xsl:variable name="flickrxml" select="umbraco.library:GetXmlDocumentByUrl($url)" />
        <ul>
     <xsl:for-each select="$flickrxml//atom:entry">
      <li> <a href="{atom:link[@rel='alternate']/@href}" title="{atom:title}"><img src="{atom:link[@rel='enclosure']/@href}" alt="{atom:title}"/></a></li>
     </xsl:for-each>
        </ul>
      </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft