XSL null output, basic RSS feed

git-svn-id: http://yolanda.mister-muffin.de/svn@211 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
erlehmann 2007-12-19 15:30:00 +00:00
parent 3b99d00bcc
commit 2c3acd9344
7 changed files with 173 additions and 48 deletions

View file

@ -185,6 +185,11 @@
<string id="account_pagesize">pagesize</string>
<string id="account_cortado">cortado</string>
<!-- rss feed -->
<string id="rss_separator">&#160;-&#160;</string>
<string id="rss_description_1">This is an Yolanda RSS Feed for query "</string>
<string id="rss_description_2">".</string>
</strings>
</xsl:stylesheet>

View file

@ -4,28 +4,29 @@
<strings>
<!-- visible -->
<str id="site_name">Yolanda</str>
<str id="site_motto">WebTV free as in Speech</str>
<string id="site_name">Yolanda</string>
<string id="site_motto">WebTV free as in Speech</string>
<!-- invisible -->
<str id="page_account">/account.pl</str>
<str id="page_account_settings">/account.pl?show=settings</str>
<str id="page_account_uploads">/account.pl?show=uploads</str>
<str id="page_account_bookmarks">/account.pl?show=bookmarks</str>
<str id="page_login">/login.pl</str>
<str id="page_login-openid">/login.pl?action=openid</str>
<str id="page_logout">/login.pl?action=logout</str>
<str id="page_authors">http://yolanda.mister-muffin.de/trac</str>
<str id="page_license">http://www.fsf.org/licensing/licenses/agpl-3.0.html</str>
<str id="page_source-code">http://yolanda.mister-muffin.de/trac/browser/trunk</str>
<str id="page_register">/register.pl</str>
<str id="page_report_bug">http://yolanda.mister-muffin.de/trac/newticket</str>
<str id="page_results">search.pl?query=</str>
<str id="page_upload">/upload.pl</str>
<str id="page_uploader">uploader.pl</str>
<str id="page_query_latestadditions">search.pl?query=&amp;orderby=timestamp&amp;sort=desc</str>
<str id="page_query_mostdownloads">search.pl?query=&amp;orderby=downloadcount&amp;sort=desc</str>
<str id="page_query_mostviews">search.pl?query=&amp;orderby=viewcount&amp;sort=desc</str>
<string id="page_account">/account.pl</string>
<string id="page_account_settings">/account.pl?show=settings</string>
<string id="page_account_uploads">/account.pl?show=uploads</string>
<string id="page_account_bookmarks">/account.pl?show=bookmarks</string>
<string id="page_login">/login.pl</string>
<string id="page_login-openid">/login.pl?action=openid</string>
<string id="page_logout">/login.pl?action=logout</string>
<string id="page_authors">http://yolanda.mister-muffin.de/trac</string>
<string id="page_license">http://www.fsf.org/licensing/licenses/agpl-3.0.html</string>
<string id="page_source-code">http://yolanda.mister-muffin.de/trac/browser/trunk</string>
<string id="page_register">/register.pl</string>
<string id="page_report_bug">http://yolanda.mister-muffin.de/trac/newticket</string>
<string id="page_results">search.pl?query=</string>
<string id="page_root">http://localhost/</string>
<string id="page_upload">/upload.pl</string>
<string id="page_uploader">uploader.pl</string>
<string id="page_query_latestadditions">search.pl?query=&amp;orderby=timestamp&amp;sort=desc</string>
<string id="page_query_mostdownloads">search.pl?query=&amp;orderby=downloadcount&amp;sort=desc</string>
<string id="page_query_mostviews">search.pl?query=&amp;orderby=viewcount&amp;sort=desc</string>
</strings>

View file

@ -23,8 +23,8 @@ a
a.tag
{
display: inline-block;
margin: 0.25em;
padding: 0em;
margin-left: 0.25em;
margin-right: 0.25em;
}
body

24
trunk/xsl/null.xsl Normal file
View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns="http://xspf.org/ns/0/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<xsl:output
encoding="utf8"
indent="yes"
method="xml"
media-type="application/xml"
omit-xml-declaration="no"
/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

80
trunk/xsl/rss.xsl Normal file
View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns="http://purl.org/rss/1.0/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<xsl:output
encoding="utf8"
indent="yes"
method="xml"
media-type="application/xml"
omit-xml-declaration="no"
/>
<xsl:variable name="locale">
<xsl:choose>
<xsl:when test="document(concat('../locale/', //@locale, '.xml'))">
<xsl:value-of select="//@locale" />
</xsl:when>
<xsl:otherwise>en-us</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="site_strings" select="document('../site/main.xml')//strings/string" />
<xsl:variable name="locale_strings" select="document(concat('../locale/', $locale, '.xml'))//strings/string" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="results">
<rdf:RDF>
<channel>
<xsl:attribute name="rdf:about">
<xsl:value-of select="$site_strings[@id='page_root']" />
<xsl:value-of select="$site_strings[@id='page_results']" />
<xsl:value-of select="//results/@value" />&#38;xslt=rss
</xsl:attribute>
<title>
<xsl:value-of select="$site_strings[@id='site_name']" />
<xsl:value-of select="$locale_strings[@id='rss_separator']" />
<xsl:value-of select="//results/@value" />
</title>
<link>
<xsl:value-of select="$site_strings[@id='page_root']" />
<xsl:value-of select="$site_strings[@id='page_results']" />
<xsl:value-of select="//results/@value" />&#38;
</link>
<description>
<xsl:value-of select="$locale_strings[@id='rss_description_1']" />
<xsl:value-of select="//results/@value" />
<xsl:value-of select="$locale_strings[@id='rss_description_2']" />
</description>
</channel>
<xsl:for-each select="result">
<item>
<title>
<xsl:value-of select="rdf:RDF/cc:Work/dc:title" />
</title>
<description>
<xsl:value-of select="rdf:RDF/cc:Work/dc:description" />
</description>
<link>
<xsl:value-of select="rdf:RDF/cc:Work/@rdf:about" />
</link>
</item>
</xsl:for-each>
</rdf:RDF>
</xsl:template>
</xsl:stylesheet>

View file

@ -34,7 +34,7 @@
</xsl:choose>
</xsl:variable>
<xsl:variable name="site_strings" select="document('../site/main.xml')//strings/str" />
<xsl:variable name="site_strings" select="document('../site/main.xml')//strings/string" />
<xsl:variable name="locale_strings" select="document(concat('../locale/', $locale, '.xml'))//strings/string" />
<!-- this kills 99% of the processed XML... sorry Tim Bray.... -->
@ -75,6 +75,21 @@
</xsl:when>
</xsl:choose>
<xsl:if test="boolean(//results)">
<link rel="alternate" type="application/rss+xml">
<xsl:attribute name="title">
<xsl:value-of select="//results/@value" />
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='page_root']" />
<xsl:value-of select="$site_strings[@id='page_results']" />
<xsl:value-of select="//results/@value" />&#38;xslt=rss
</xsl:attribute>
</link>
</xsl:if>
<title>
<xsl:choose>
<xsl:when test="boolean(//frontpage)">
@ -89,6 +104,10 @@
"<xsl:value-of select="//resultspage/@query" />"
</xsl:when>
<xsl:otherwise>
<!--
this seems to be fail
should be fixed somehow
-->
<xsl:value-of select="$site_strings[@id='site_name']" />
-
<xsl:value-of select="$site_strings[@id='site_motto']" />

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns="http://xspf.org/ns/0/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@ -8,8 +8,6 @@
>
<xsl:output
doctype-public="-//W3C//DTD XHTML 1.1//EN"
doctype-system="http://xspf.org/ns/0/"
encoding="utf8"
indent="yes"
method="xml"
@ -17,9 +15,6 @@
omit-xml-declaration="no"
/>
<xsl:variable name="site_strings" select="document('../site/main.xml')//strings" />
<xsl:variable name="locale_strings" select="document(concat('../locale/', $locale, '.xml'))//strings/string" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
@ -55,4 +50,5 @@
</xsl:template>
</xsl:stylesheet>