1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:r="http://backend.userland.com/rss2"
xmlns="http://purl.org/rss/1.0/"
xmlns:rss="http://purl.org/rss/1.0/"
xmlns:vi="http://www.openlinksw.com/weblog/"
xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd"
version="1.0">
<xsl:output indent="yes" cdata-section-elements="content:encoded" />
<!-- general element conversions -->
<xsl:template match="/">
<xsl:comment>RDF based XML document generated By OpenLink Virtuoso</xsl:comment>
<rdf:RDF>
<xsl:apply-templates/>
</rdf:RDF>
</xsl:template>
<xsl:template match="*">
<xsl:choose>
<xsl:when test="name() = 'image'"/>
<xsl:when test="namespace-uri()='' or namespace-uri()='http://backend.userland.com/rss2'">
<xsl:element name="{name()}" namespace="http://purl.org/rss/1.0/">
<xsl:apply-templates select="*|@*|text()" />
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="*|@*|text()" />
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@*">
<!--<xsl:copy><xsl:value-of select="." /></xsl:copy>-->
</xsl:template>
<xsl:template match="vi:*" />
<xsl:template match="channel/itunes:*" />
<xsl:template match="item/itunes:*" />
<xsl:template match="text()">
<xsl:value-of select="normalize-space(.)" />
</xsl:template>
<xsl:template match="rss|r:rss">
<!--xsl:copy-of select="namespace::*" /-->
<xsl:apply-templates select="channel|r:channel" />
<xsl:apply-templates select="channel/item[guid|link]|r:channel/r:item[r:guid|r:link]" mode="rdfitem" />
</xsl:template>
<xsl:template match="channel|r:channel">
<channel rdf:about="{link|r:link}">
<xsl:apply-templates/>
<items>
<rdf:Seq>
<xsl:apply-templates select="item|r:item" mode="li" />
</rdf:Seq>
</items>
</channel>
</xsl:template>
<!-- channel content conversions -->
<xsl:template match="title|r:title">
<title><xsl:value-of select="." /></title>
</xsl:template>
<xsl:template match="description|r:description">
<description><xsl:value-of select="." /></description>
</xsl:template>
<xsl:template match="language|r:language">
<dc:language><xsl:value-of select="." /></dc:language>
</xsl:template>
<xsl:template match="copyright|r:copyright">
<dc:rights><xsl:value-of select="." /></dc:rights>
</xsl:template>
<xsl:template match="lastBuildDate|pubdate|r:lastBuildDate|r:pubdate">
<dc:date><xsl:call-template name="date" /></dc:date>
</xsl:template>
<xsl:template match="managingEditor|r:managingEditor">
<dc:creator><xsl:value-of select="." /></dc:creator>
</xsl:template>
<!-- elements from 0.94 not converted:
webMaster
category
generator
docs
cloud
ttl
image
textInput
skipHours
skipDays
-->
<!-- item content conversions -->
<xsl:template match="item/description|r:item/r:description">
<dc:description><xsl:call-template name="removeTags" /></dc:description>
<xsl:if test="not(../content:encoded)">
<content:encoded><xsl:value-of select="." /></content:encoded>
</xsl:if>
</xsl:template>
<xsl:template match="pubDate|r:pubDate">
<dc:date><xsl:call-template name="date" /></dc:date>
</xsl:template>
<xsl:template match="source|r:source">
<dc:source><xsl:value-of select="@url" /></dc:source>
</xsl:template>
<xsl:template match="author|r:author">
<dc:creator><xsl:value-of select="." /></dc:creator>
</xsl:template>
<!-- elements from 0.94 not converted:
category
comments
enclosure
-->
<!-- item templates -->
<xsl:template match="item|r:item" mode="li">
<xsl:choose>
<xsl:when test="link|r:link">
<rdf:li rdf:resource="{link|r:link}" />
</xsl:when>
<xsl:when test="guid|r:guid">
<rdf:li rdf:resource="{guid|r:guid}" />
</xsl:when>
<xsl:otherwise>
<rdf:li rdf:parseType="Resource">
<xsl:apply-templates />
</rdf:li>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="item[link]|r:item[r:link]" mode="rdfitem">
<item rdf:about="{link|r:link}">
<xsl:apply-templates/>
</item>
</xsl:template>
<xsl:template match="item[guid][not(link)]|r:item[r:guid][not(r:link)]" mode="rdfitem">
<item rdf:about="{r:guid|guid}">
<xsl:apply-templates/>
</item>
</xsl:template>
<!-- utility templates -->
<!--xsl:template match="channel/link|r:channel/r:link" /-->
<xsl:template match="channel/item|r:channel/r:item" />
<xsl:template match="item/guid|r:item/r:guid" />
<xsl:template match="item/link|r:item/r:link" />
<xsl:template match="channel/generator" />
<xsl:template match="channel/webMaster" />
<xsl:template match="channel/cloud" />
<xsl:template match="channel/category" />
<xsl:template match="item/comments" />
<xsl:template match="item/enclosure" />
<xsl:template name="date">
<xsl:variable name="m" select="substring(., 9, 3)" />
<xsl:value-of select="substring(., 13, 4)"
/>-<xsl:choose>
<xsl:when test="$m='Jan'">01</xsl:when>
<xsl:when test="$m='Feb'">02</xsl:when>
<xsl:when test="$m='Mar'">03</xsl:when>
<xsl:when test="$m='Apr'">04</xsl:when>
<xsl:when test="$m='May'">05</xsl:when>
<xsl:when test="$m='Jun'">06</xsl:when>
<xsl:when test="$m='Jul'">07</xsl:when>
<xsl:when test="$m='Aug'">08</xsl:when>
<xsl:when test="$m='Sep'">09</xsl:when>
<xsl:when test="$m='Oct'">10</xsl:when>
<xsl:when test="$m='Nov'">11</xsl:when>
<xsl:when test="$m='Dec'">12</xsl:when>
<xsl:otherwise>00</xsl:otherwise>
</xsl:choose>-<xsl:value-of select="substring(., 6, 2)"
/>T<xsl:value-of select="substring(., 18, 8)" /><xsl:text>Z</xsl:text>
</xsl:template>
<xsl:template name="removeTags">
<xsl:param name="html" select="." />
<xsl:choose>
<xsl:when test="contains($html,'<')">
<xsl:call-template name="removeEntities">
<xsl:with-param name="html" select="substring-before($html,'<')" />
</xsl:call-template>
<xsl:call-template name="removeTags">
<xsl:with-param name="html" select="substring-after($html, '>')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="removeEntities">
<xsl:with-param name="html" select="$html" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="removeEntities">
<xsl:param name="html" select="." />
<xsl:choose>
<xsl:when test="contains($html,'&')">
<xsl:value-of select="substring-before($html,'&')" />
<xsl:variable name="c" select="substring-before(substring-after($html,'&'),';')" />
<xsl:choose>
<xsl:when test="$c='nbsp'"> </xsl:when>
<xsl:when test="$c='lt'"><</xsl:when>
<xsl:when test="$c='gt'">></xsl:when>
<xsl:when test="$c='amp'">&</xsl:when>
<xsl:when test="$c='quot'">"</xsl:when>
<xsl:when test="$c='apos'">'</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="removeTags">
<xsl:with-param name="html" select="substring-after($html, ';')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$html" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|