XQuery/简单 RSS 阅读器
外观
< XQuery
BBC 提供了各种 RSS 新闻源,例如 英国教育新闻
将 RSS 提要重新格式化为 HTML
declare option exist:serialize "method=xhtml media-type=text/html"; let $news := doc("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/education/rss.xml") let $dateTime := $news/rss/channel/lastBuildDate return <html> <body> <h2>Education news from the BBC at {string($dateTime)}</h2> { for $newsItem in $news/rss/channel/item[position() < 10] return <div> <h4>{string($newsItem/title)}</h4> <p>{string($newsItem/title/description)} <a href="{$newsItem/link}">more..</a></p> </div> } </body> </html>
带语音扩展的 Opera 浏览器支持文字转语音,允许将此新闻朗读出来。 这使用 XML 词汇 VoiceXML 和 XML 事件。 [2019-01-26 : 遗憾的是,Opera 不再支持 VoiceXML]
declare option exist:serialize "method=xhtml media-type=application/xv+xml"; let $news := doc("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/education/rss.xml") let $dateTime := $news/rss/channel/lastBuildDate let $newsItems := $news/rss/channel/item[position() < 10] return <h:html xmlns:h="http://www.w3.org/1999/xhtml" xmlns:vxml="http://www.w3.org/2001/vxml" xmlns:ev="http://www.w3.org/2001/xml-events" > <h:head> <h:title>BBC Education news</h:title> <vxml:form id="news"> <vxml:block> {for $newsItem in $newsItems return string($newsItem/description) } </vxml:block> </vxml:form> </h:head> <h:body> <h:h1>BBC Education news at {string($dateTime)}</h:h1> <h:p> <h:a ev:event="click" ev:handler="#news" > <h:img src="http://www.naturalreaders.com/images/laba.gif"/> </h:a> (Requires the Opera Browser with Voice extension) </h:p> { for $newsItem in $newsItems return <h:div> <h:h4>{string($newsItem/title)}</h:h4> <h:p>{string($newsItem/description)} <h:a href="{$newsItem/link}">more..</h:a></h:p> </h:div> } </h:body> </h:html>
请注意,html 命名空间已指定前缀,以便默认前缀可以引用 RSS 提要。
更一般地说,可以朗读任何 RSS 提要的阅读器将是一项有用的服务。