teacup/transforms/desc2html.xsl
2021-12-15 11:29:23 +00:00

45 lines
No EOL
1.2 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
Transforms pseudo-markup in an ONIX CDATA section into XHTML.
Author: Andrew Sales
Project: Screen Studies
Date: 20171108
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="xhtml"/>
<xsl:template match="/">
<div><xsl:apply-templates/></div>
</xsl:template>
<xsl:template match="p">
<xsl:apply-templates/>
<xsl:if test="following-sibling::p"><br/></xsl:if>
</xsl:template>
<xsl:template match="b">
<strong><xsl:apply-templates/></strong>
</xsl:template>
<xsl:template match="i">
<em><xsl:apply-templates/></em>
</xsl:template>
<xsl:template match="u">
<u><xsl:apply-templates/></u>
</xsl:template>
<xsl:template match="text()[contains(., '&#xA;')]">
<xsl:variable name="tokens" select="tokenize(., '&#xA;')"/>
<xsl:for-each select="$tokens">
<xsl:value-of select="."/>
<br/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>