How To Publish Reviews As RSS Feeds
|
|
« Review Foundry User Manual
|
Tutorial Table Of Contents
|
Obtain Review Foundry »
USING XSL STYLESHEETSWhy Bother With Complex Style Sheets?XSL style sheets are difficult to use. Even regular programmers like myself find the syntax ghastly, foreign, and hard to comprehend. It is hard to recommend people study them. On the other hand, browsers understand XSL syntax, and no extra software is needed to render the RSS feed into a nicely formatted list of reviews, or what have you. The custom RSS feeds use stylesheets that allow them to be viewed with information at the top of the page about how the feeds can be used. If you go to your RSS syndication page after creating one or more custom RSS feeds you will be able to click on the link for an RSS feed and see the content formatted according to the XSL stylesheet with which it has been associated. If you look in the RSS feed itself, you'll see a line near the top of it that looks something like this: <?xml-stylesheet title="XSL_formatting" type="text/xsl" href="/some/path/to/foundry/rss/stylesheets/rss_stylesheet_item_review.xsl" ?> You will notice that the URL for the style sheet is relative to the document root for the server from which the feed was taken. What this means is that if you take the same RSS feed and place it onto the web page of another site, the relative URL will be instructing the browser that is looking at the feed to try and fetch the XSL stylesheet from that same location on the new server. Of course, the XSL file won't be there, and the browser will not be able to use it for formatting purposes. This can also result in the browser putting up a not-so-nice error message rather than just trying to make do without the stylesheet. Also, if the RSS feed is being parsed by another application before being presented, the XSL style sheet is also likely to be ignored, and the feed will be formatted in whatever fashion the application deems suitable. So XSL style sheets are great if you are going to be viewing an RSS feed in isolation, say, by pulling up the URL of the feed in your browser. But when the feed is incorporated into another web page you are very likely going to have little to no control over the exact formatting of the content. What this means is that the most important formatting is determined by what you put into the <description> element of each <item> in the feed. If you put HTML in this element, and encode it properly, the RSS reader is likely to represent exactly the HTML you have provided. You have some control over that HTML, since you can edit the RSS template that is used to format the RSS feed. So, for example, if you look at the rss_item.ttml template you will see a BLOCK like this: [% content_encoded = BLOCK %] some HTML and Template Toolkit code... [% END %]Whatever appears in that section is what will be rendered when the feed is parsed and displayed by another application. The trouble with this is that the person receiving the feed--the one who is putting it on their web site--cannot pick and choose which bits of information they want to display. It's an all or nothing approach. On the other hand, if you can convince them to display the entire feed by itself (not embedded into a web page), and add the XSL style sheet to their site, it becomes much easier to allow elements to be switched on and off at their end. The XSL style sheets for the RSS feeds that are published in bulk use this idea. For example, at the top of the style sheet named rss_stylesheet_reviews_single_thing.ttml you will see a configuration block that looks like this: <xsl:variable name="max_items" select="5" /> <xsl:variable name="enable_header" select="1" /> <xsl:variable name="enable_header_title" select="1" /> <xsl:variable name="enable_header_image" select="1" /> <xsl:variable name="enable_header_summary" select="1" /> <xsl:variable name="enable_header_submit_review" select="1" /> <xsl:variable name="enable_report_review" select="1" /> <xsl:variable name="enable_reviewer_byline" select="1" /> <xsl:variable name="enable_average_rating" select="1" /> <xsl:variable name="enable_average_rating_image" select="0" /> <xsl:variable name="enable_average_rating_numeric" select="1" /> <xsl:variable name="enable_attribute_ratings" select="1" /> <xsl:variable name="enable_avatars" select="1" /> <xsl:variable name="enable_pros" select="1" /> <xsl:variable name="enable_cons" select="1" /> <xsl:variable name="enable_review_text" select="1" /> <xsl:variable name="enable_read_more" select="1" /> <xsl:variable name="enable_image_frames" select="1" /> All of these variables can be toggled by whoever takes a copy of the style sheet and puts it on their server at the same relative location (to their document root) as the file is located on the web server from which they retrieved it. You can easily guess the effect that each of these variables has by reading the variable name itself, so I won't spend any time detailing what each does. The important point is that it is very easy to modify the content that gets displayed when the feed uses the XSL style sheet. Here is an example of an RSS feed that might be generated in bulk. This one shows the 2 latest reviews for a beach named Children's Pool. The corresponding XSL file is located here. By editing the configuration values at the top of the file you can see how to switch off various features.
Summary
Having said all this, it is very unlikely that a user will want to add an RSS document in isolation (not embedded into an existing web page) to their site. More than likely they will want to be able to retrieve from your site an already HTML-formatted version of your RSS feeds. How to do exactly that has been discussed in PUBLISHING RSS FEEDS. Copyright © 2004 Random Mouse Software. All Rights Reserved. | |||||||||