summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <bfr@qbus.de>2015-02-19 09:54:08 +0100
committerBenjamin Franzke <bfr@qbus.de>2015-02-19 09:54:08 +0100
commit6e5eefd1db1faa682b6db9dd73ffa2d76ead84e0 (patch)
tree792795288a4fb5d196a0fb5ae21b10fcb9cb8879
parent0e2b3b7503ee7734bc928236e6d7022a51bc91e6 (diff)
downloadendnote-import-6e5eefd1db1faa682b6db9dd73ffa2d76ead84e0.zip
endnote-import-6e5eefd1db1faa682b6db9dd73ffa2d76ead84e0.tar.gz
endnote-import-6e5eefd1db1faa682b6db9dd73ffa2d76ead84e0.tar.bz2
Use exsl:str:replace function instead of template
We need exsl anyway and using str:replace as xpath function simplifies the template alot.
-rw-r--r--convert-style-to-html.xsl32
-rw-r--r--util.xsl23
2 files changed, 9 insertions, 46 deletions
diff --git a/convert-style-to-html.xsl b/convert-style-to-html.xsl
index dbc7281..b22de5c 100644
--- a/convert-style-to-html.xsl
+++ b/convert-style-to-html.xsl
@@ -1,62 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:str="http://exslt.org/strings"
+ extension-element-prefixes="str">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
- <xsl:include href="util.xsl"/>
-
<!-- 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:param name="face" select="@face"/>
<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:with-param name="face" select="str:replace($face, '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:with-param name="face" select="str:replace($face, '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:with-param name="face" select="str:replace($face, '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:with-param name="face" select="str:replace($face, 'bold', '')"/>
</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:with-param name="face" select="str:replace($face, 'normal', '')"/>
</xsl:call-template>
</xsl:when>
diff --git a/util.xsl b/util.xsl
index 1c8bb5a..19e6cf9 100644
--- a/util.xsl
+++ b/util.xsl
@@ -51,27 +51,4 @@
<xsl:template mode="nodetype" match="@*">attribute</xsl:template>
<xsl:template mode="nodetype" match="text()">text</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:stylesheet>