summaryrefslogtreecommitdiff
path: root/convert.xsl
blob: c91e120239b327e20752ac31eb057232daf25042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<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" mode="conv">
		<caption>
			<xsl:attribute name="vref">
 				<xsl:choose>
					<xsl:when test="string-length(following::span[@class='verse']) > 0">
						<xsl:value-of select="following::span[@class='verse']"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="preceding::span[@class='verse']"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>

			<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="emphasis">
			<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>