Commit 2ac6bce7 authored by Zangdar1111's avatar Zangdar1111

Factorisation code

parent 03cfafe7
......@@ -27,7 +27,7 @@
<!-- Header in hdoc -->
<xsl:template match="node[1]" mode="header">
<title>
<xsl:value-of select="utc:string-remove-order(@TEXT)"/>
<xsl:value-of select="utc:remove-language(@TEXT)"/>
<xsl:value-of select="richcontent"/>
</title>
<meta charset="utf-8"/>
......@@ -39,7 +39,7 @@
<xsl:element name="section">
<header>
<h1>
<xsl:value-of select="utc:string-remove-order(@TEXT)"/>
<xsl:value-of select="utc:remove-language(@TEXT)"/>
<xsl:value-of select="richcontent"/>
</h1>
</header>
......@@ -49,7 +49,7 @@
<header><h1>Introduction</h1>
<xsl:element name="div">
<xsl:attribute name="data-hdoc-type">introduction</xsl:attribute>
<xsl:value-of select="utc:string-remove-order(utc:string-remove-all(child::*[contains(@TEXT, '#intro')][1]/@TEXT, '#intro '))"/>
<xsl:value-of select="utc:remove-language(child::*[contains(@TEXT, '#intro')][1]/@TEXT)"/>
</xsl:element>
</header>
</xsl:element>
......@@ -63,7 +63,7 @@
<footer>
<xsl:element name="div">
<xsl:attribute name="data-hdoc-type">conclusion</xsl:attribute>
<xsl:value-of select="utc:string-remove-order(utc:string-remove-all(child::*[contains(@TEXT, '#conclu')][1]/@TEXT, '#conclu '))"/>
<xsl:value-of select="utc:remove-language(child::*[contains(@TEXT, '#conclu')][1]/@TEXT)"/>
</xsl:element>
</footer>
</xsl:element>
......@@ -84,7 +84,7 @@
</xsl:if>
<header>
<h1>
<xsl:value-of select="utc:string-remove-order(@TEXT)"/>
<xsl:value-of select="utc:remove-language(@TEXT)"/>
<xsl:value-of select="richcontent"/>
</h1>
</header>
......@@ -95,7 +95,7 @@
<!-- Paragraph -->
<xsl:template match="node[contains(@TEXT, '#p')]" priority="2">
<xsl:element name="p">
<xsl:value-of select="utc:string-remove-order(utc:string-remove-all(@TEXT, '#p '))"/>
<xsl:value-of select="utc:remove-language(@TEXT)"/>
</xsl:element>
</xsl:template>
......@@ -104,9 +104,9 @@
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>#</xsl:text>
<xsl:value-of select="utc:string-remove-order(utc:string-remove-all(@TEXT, '#a '))"/>
<xsl:value-of select="utc:remove-language(@TEXT)"/>
</xsl:attribute>
<xsl:value-of select="utc:string-remove-order(utc:string-remove-all(@TEXT, '#a '))"/>
<xsl:value-of select="utc:remove-language(@TEXT)"/>
</xsl:element>
</xsl:template>
......@@ -114,43 +114,14 @@
<xsl:template match="node[contains(@TEXT, '#intro')] | node[contains(@TEXT, '#conclu')]" priority="3"/>
<xsl:template match="richcontent">
<xsl:value-of select="utc:string-remove-order(html/body/p)"/>
<xsl:value-of select="utc:remove-language(html/body/p)"/>
</xsl:template>
<!-- Utility functions -->
<xsl:function name="utc:string-remove-all" as="xs:string">
<xsl:param name="text" as="xs:string"/>
<xsl:param name="replace" as="xs:string"/>
<xsl:variable name="ret">
<xsl:call-template name="string-remove-all">
<xsl:with-param name="text" select="$text"/>
<xsl:with-param name="replace" select="$replace"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$ret"/>
</xsl:function>
<xsl:template name="string-remove-all">
<xsl:param name="text" as="xs:string"/>
<xsl:param name="replace" as="xs:string"/>
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:call-template name="string-remove-all">
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:function name="utc:string-remove-order" as="xs:string">
<xsl:function name="utc:remove-language" as="xs:string">
<xsl:param name="text" as="xs:string?" />
<xsl:variable name="text2" select="string($text)"/>
<xsl:value-of select="replace($text2,'#[1-9][0-9]* ','')"></xsl:value-of>
<xsl:value-of select="replace($text2,'(#[0-9a-z]* )+','')"></xsl:value-of>
</xsl:function>
</xsl:stylesheet>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment