annotate summa/bilingual/merge.xsl @ 45:a768840ee9ff

correct dtd
author ht
date Sun, 20 Dec 2009 14:49:34 +0000
parents d16e7ecf99ad
children 77921d86a058
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
1 <?xml version='1.0'?>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
2 <!DOCTYPE doc SYSTEM "../../../../lib/xml/xsl.dtd" >
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" exclude-result-prefixes="x" xmlns:x="http://www.w3.org/1999/xhtml">
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
4
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
5 <!-- Merge wrapped latin and prepped english to produce two-column
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
6 bilingual for a single Summa Question -->
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
7 <xsl:param name="lf">xyzzy</xsl:param>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
8 <xsl:variable name="latin" select="document($lf,/)/*"/>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
9 <xsl:key name="lq" match="x:div[@class='q']" use="@id"/>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
10 <xsl:variable name="di" select="/x:div/@id"/>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
11 <xsl:variable name="qi" select="concat('q',substring-after($di,'_Q'))"/>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
12 <xsl:variable name="la" select="key('lq',$qi,$latin)"/>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
13
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
14 <xsl:template match="node()|@*">
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
15 <xsl:copy>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
16 <xsl:apply-templates select="node()|@*"/>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
17 </xsl:copy>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
18 </xsl:template>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
19
44
d16e7ecf99ad add prooemium
ht
parents: 43
diff changeset
20 <xsl:template match="/x:div/x:div[not(@n)]">
d16e7ecf99ad add prooemium
ht
parents: 43
diff changeset
21 <!-- Wrap a prooemium -->
d16e7ecf99ad add prooemium
ht
parents: 43
diff changeset
22 <xsl:copy>
d16e7ecf99ad add prooemium
ht
parents: 43
diff changeset
23 <xsl:apply-templates select="@*|node()"/>
d16e7ecf99ad add prooemium
ht
parents: 43
diff changeset
24 <xsl:apply-templates select="$la/x:div[@class='p']/x:p"/>
d16e7ecf99ad add prooemium
ht
parents: 43
diff changeset
25 </xsl:copy>
d16e7ecf99ad add prooemium
ht
parents: 43
diff changeset
26 </xsl:template>
d16e7ecf99ad add prooemium
ht
parents: 43
diff changeset
27
d16e7ecf99ad add prooemium
ht
parents: 43
diff changeset
28 <xsl:template match="/x:div/x:div[@n]">
42
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
29 <!-- Wraps a single article within a question -->
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
30 <xsl:variable name="n" select="count(preceding-sibling::x:div[@n])+1"/>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
31 <xsl:variable name="ld" select="$la/x:div[@class='a'][position()=$n]"/>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
32 <xsl:message><xsl:value-of select="@n"/>,<xsl:value-of select="$n"/>,<xsl:value-of select="@title"/>,<xsl:value-of select="count(x:div)"/>,<xsl:value-of select="$ld/x:h3"/>,<xsl:value-of select="count($ld/x:p)"/></xsl:message>
43
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
33 <xsl:choose>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
34 <xsl:when test="count(x:div)=count($ld/x:p)">
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
35 <xsl:copy>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
36 <xsl:apply-templates select="@*|x:h4"/>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
37 <xsl:for-each select="x:div">
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
38 <xsl:variable name="i" select="position()"/>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
39 <xsl:copy>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
40 <xsl:apply-templates select="@*|x:div[1]"/>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
41 <xsl:for-each select="x:div[2]">
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
42 <xsl:copy>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
43 <xsl:apply-templates select="@*"/>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
44 <xsl:apply-templates select="$ld/x:p[position()=$i]"/>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
45 </xsl:copy>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
46 </xsl:for-each>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
47 </xsl:copy>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
48 </xsl:for-each>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
49 </xsl:copy>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
50 </xsl:when>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
51 <xsl:otherwise>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
52 <xsl:message>Can't merge article <xsl:value-of select="@n"/>, <xsl:value-of select="count(x:div)"/>!=<xsl:value-of select="count($ld/x:p)"/></xsl:message>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
53 </xsl:otherwise>
d49f2ca9374c all but proemium working
ht
parents: 42
diff changeset
54 </xsl:choose>
42
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
55 </xsl:template>
8f4be7dfda7a ready to try real work
ht
parents:
diff changeset
56 </xsl:stylesheet>