Wednesday, January 19, 2011

Spry and trials

I've been working with the website recently and have been struggling with a particular aspect, namely Spry.  Spry is a framework that allows the website developer to incorporate a variety of features, effects and generally build more interesting and interactive websites. 

For the last few days, however, I've been stumped by a problem in that my Spry code is not giving me the results that I would expect.  I am trying to display news items created text and images that are stored in an XML file (basically a text file with tags  that identify what each piece of text represents) on a web page.  To do this I create a variable which points to the XML data and then reference these content using spry:region and spry:repeat attributes. 

...
<script src="includes/xpath.js" type="text/javascript"></script>
<script src="includes/SpryData.js" type="text/javascript"></script>
<script type="text/javascript">
    var news_data = new Spry.Data.XMLDataSet("newsfeed.xml", "news/news_item");
</script>
...
<h3>Latest News</h3>
<div id="news_div" spry:region="news_data">
    <div spry:repeat="news_data">{news_data::news_date}</div>
</div>
...
 
There shouldn't, according to all of the websites that I've read, be a problem with this code.  However, what I discovered was that at some point in the lifecycle the xpath.js and SpryData.js files must have become corrupted.  This resulted in a hair-pulling frustration until I replaced the Spry js files using freshly downloaded versions from the Spry website: http://labs.adobe.com/technologies/spry/home.html
 
Once this was in place, all was wonderful!