diff options
Diffstat (limited to 'convert.xsl')
-rw-r--r-- | convert.xsl | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/convert.xsl b/convert.xsl new file mode 100644 index 0000000..d8f1d77 --- /dev/null +++ b/convert.xsl @@ -0,0 +1,88 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + <xsl:output method="xml" indent="yes" encoding="UTF-8" media-type="text/xml"/> + + <xsl:template match="h2"> + <caption vref="{following::span[@class='verse']}"> + <xsl:apply-templates mode="copy" /> + </caption> + </xsl:template> + + <xsl:template match="span[@class='fussnote']" mode="copy-with-notes"> + <note n1="x-studynote"> + <xsl:variable name="id"> + <xsl:value-of select="@data-param"/> + </xsl:variable> + <xsl:apply-templates select="//div[@id=$id]/div/p" mode="copy-with-notes"/> + </note> + </xsl:template> + + <xsl:template match="text()" mode="copy-with-notes"> + <xsl:if test="string-length(normalize-space(.)) > 0"> + <xsl:value-of select="." /> + </xsl:if> + </xsl:template> + + <xsl:template match="em" mode="copy-with-notes"> + <style fs="emphasize"> + <xsl:value-of select="." /> + </style> + </xsl:template> + + <xsl:template match="br" mode="copy-with-notes"> + <br art="x-nl" /> + </xsl:template> + +<!-- + <xsl:template match="*" mode="error"> + <xsl:choose> + <xsl:when test="@class='fussnote'"/> + <xsl:when test="@class='verse'"/> + <xsl:when test="@class='chapter'"/> + <xsl:when test="local-name()='em'"/> + <xsl:when test="local-name()='br'"/> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:value-of select="local-name()" /> + <xsl:value-of select="@class" /> + <xsl:apply-templates select="." mode="copy" /> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:template> +--> + <xsl:template match="p[span/@class='verse']"> + <vers> + <xsl:attribute name="vnumber"> + <xsl:value-of select="span[@class='verse']"/> + </xsl:attribute> + <xsl:apply-templates select="text()|span[@class='fussnote']|em|br" mode="copy-with-notes" /> + <!--<xsl:apply-templates select="*" mode="error" />--> + </vers> + </xsl:template> + + <xsl:template match="div[@class='annotation']"> + </xsl:template> + + + <xsl:template match="div[@class='markdown']"> + <xsl:apply-templates select="*" /> + </xsl:template> + + + <xsl:template match="/"> + <chapter cnumber="{//span[@class='chapter']}"> + <xsl:apply-templates select="//div[@class='markdown']"/> + </chapter> + </xsl:template> + + <xsl:template match="*" mode="copy"> + <xsl:element name="{local-name()}"> + <xsl:apply-templates mode="copy" select="@*|node()" /> + </xsl:element> + </xsl:template> + <xsl:template match="@*" mode="copy"> + <xsl:attribute name="{local-name()}"> + <xsl:value-of select="." /> + </xsl:attribute> + </xsl:template> +</xsl:stylesheet> |