diff options
Diffstat (limited to 'convert-style-to-html.xsl')
-rw-r--r-- | convert-style-to-html.xsl | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/convert-style-to-html.xsl b/convert-style-to-html.xsl new file mode 100644 index 0000000..9858964 --- /dev/null +++ b/convert-style-to-html.xsl @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + + <xsl:output method="xml" indent="yes" encoding="UTF-8" /> + + <!-- Convert endnote style definitions declarations to html tags --> + <!-- TODO: <author>Editors,</author> bzw <author>Editor,</author> --> + <xsl:template match="style" name="style"> + + <xsl:param name="oldface" select="@face"/> + <xsl:param name="exclude" select="''" /> + + <xsl:variable name="face"> + <xsl:call-template name="string-replace-all"> + <xsl:with-param name="text" select="$oldface" /> + <xsl:with-param name="replace" select="$exclude" /> + <xsl:with-param name="by" select="''" /> + </xsl:call-template> + </xsl:variable> + + <xsl:choose> + <xsl:when test="contains($face, 'subscript')"> + <sub> + <xsl:call-template name="style"> + <xsl:with-param name="oldface" select="$face"/> + <xsl:with-param name="exclude" select="'subscript'"/> + </xsl:call-template> + </sub> + </xsl:when> + <xsl:when test="contains($face, 'superscript')"> + <sub> + <xsl:call-template name="style"> + <xsl:with-param name="oldface" select="$face"/> + <xsl:with-param name="exclude" select="'superscript'"/> + </xsl:call-template> + </sub> + </xsl:when> + <xsl:when test="contains($face, 'italic')"> + <em> + <xsl:call-template name="style"> + <xsl:with-param name="oldface" select="$face"/> + <xsl:with-param name="exclude" select="'italic'"/> + </xsl:call-template> + </em> + </xsl:when> + <xsl:when test="contains($face, 'boldface')"> + <strong> + <xsl:call-template name="style"> + <xsl:with-param name="oldface" select="$face"/> + <xsl:with-param name="exclude" select="'boldface'"/> + </xsl:call-template> + </strong> + </xsl:when> + <xsl:when test="contains($face, 'normal')"> + <xsl:call-template name="style"> + <xsl:with-param name="oldface" select="$face"/> + <xsl:with-param name="exclude" select="'normal'"/> + </xsl:call-template> + </xsl:when> + + <xsl:otherwise> + <xsl:apply-templates /> + </xsl:otherwise> + + </xsl:choose> + </xsl:template> + + <!-- Drop style definitions from author-tags --> + <xsl:template match="author/style"> + <xsl:apply-templates /> + </xsl:template> + + <xsl:template match="*"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates /> + </xsl:copy> + </xsl:template> + + <xsl:template name="string-replace-all"> + <xsl:param name="text" /> + <xsl:param name="replace" /> + <xsl:param name="by" /> + <xsl:choose> + <xsl:when test="$replace = ''"> + <xsl:value-of select="$text" /> + </xsl:when> + <xsl:when test="contains($text, $replace)"> + <xsl:value-of select="substring-before($text,$replace)" /> + <xsl:value-of select="$by" /> + <xsl:call-template name="string-replace-all"> + <xsl:with-param name="text" select="substring-after($text,$replace)" /> + <xsl:with-param name="replace" select="$replace" /> + <xsl:with-param name="by" select="$by" /> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$text" /> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="/"> + <xsl:apply-templates /> + </xsl:template> + +</xsl:stylesheet> |