Download TEAM LinG - LinuxTone.Org

Transcript
Chapter 15
<body>
<h1><xsl:value-of select=”@owner”/>’s Library</h1>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
The xsl:value-of element returns the text value of an XPath expression. If the XPath selects more than
one node, each node is converted to text according to XSL’s conversion rules and then concatenated and
returned. <xsl:value-of select=”@owner”/>, for instance, will return the text value of the owner
attribute on the current context node, which in this case is the <library> node. Because the attribute is
a string, it will return John Q. Reader unchanged.
The xsl:apply-templates element is where the power of XSL occurs. When called with no arguments, it selects all child nodes of the current node, triggers the templates that match each of them, and
then inserts the resulting nodes into the results of the current template. It can also be called with a
select argument in the form of an XPath that will apply templates only to the nodes selected.
Putting It All Together : Working with RSS
Now that you’ve learned how to work with XML in Python, it’s time for a real-world example that
shows you how you might want to use these modules to create your own RSS feed and how to take an
RSS feed and turn it into a web page for reading.
RSS Overview and Vocabulary
Depending on who you ask, RSS stands for Really Simple Syndication, or Rich Site Summary, or RDF
Site Summary. Regardless of what you want to call it, RSS is an XML-based format for syndicating content from news sites, blogs, and anyone else who wants to share discrete chunks of information over
time. RSS’s usefulness lies in the ease with which content can be aggregated and republished. RSS makes
it possible to read all your favorite authors’ blogs on a single web page, or, for example, to see every article from a news agency containing the word “Tanzania” first thing every day.
RSS originally started as part of Netscape’s news portal and has released several versions since then.
After Netscape dropped development on RSS and released it to the public, two different groups began
developing along what they each felt was the correct path for RSS to take. At present, one group has
released a format they are calling RSS 1.0, and the other has released a format they are calling 2.0,
despite the fact that 2.0 is not a successor to 1.0. At this point, RSS refers to seven different and sometimes incompatible formats, which can lead to a great deal of confusion for the newcomer to RSS.
Making Sense of It All
The following table summarizes the existing versions of RSS. As a content producer, the choice of version is fairly simple, but an RSS aggregator, which takes content from multiple sites and displays it in a
single feed, has to handle all seven formats.
296
TEAM LinG