149 lines
4.9 KiB
XML
149 lines
4.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<xsl:stylesheet
|
|
version="1.0"
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
xmlns:itsb="http://tilde.town/~lucidiot/itsb/itsb.xsd"
|
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
xmlns:ocs="http://InternetAlchemy.org/ocs/directory#"
|
|
>
|
|
<xsl:output method="xml" indent="yes"/>
|
|
<xsl:param name="itsbRootUrl" select="'https://tilde.town/~lucidiot/itsb/'" />
|
|
|
|
<xsl:template match="/">
|
|
<rdf:RDF>
|
|
<xsl:apply-templates select=".//itsb:source" />
|
|
</rdf:RDF>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="itsb:source">
|
|
<rdf:description about="{./itsb:url/text()}">
|
|
<xsl:apply-templates select="itsb:name | itsb:description | itsb:type | itsb:region | itsb:license | itsb:feed" />
|
|
</rdf:description>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="itsb:name">
|
|
<dc:title>
|
|
<xsl:value-of select="text()" />
|
|
</dc:title>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="itsb:description">
|
|
<dc:description>
|
|
<xsl:value-of select="text()" />
|
|
</dc:description>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="itsb:type">
|
|
<dc:subject>
|
|
<xsl:value-of select="text()" />
|
|
</dc:subject>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="itsb:region">
|
|
<dc:coverage>
|
|
<xsl:value-of select="text()" />
|
|
</dc:coverage>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="itsb:license">
|
|
<dc:rights>
|
|
<xsl:value-of select="text()" />
|
|
</dc:rights>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="itsb:feed">
|
|
<rdf:description>
|
|
<xsl:choose>
|
|
<xsl:when test="itsb:link">
|
|
<xsl:attribute name="about">
|
|
<xsl:value-of select="itsb:link/text()" />
|
|
</xsl:attribute>
|
|
<dc:publisher>
|
|
<xsl:value-of select="ancestor::itsb:source/itsb:name/text()" />
|
|
</dc:publisher>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:attribute name="about">
|
|
<xsl:value-of select="$itsbRootUrl" />
|
|
<xsl:text>feeds/</xsl:text>
|
|
<xsl:value-of select="itsb:output/text()" />
|
|
</xsl:attribute>
|
|
<dc:publisher>International Transport Safety Bureau</dc:publisher>
|
|
<ocs:updatePeriod>daily</ocs:updatePeriod>
|
|
<ocs:updateFrequency>1</ocs:updateFrequency>
|
|
<ocs:updateBase>1970-01-01T14:00</ocs:updateBase>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
|
|
<xsl:if test="@type">
|
|
<dc:subject>
|
|
<xsl:value-of select="@type" />
|
|
</dc:subject>
|
|
</xsl:if>
|
|
<!-- TODO: Add dc:language - might require updating itsb.xsd to require ISO language codes -->
|
|
|
|
<ocs:format>
|
|
<xsl:choose>
|
|
<xsl:when test="@format = 'atom'">
|
|
<xsl:text>http://www.w3.org/2005/Atom</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'cdf'">
|
|
<xsl:text>https://msdn.microsoft.com/workshop/standards/cdf/</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'echo'">
|
|
<xsl:text>http://purl.org/echo/</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'json'">
|
|
<xsl:text>https://www.jsonfeed.org/version/1.1/</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'rdf'">
|
|
<xsl:text>https://web.resource.org/rss/1.0/spec</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'rss'">
|
|
<xsl:text>https://www.rssboard.org/rss-2-0-1</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'rss3'">
|
|
<xsl:text>http://www.aaronsw.com/2002/rss30</xsl:text>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:message terminate="yes">
|
|
<xsl:text>Unsupported feed format: </xsl:text>
|
|
<xsl:value-of select="@format" />
|
|
</xsl:message>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</ocs:format>
|
|
|
|
<ocs:contentType>
|
|
<xsl:choose>
|
|
<xsl:when test="@format = 'atom'">
|
|
<xsl:text>application/atom+xml</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'cdf' or @format = 'echo'">
|
|
<xsl:text>application/xml</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'json'">
|
|
<xsl:text>application/json</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'rdf'">
|
|
<xsl:text>application/rdf+xml</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'rss'">
|
|
<xsl:text>application/rss+xml</xsl:text>
|
|
</xsl:when>
|
|
<xsl:when test="@format = 'rss3'">
|
|
<xsl:text>text/plain</xsl:text>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:message terminate="yes">
|
|
<xsl:text>Unsupported feed format: </xsl:text>
|
|
<xsl:value-of select="@format" />
|
|
</xsl:message>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</ocs:contentType>
|
|
</rdf:description>
|
|
</xsl:template>
|
|
</xsl:stylesheet>
|