doc/share/sgml/templates.events2ics.xsl
Hiroki Sato cfd9e12239 www cleanup mega commit:
- Move includes.nav*.sgml to share/sgml/navibar.ent and
   <lang>/share/sgml/nabibar.l10n.ent.

 - Move includes.sgml and includes.xsl to
   share/sgml/common.ent, share/sgml/header.ent, <lang>/share/sgml/l10n.ent,
   and <lang>?share/sgml/header.l10n.ent.

 - Move most of XSLT libraries to share/sgml/*.xsl and
   <lang>/share/sgml/*.xsl.

 - Move news.xml and other *.xml files for the similar purpose
   to share/sgml/*.xml and <lang>/share/sgml/*.xml.

 - Switch to use a custom DTD for HTML document.  Now we use
   "-//FreeBSD//DTD HTML 4.01 Transitional-Based Extension", which is
   HTML 4.01 + some entities previously pulled via
   "<!ENTITY % includes SYSTEM "includes.sgml"> %includes;" line.
   The location of entity file will be resolved by using catalog file.

 - Add DOCTYPE declearation to XML documents.  This makes the followings
   possible:

   * Use of &foo; entities for SGML in an XML file instead of defining
     {$foo} as the same content.

   * &symbolic; entities for Latin characters.

 - Duplicated information between SGML and XML, or English and
   translated doc, has been removed as much as possible.
2006-08-19 21:20:54 +00:00

118 lines
4.3 KiB
XML

<!DOCTYPE xsl:stylesheet PUBLIC "-//FreeBSD//DTD FreeBSD XSLT 1.0 DTD Fragment//EN"
"http://www.FreeBSD.org/XML/www/share/sgml/xslt10-freebsd.dtd" [
]>
<!-- $FreeBSD$ -->
<!-- Copyright (c) 2005 Ceri Davies <ceri@FreeBSD.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-->
<!-- Generate an iCalendar file from a www/en/events/events.dtd
compliant events.xml -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:cvs="http://www.FreeBSD.org/XML/CVS"
exclude-result-prefixes="cvs">
<xsl:import href="http://www.FreeBSD.org/XML/www/lang/share/sgml/libcommon.xsl"/>
<xsl:variable name="freebsd-web-base" select="'http://www.FreeBSD.org'"/>
<xsl:output method="text" encoding="&xml.encoding;"/>
<xsl:strip-space elements="*"/>
<!-- Template: events -->
<xsl:template match="events">BEGIN:VCALENDAR
VERSION:2.0
PRODID:$FreeBSD$
<xsl:apply-templates select="event"/>
END:VCALENDAR</xsl:template>
<!-- Template: event -->
<xsl:template match="event">
BEGIN:VEVENT
SEQUENCE:<xsl:value-of select="position()" />
SUMMARY:<xsl:value-of select="name"/>
<xsl:if test="url">
<xsl:apply-templates select="url"/>
</xsl:if>
LOCATION:<xsl:if test="location/site!=''">
<xsl:value-of select="location/site"/>
</xsl:if>
<xsl:if test="location/city!=''">
<xsl:text>, </xsl:text>
<xsl:value-of select="location/city"/>
</xsl:if>
<xsl:if test="location/state!=''">
<xsl:text>, </xsl:text>
<xsl:value-of select="location/state"/>
</xsl:if>
<xsl:if test="location/country!=''">
<xsl:text>, </xsl:text>
<xsl:value-of select="location/country"/>
</xsl:if>
<xsl:call-template name="gen-ical-date-interval">
<xsl:with-param name="startdate" select="startdate" />
<xsl:with-param name="enddate" select="enddate" />
</xsl:call-template>
DESCRIPTION:<xsl:copy-of select="description/child::node()"/>
<xsl:if test="link">
<xsl:apply-templates select="link"/>
</xsl:if>
END:VEVENT</xsl:template>
<!-- Template: link -->
<xsl:template match="link">
<xsl:apply-templates select="url"/>
</xsl:template>
<!-- Template: url -->
<xsl:template match="url">
URL;VALUE=URI:<xsl:choose>
<xsl:when test="@type='freebsd-website'">
<xsl:value-of select="$freebsd-web-base"/>
</xsl:when>
</xsl:choose>
<xsl:value-of select="."/>
</xsl:template>
<!-- Generate iCalendar DTSTART and DTEND entries -->
<xsl:template name="gen-ical-date-interval">
<xsl:param name="startdate"/>
<xsl:param name="enddate"/>
DTSTART;VALUE=DATE:<xsl:value-of select="concat(startdate/year,
format-number(startdate/month, '00'),
format-number(startdate/day, '00'))"/>
<xsl:if test="number(startdate/month) != number(enddate/month) or
number(startdate/day) != number(enddate/day) or
number(startdate/year) != number(enddate/year)">
DTEND;VALUE=DATE:<xsl:value-of select="concat(enddate/year,
format-number(enddate/month, '00'),
format-number(enddate/day, '00'))"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>