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_pagesize">pagesize</string>
<string id="account_cortado">cortado</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> </strings>
</xsl:stylesheet> </xsl:stylesheet>

View file

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

View file

@ -23,8 +23,8 @@ a
a.tag a.tag
{ {
display: inline-block; display: inline-block;
margin: 0.25em; margin-left: 0.25em;
padding: 0em; margin-right: 0.25em;
} }
body 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:choose>
</xsl:variable> </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" /> <xsl:variable name="locale_strings" select="document(concat('../locale/', $locale, '.xml'))//strings/string" />
<!-- this kills 99% of the processed XML... sorry Tim Bray.... --> <!-- this kills 99% of the processed XML... sorry Tim Bray.... -->
@ -53,27 +53,42 @@
<head> <head>
<meta http-equiv="Content-Type" content="application/xhtml+xml;charset=utf-8" /> <meta http-equiv="Content-Type" content="application/xhtml+xml;charset=utf-8" />
<xsl:choose> <xsl:choose>
<xsl:when test="not(//@embed='true')"> <xsl:when test="not(//@embed='true')">
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico" /> <link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico" />
<link rel="stylesheet" type="text/css"> <link rel="stylesheet" type="text/css">
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="//@stylesheet" /> <xsl:value-of select="//@stylesheet" />
</xsl:attribute> </xsl:attribute>
</link> </link>
</xsl:when> </xsl:when>
<xsl:when test="//@embed='true'"> <xsl:when test="//@embed='true'">
<!-- <!--
embedded stylesheet should rather be done through URL like embedded stylesheet should rather be done through URL like
"http://localhost/video/4chan%20city/3/embed=true+stylesheet=embedded.css" "http://localhost/video/4chan%20city/3/embed=true+stylesheet=embedded.css"
--> -->
<link rel="stylesheet" type="text/css"> <link rel="stylesheet" type="text/css">
<xsl:attribute name="href"> <xsl:attribute name="href">
/style/embedded.css /style/embedded.css
</xsl:attribute> </xsl:attribute>
</link> </link>
</xsl:when> </xsl:when>
</xsl:choose> </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> <title>
<xsl:choose> <xsl:choose>
@ -89,6 +104,10 @@
"<xsl:value-of select="//resultspage/@query" />" "<xsl:value-of select="//resultspage/@query" />"
</xsl:when> </xsl:when>
<xsl:otherwise> <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_name']" />
- -
<xsl:value-of select="$site_strings[@id='site_motto']" /> <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" <xsl:stylesheet version="1.0"
xmlns="http://xspf.org/ns/0/" xmlns="http://xspf.org/ns/0/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@ -8,8 +8,6 @@
> >
<xsl:output <xsl:output
doctype-public="-//W3C//DTD XHTML 1.1//EN"
doctype-system="http://xspf.org/ns/0/"
encoding="utf8" encoding="utf8"
indent="yes" indent="yes"
method="xml" method="xml"
@ -17,9 +15,6 @@
omit-xml-declaration="no" 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:template match="/">
<xsl:apply-templates /> <xsl:apply-templates />
</xsl:template> </xsl:template>
@ -55,4 +50,5 @@
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>