be less rigid, however run as a test.
[pin4sha_cgi.git] / scripts / tagcloud-html2atom.xslt
blob4f6882b6e90af5e86c6cda562b1ba8a63a88294c
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
4 $ curl "https://links.mro.name/?do=tagcloud" | xsltproc - -html tagcloud-html2atom.xslt - | xmllint - -relaxng categories.rng -
6 http://www.w3.org/TR/xslt/
7 http://www.w3.org/TR/xpath/
8 https://tools.ietf.org/html/rfc5023#appendix-B
9 -->
10 <xsl:stylesheet
11 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
12 xmlns:dctype="http://purl.org/dc/dcmitype/"
13 xmlns="http://www.w3.org/2005/Atom"
14 xmlns:app="http://www.w3.org/2007/app"
15 xmlns:foo="foo"
16 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17 exclude-result-prefixes="dctype rdf"
18 version="1.0">
20 <xsl:output method="xml" indent="yes"/>
22 <xsl:template match="/html">
23 <xsl:comment>
24 https://tools.ietf.org/html/rfc5023#appendix-B
25 http://atomenabled.org/developers/protocol/#appCategories1
26 https://web.archive.org/web/20130716150512/http://www.atomenabled.org:80/developers/protocol/atom-protocol-spec.php#rfc.section.8.3.3
27 https://web.archive.org/web/20130716150512/http://www.atomenabled.org:80/developers/protocol/atom-protocol-spec.php#schema
28 </xsl:comment>
29 <app:categories scheme="?searchtags=">
30 <xsl:variable name="traditional_count_prefix" select="1 = count(.//a[starts-with(@href, '?searchtags=')][1]/preceding-sibling::*[1])"/>
32 <xsl:for-each select=".//a[starts-with(@href, '?searchtags=')]">
33 <xsl:sort select="." data-type="text" order="ascending"/>
35 <xsl:variable name="count">
36 <xsl:choose>
37 <xsl:when test="$traditional_count_prefix"><xsl:value-of select="preceding-sibling::*[1]"/></xsl:when>
38 <xsl:otherwise><xsl:value-of select="following-sibling::*[1]"/></xsl:otherwise>
39 </xsl:choose>
40 </xsl:variable>
42 <category term="{.}" foo:count="{$count}"/>
43 </xsl:for-each>
44 </app:categories>
45 </xsl:template>
47 </xsl:stylesheet>