|
42
|
1 <?xml version='1.0'?>
|
|
|
2 <!DOCTYPE doc SYSTEM "../../../../lib/xml/xsl.dtd" >
|
|
|
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">
|
|
|
4
|
|
|
5 <!-- Merge wrapped latin and prepped english to produce two-column
|
|
|
6 bilingual for a single Summa Question -->
|
|
|
7 <xsl:param name="lf">xyzzy</xsl:param>
|
|
|
8 <xsl:variable name="latin" select="document($lf,/)/*"/>
|
|
|
9 <xsl:key name="lq" match="x:div[@class='q']" use="@id"/>
|
|
|
10 <xsl:variable name="di" select="/x:div/@id"/>
|
|
|
11 <xsl:variable name="qi" select="concat('q',substring-after($di,'_Q'))"/>
|
|
|
12 <xsl:variable name="la" select="key('lq',$qi,$latin)"/>
|
|
|
13
|
|
|
14 <xsl:template match="node()|@*">
|
|
|
15 <xsl:copy>
|
|
|
16 <xsl:apply-templates select="node()|@*"/>
|
|
|
17 </xsl:copy>
|
|
|
18 </xsl:template>
|
|
|
19
|
|
44
|
20 <xsl:template match="/x:div/x:div[not(@n)]">
|
|
|
21 <!-- Wrap a prooemium -->
|
|
|
22 <xsl:copy>
|
|
|
23 <xsl:apply-templates select="@*|node()"/>
|
|
|
24 <xsl:apply-templates select="$la/x:div[@class='p']/x:p"/>
|
|
|
25 </xsl:copy>
|
|
|
26 </xsl:template>
|
|
|
27
|
|
|
28 <xsl:template match="/x:div/x:div[@n]">
|
|
42
|
29 <!-- Wraps a single article within a question -->
|
|
|
30 <xsl:variable name="n" select="count(preceding-sibling::x:div[@n])+1"/>
|
|
|
31 <xsl:variable name="ld" select="$la/x:div[@class='a'][position()=$n]"/>
|
|
|
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
|
33 <xsl:choose>
|
|
|
34 <xsl:when test="count(x:div)=count($ld/x:p)">
|
|
|
35 <xsl:copy>
|
|
|
36 <xsl:apply-templates select="@*|x:h4"/>
|
|
|
37 <xsl:for-each select="x:div">
|
|
|
38 <xsl:variable name="i" select="position()"/>
|
|
|
39 <xsl:copy>
|
|
|
40 <xsl:apply-templates select="@*|x:div[1]"/>
|
|
|
41 <xsl:for-each select="x:div[2]">
|
|
|
42 <xsl:copy>
|
|
|
43 <xsl:apply-templates select="@*"/>
|
|
|
44 <xsl:apply-templates select="$ld/x:p[position()=$i]"/>
|
|
|
45 </xsl:copy>
|
|
|
46 </xsl:for-each>
|
|
|
47 </xsl:copy>
|
|
|
48 </xsl:for-each>
|
|
|
49 </xsl:copy>
|
|
|
50 </xsl:when>
|
|
|
51 <xsl:otherwise>
|
|
|
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>
|
|
|
53 </xsl:otherwise>
|
|
|
54 </xsl:choose>
|
|
42
|
55 </xsl:template>
|
|
|
56 </xsl:stylesheet>
|