summaryrefslogtreecommitdiff
path: root/contrib/xslt
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-04-03 22:27:51 +0200
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2016-04-25 22:19:31 +0200
commit873325de938562033aef367b18985b4bc0d61d17 (patch)
tree3fc6098c1831711d0e988e0063e871e73ccb2c29 /contrib/xslt
parentceff0d93892a6af3c3536ee645c83440c2f06b44 (diff)
Add (not at all finished) XSLT transformations to the contrib folder
Diffstat (limited to 'contrib/xslt')
-rw-r--r--contrib/xslt/mathml.xsl93
-rw-r--r--contrib/xslt/poem.xsl102
2 files changed, 195 insertions, 0 deletions
diff --git a/contrib/xslt/mathml.xsl b/contrib/xslt/mathml.xsl
new file mode 100644
index 0000000..dc386d3
--- /dev/null
+++ b/contrib/xslt/mathml.xsl
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:math="math">
+
+ <xsl:template match="/">
+ <xsl:apply-templates select="/document/math:math"/>
+ </xsl:template>
+
+ <xsl:template match="/document/math:math">
+ <xsl:element name="math" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:apply-templates select="math:*"/>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="math:equation">
+ <!--<xsl:element name="mtr" namespace="http://www.w3.org/1998/Math/MathML">-->
+ <xsl:apply-templates select="math:field"/>
+ <!--</xsl:element>-->
+ </xsl:template>
+
+ <xsl:template match="math:field">
+ <xsl:element name="mrow" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:apply-templates select="math:*"/>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="math:power">
+ <xsl:element name="msup" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:apply-templates select="math:*"/>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="math:index">
+ <xsl:element name="msub" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:apply-templates select="math:*"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Operators -->
+
+ <xsl:template match="math:equals">
+ <xsl:element name="mo" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:text>=</xsl:text>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="math:plus">
+ <xsl:element name="mo" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:text>+</xsl:text>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="math:minus">
+ <xsl:element name="mo" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:text>-</xsl:text>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="math:ast">
+ <xsl:element name="mo" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:text>*</xsl:text>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Leaf elements -->
+
+ <xsl:template match="math:number">
+ <xsl:element name="mn" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:value-of select="."/>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="math:text">
+ <xsl:element name="mtext" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:value-of select="."/>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="math:var">
+ <xsl:element name="mi" namespace="http://www.w3.org/1998/Math/MathML">
+ <xsl:value-of select="."/>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template math="* msup">
+
+ </xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/contrib/xslt/poem.xsl b/contrib/xslt/poem.xsl
new file mode 100644
index 0000000..197ec4a
--- /dev/null
+++ b/contrib/xslt/poem.xsl
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:poem="poem">
+
+ <xsl:output method="html" encoding="utf-8" indent="yes" />
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <title>Poem</title>
+ <style type="text/css">
+body {
+ font-size: 14pt;
+ line-height: 1.75;
+ font-family: Palatino, serif;
+ color: black;
+}
+h1, h2, h3 {
+ font-size: 100%;
+ font-weight: bold;
+}
+h1 span.title {
+ font-size: 150%;
+}
+h1 span.subtitle {
+ display: block;
+}
+.poem {
+ position: relative;
+ padding-left: 4em;
+}
+.poem h2 {
+ font-size: 100%;
+}
+.linenumber {
+ position: absolute;
+ left: 0;
+ width: 2em;
+ text-align: right;
+ -moz-user-select: none;
+ -webkizt-user-select: none;
+ user-select: none;
+}
+.indentation {
+ display: block;
+ padding-left: 2em;
+}
+ </style>
+ </head>
+ <body>
+ <xsl:apply-templates select="/document/poem:poem"/>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="/document/poem:poem">
+ <section class="poem">
+ <h1>
+ <span class="title">
+ <xsl:value-of select="title"/>
+ </span>
+ <span class="subtitle">
+ <xsl:text>by </xsl:text>
+ <a rel="author"><xsl:value-of select="author"/></a>
+ <xsl:text> (</xsl:text>
+ <span class="year">
+ <xsl:value-of select="year"/>
+ </span>
+ <xsl:text>)</xsl:text>
+ </span>
+ </h1>
+ <xsl:apply-templates select="poem:*"/>
+ </section>
+ </xsl:template>
+
+ <xsl:template match="poem:stanza">
+ <h2><xsl:number level="any" from="poem:poem" format="I."/></h2>
+ <p class="stanza">
+ <xsl:apply-templates select="poem:*"/>
+ </p>
+ </xsl:template>
+
+ <xsl:template match="poem:line">
+ <xsl:variable name="linenumber"><xsl:number level="any" from="poem:poem"/></xsl:variable>
+ <xsl:if test="($linenumber mod 5 = 0) or ($linenumber = 1)">
+ <span class="linenumber"><xsl:value-of select="$linenumber"/></span>
+ </xsl:if>
+ <span class="line">
+ <xsl:value-of select="."/>
+ </span><br/>
+ </xsl:template>
+
+ <xsl:template match="poem:indentation">
+ <span class="indentation">
+ <xsl:apply-templates select="poem:*"/>
+ </span>
+ </xsl:template>
+</xsl:stylesheet>
+