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
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Set output format to Docbook -->
<xsl:output
method="xml"
encoding="utf-8"
indent="yes"
doctype-public="-//OASIS//DTD DocBook XML V4.4//EN"
doctype-system="http://www.docbook.org/xml/4.4/docbookx.dtd"/>
<!-- Copy all nodes and attributes by default -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Replace / in title with a space -->
<xsl:template match="articleinfo/title/text()">
<xsl:call-template name="clean-title">
<xsl:with-param name="title" select="."/>
</xsl:call-template>
</xsl:template>
<xsl:template name="clean-title">
<xsl:param name="title"/>
<xsl:choose>
<xsl:when test="contains($title, '/')">
<xsl:value-of select="substring-before($title, '/')"/>
<xsl:text> </xsl:text>
<xsl:call-template name="clean-title">
<xsl:with-param name="title" select="substring-after($title, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Remove revision history -->
<xsl:template match="revhistory"/>
<!-- Convert all image dimensions from pixels to points -->
<xsl:template match="@width[parent::imagedata]|@depth[parent::imagedata]">
<xsl:attribute name="{name()}">
<xsl:value-of select=". div 2"/>
<xsl:text>pt</xsl:text>
</xsl:attribute>
</xsl:template>
<!-- Convert all image source URLs to relative paths -->
<xsl:template match="@fileref[parent::imagedata]">
<xsl:attribute name="fileref">
<xsl:text>images/</xsl:text>
<xsl:call-template name="filename">
<xsl:with-param name="path" select="."/>
</xsl:call-template>
</xsl:attribute>
</xsl:template>
<!-- Output just the filename from a URL -->
<xsl:template name="filename">
<xsl:param name="path"/>
<xsl:choose>
<xsl:when test="contains($path, 'target=')">
<xsl:value-of select="substring-after($path, 'target=')"/>
</xsl:when>
<xsl:when test="not(contains($path, '/'))">
<xsl:value-of select="$path"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="filename">
<xsl:with-param name="path" select="substring-after($path, '/')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Fix incorrectly output wiki links -->
<xsl:template match="@url[parent::ulink]">
<xsl:attribute name="url">
<xsl:choose>
<xsl:when test="contains(., 'FreedomBox/Manual/')">
<xsl:value-of select="substring-before(., 'FreedomBox/Manual/')"/>
<xsl:value-of select="substring-after(., 'FreedomBox/Manual/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
|