Reputation: 386
I'm maintaining a website for a friend, which I didn't create. It uses the Symphony CMS, and my XML / XSLT / XPATH knowledge is elementary at best. There's a page that has an Instagram feed section, which has recently stopped displaying images and now just shows the Alt text "Instagram."
The relevant code from that template is:
<section>
...
<xsl:for-each select="instagram/rss/channel/item[position() < '5']">
<div class="one-quarter left">
<img class="border" src="{image/url}" alt="Instagram" />
</div>
</xsl:for-each>
...
</section>
The data source blueprint from this section is Dynamic XML which draws from an RSS feed at https://websta.me/rss/n/vubrew:
<rss xmlns:admin="http://webns.net/mvcb/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" version="2.0">
<channel>
<title>vubrew's feed - WEBSTA</title>
<link>https://widget.websta.me/rss/n/vubrew</link>
<description>
WEBSTA's RSS Feed - Websta is the best Instagram Web Viewer
</description>
<dc:language>en</dc:language>
<dc:creator>WEBSTA</dc:creator>
<pubDate>Fri, 19 Aug 2016 07:01:29 +0900</pubDate>
<atom:link href="https://widget.websta.me/rss/n/vubrew" rel="self" type="application/rss+xml"/>
<item>
<pubDate>Fri, 19 Aug 2016 00:32:44 +0900</pubDate>
<title>Fri, 19 Aug 2016 00:32:44 +0900</title>
<description>
Join Veterans United, Pit Sisters, and The Jed Fund tonight from 6 to 9 for the Mission Pawsible: TAILS kickoff event! There will be a food truck, raffles, and a silent auction, and $1 from every pint sold during the event will be donated to this great cause.
</description>
<atom:link href="https://websta.me/p/1319648356028404744_761313738"/>
<media:thumbnail url="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/13696890_1570626159907795_1849825203_n.jpg?ig_cache_key=MTMxOTY0ODM1NjAyODQwNDc0NA%3D%3D.2"/>
<guid>https://websta.me/p/1319648356028404744_761313738</guid>
</item>
<item>...</item>
...
</channel>
</rss>
From what I can tell, it looks like WEBSTA has possibly recently changed the format of their XML feed, such that {image/url}
no longer works to select the images, which now appear under the media
namespace media:thumbnail/url
.
I added the new media
namespace in the Symphony admin control panel for the Instagram data source, with a URI of http://search.yahoo.com/mrss/
. (The others specified in the RSS feed were already present.)
I've tried changing the image source to {thumbnail/url}
which produces the same result (just the Alt text) and to {media:thumbnail/url}
which causes an error to appear about an invalid namespace prefix:
XSLTProcessor::transformToXml():
Undefined namespace prefix
xmlXPathCompiledEval: evaluation failed
XPath evaluation returned no result.
Trying to pull up the media
URI of http://search.yahoo.com/mrss/
in a browser redirects to Yahoo's home page, and I found some info indicating that this specification might be maintained elsewhere now, but I can't seem to locate an alternate URI. So I'm wondering if this is part of the problem?
Admittedly, my XML / XSLT / XPATH knowledge is thin, so I'm not sure if I'm just not specifying the element correctly or if the problem is related to the media namespace URI possibly having been moved. I've also considered that I may need to somehow refresh Symphony to recognize the new namespace in the data source, but I don't see anything that would accomplish that.
I'd appreciate any insight.
Upvotes: 0
Views: 325
Reputation: 70638
I'll give an answer from an XSLT point of view, because I don't know Symphony, but normally you would declare the namespaces on the root xsl:stylesheet
element. For example, in this particular case, it would look something like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:media="http://search.yahoo.com/mrss/"
exclude-result-prefixes="media">
Then, there should be no problem using that namespace anywhere in the XSLT, so your <img>
tag would look this this (Note that url
is an attribute, so you need to use the @
prefix accordingly)
<img class="border" src="{media:thumbnail/@url}" alt="Instagram" />
Note that, you can actually declare the namespace on the template itself too, if you restricted to only being allowed to change templates in Symphony. So, you can write your template like so:
<xsl:template match="/" xmlns:media="http://search.yahoo.com/mrss/">
<section>
<xsl:for-each select="rss/channel/item[position() < 5]">
<div class="one-quarter left">
<img class="border" src="{media:thumbnail/@url}" alt="Instagram" />
</div>
</xsl:for-each>
</section>
</xsl:template>
Upvotes: 1