xsl-list
[Top] [All Lists]

Re: [xsl] creating diglot

2016-08-30 11:03:55
I have successfully figured out how to create a diglot automatically. Anyone 
needing help I would be glad to share information. This is for side-by-side. I 
used Saxon to combine the two files. You can have primary always on right/left 
side or outside/inside. This uses PrinceXML which is free for non-commercial 
use.

-----Original Message-----
From: jim_albright(_at_)wycliffe(_dot_)org 
[mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com] 
Sent: Wednesday, August 10, 2016 7:38 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] creating diglot

saxon960HE   xslt 2.0

I would like to produce a diglot of scripture. That means two languages in two 
columns per page.
I have processed each text to identify the chapter and verse in attributes 
cvStart and cvEnd. I can fill in ones without attributes if needed.


Assuming that English is secondary

<?xml version="1.0" encoding="UTF-8"?><usx version="2.0">
  <book code="MRK" style="id">41-MRK-web.sfm World English Bible British 
Edition (WEBBE)</book>
  <para style="ide">UTF-8</para>
  <para style="h">Mark</para>
  <para style="mt1">Mark</para>
  <chapter number="1" style="c"/>
  <para style="p" cvStart="1.1" cvEnd="1.2">
    <verse number="1" style="v"/>The beginning of the Good News of Jesus 
Christ, the Son of God. <verse number="2" style="v"/>As it is written in the 
prophets,</para>
  <para style="q1">“Behold, I send my messenger before your face,</para>
  <para style="q2">who will prepare your way before you: </para>
  <para style="q1" cvStart="1.3">
    <verse number="3" style="v"/>the voice of one crying in the 
wilderness,</para>
  <para style="q2">‘Make ready the way of the .Lord!</para>
  <para style="q2">Make his paths straight!’” </para>
  <para style="p" cvStart="1.4" cvEnd="1.8">
    <verse number="4" style="v"/>John came baptising in the wilderness and 
preaching the baptism of repentance for forgiveness of sins. <verse number="5" 
style="v"/>All the country of Judea and all those of Jerusalem went out to him. 
They were baptised by him in the Jordan river, confessing their sins. <verse 
number="6" style="v"/>John was clothed with camel’s hair and a leather belt 
around his waist. He ate locusts and wild honey. <verse number="7" 
style="v"/>He preached, saying, “After me comes he who is mightier than I, the 
thong of whose sandals I am not worthy to stoop down and loosen. <verse 
number="8" style="v"/>I baptised you in water, but he will baptise you in the 
Holy Spirit.”</para>
  <para style="p" cvStart="1.9" cvEnd="1.11">
    <verse number="9" style="v"/>In those days, Jesus came from Nazareth of 
Galilee, and was baptised by John in the Jordan. <verse number="10" 
style="v"/>Immediately coming up from the water, he saw the heavens parting, 
and the Spirit descending on him like a dove. <verse number="11" style="v"/>A 
voice came out of the sky, “You are my beloved Son, in whom I am well 
pleased.”</para>
  <para style="p" cvStart="1.12" cvEnd="1.13"> ...


And Tok Pisin is primary

<?xml version="1.0" encoding="UTF-8"?><usx version="2.0">
  <book code="MRK" style="id">Tok Pisin Bible</book>
  <para style="ide">65001 - Unicode (UTF-8)</para>
  
<para style="mt1">Mak i raitim</para>
  <para style="imt1">Tok i go pas</para>
  <para style="ip">Namba wan tok bilong buk Mak i tok olsem, “Dispela em i 
gutnius bilong Jisas Krais, Pikinini Bilong God.” Na long dispela buk yumi 
lukim Jisas em i man i gat strong na namba bilong mekim olkain wok. Yumi lukim 
strong na namba bilong en long taim em i skulim ol manmeri na long taim em i 
rausim ol spirit nogut na long taim em i lusim sin bilong ol manmeri. Jisas i 
kolim em yet olsem, “Pikinini Bilong Man”, na em i tok olsem em i kam bilong 
givim laip bilong em yet bilong baim bek planti manmeri (10.45).</para>
  <para style="ip">Mak i stori planti long wok bilong Jisas, tasol em i no 
stori planti long ol toktok Jisas i bin mekim bilong skulim ol manmeri. Pastaim 
Mak i stori long wok bilong Jon bilong Baptais na long Jisas i kisim baptais na 
Satan i traim em. Bihain yumi lukim Jisas i marimari long ol man i karim ol 
kain kain hevi, na em i skulim ol. Pastaim ol disaipel i no klia tumas long as 
bilong ol samting Jisas i mekim, tasol isi isi ol i kisim save long em.</para>
  <para style="ip">Yumi lukim tu ol man i kamap birua bilong Jisas na ol i 
givim planti hevi long em. Na long las hap bilong Gutnius em i raitim, Mak i 
stori long Jisas i dai na i kirap bek.</para>
  <chapter number="1" style="c"/>
  <para style="ms1">Jisas i kam bilong tokim ol manmeri long kingdom bilong 
God</para>
  <para style="s2">(Sapta 1.1—3.6)</para>
  <para style="s1">Jon Bilong Baptais i autim tok</para>
  <para style="r">(Matyu 3.1-12 na Luk 3.1-9 na 3.15-17 na Jon 1.19-28)</para>
  <para style="p" cvStart="1.1">
    <verse number="1" style="v"/>Dispela em i gutnius bilong Jisas Krais, 
Pikinini Bilong God.</para>
  <para style="p" cvStart="1.2" cvEnd="1.3">
    <verse number="2" style="v"/>Dispela gutnius em i kamap pastaim olsem 
profet Aisaia i bin raitim, “Harim. Bai mi salim wanpela man bilong autim tok 
bilong mi, na em i go paslain long yu. Na em bai i redim rot bilong yu. <verse 
number="3" style="v"/>Long ples i no gat man, maus bilong wanpela man i singaut 
olsem, ‘Redim rot bilong Bikpela. Stretim ol rot bilong en.’”</para>
  <para style="p" cvStart="1.4" cvEnd="1.5">
   <verse number="4" style="v"/>Jon, dispela man bilong givim baptais, em i 
kamap long ples i no gat man, na em i autim tok long ol manmeri i mas tanim bel 
na kisim baptais, na bai God i lusim sin bilong ol. <verse number="5" 
style="v"/>Na olgeta Judia na olgeta manmeri bilong Jerusalem ol i go long Jon. 
Na ol i autim sin bilong ol, na Jon i baptaisim ol long wara Jordan.</para>
  <para style="p" cvStart="1.6" cvEnd="1.8">
    <verse number="6" style="v"/>Jon hani bilong bus. <verse number="7" 
style="v"/>Em i autim tok olsem, “Wanpela man i kam bihain long mi, na strong 
bilong en i winim strong bilong mi. Mi no gutpela man inap long mi brukim skru 
na lusim string i pasim su bilong em. <verse number="8" style="v"/>Mi  save 
baptaisim yupela long wara. Tasol em bai i baptaisim yupela long Holi 
Spirit.”</para>
  <para style="s1">Jon i baptaisim Jisas</para>
  <para style="r">(Matyu 3.13-17 na Luk 3.21-22)</para>
  <para style="p" cvStart="1.9" cvEnd="1.11">
    <verse number="9" style="v"/>Long dispela taim Jisas i lusim taun Nasaret 
long distrik Galili na i kam. Na Jon i baptaisim em long wara Jordan. <verse 
number="10" style="v"/>Na Jisas i lusim wara na i kam antap, na wantu em i 
lukim heven i op, na Holi Spirit i kam daun long em olsem wanpela bilong ol 
dispela pisin ol i kolim balus. <verse number="11" style="v"/>Na long heven 
wanpela maus i singaut olsem, “Yu Pikinini bilong mi. Mi laikim yu tumas. Bel 
bilong mi em i amamas long yu.”</para>
  <para style="s1">Satan i traim Jisas</para>
  <para style="r">(Matyu 4.1-11 na Luk 4.1-13)</para>
  <para style="p" cvStart="1.12" cvEnd="1.13">
    <verse number="12" style="v"/>Na long dispela taim stret Holi Spirit i 
salim Jisas i go long ples i no gat man. <verse number="13" style="v"/>Na  
Jisas i stap long ples i no gat man inap long 40 de, na Satan i traim em. Em i 
stap wantaim ol wel abus. Na ol ensel i helpim em.</para> .....

Desired output (note this was done for Genesis by hand so content won't match) 
<?xml version="1.0" encoding="UTF-8"?>

<book id="GEN">

        <div class="group">

                <div class="secondary">

                        <id id="GEN">World English Bible (WEB) </id>

                        <ide charset="UTF-8"/>

                        <h>Genesis </h>

                        <toc level="1">The First Book of Moses, Commonly Called 
Genesis </toc>

                        <toc level="2">Genesis </toc>

                        <toc level="3">Gen </toc>

                        <p sfm="mt" style="Book Title" level="2">The First Book 
of Moses, </p>

                        <p sfm="mt" style="Book Title" level="3">Commonly 
Called </p>

                        <p sfm="mt" style="Book Title">Genesis </p>
                </div>

                <div class="primary">

                        <id id="GEN">Tok Pisin Bible </id>

                        <ide charset="65001">- Unicode (UTF-8)</ide>

                        <p sfm="mt" style="Book Title">Stat bilong Olgeta 
Samting </p>

                        <p sfm="mt" style="Book Title" level="2">o </p>

                        <p sfm="mt" style="Book Title" level="2">Jenesis </p>

                        <p sfm="imt" style="Intro Title Main">Tok i go pas </p>

                        <p sfm="ip" style="Intro Paragraph">Dispela buk i stori 
long as o stat
                                bilong olgeta samting. Em i stori long as 
bilong skai na graun, na
                                em i stori tu long stat bilong ol manmeri na 
long as bilong ol sin
                                na hevi na pen i stap long dispela graun. Em i 
stori long rot God
                                yet i makim bilong wok wantaim yumi manmeri 
bilong dispela graun. </p>

                        <p sfm="ip" style="Intro Paragraph">Yumi inap brukim 
dispela buk long tupela
                                bikpela hap. </p>

                        <p sfm="ip" style="Intro Paragraph">1) Sapta 1-11. 
Dispela hap i stori long
                                God i wokim skai na graun, na em i stori tu 
long ol samting i bin
                                kamap bipo yet, taim ol manmeri i kamap long 
graun. I gat ol stori
                                bilong Adam tupela Iv, na bilong Kein na Abel. 
Na tu dispela hap
                                bilong buk i stori long Noa na long bikpela 
tait i bin kamap long
                                graun, na long taua bilong Babel. </p>

                        <p sfm="ip" style="Intro Paragraph">2) Sapta 12-50. 
Dispela ol sapta i stori
                                long ol tumbuna bilong ol lain Israel. Namba 
wan tumbuna em Abraham.
                                Abraham i bin aninit tru long laik bilong God 
na em i kamap olsem
                                piksa bilong ol manmeri i bilip tru long God. 
Dispela hap i stori tu
                                long Aisak na long pikinini bilong en Jekop 
wantaim ol 12-pela
                                pikinini man bilong em. Dispela man Jekop em i 
kisim narapela nem
                                Israel, na ol 12-pela pikinini man bilong en i 
bin kamapim ol
                                12-pela lain bilong Israel. Planti sapta long 
dispela hap bilong buk
                                i stori long Josep, em wanpela pikinini bilong 
Jekop. Ol i soim klia
                                ol samting i bin kamap bilong mekim ol lain 
tumbuna bilong ol Israel
                                i go i stap long kantri Isip. </p>

                        <p sfm="ip" style="Intro Paragraph">I gat planti stori 
bilong ol manmeri i
                                stap insait long dispela buk, tasol namba wan 
samting dispela buk i
                                tok long en, em ol samting God yet i bin mekim. 
Pastaim God yet i
                                bin wokim olgeta samting, na bihain, taim ol 
manmeri i stat long
                                mekim ol pasin nogut, God i mekim save long ol 
na em i larim ol lain
                                bilong Noa tasol i stap. Na bihain gen, God i 
makim Abraham na em i
                                promis long mekim gut long Abraham na long ol 
lain tumbuna bilong
                                en. Dispela buk i stori moa yet long God. Em i 
Papa tru bilong ol
                                manmeri, na em i save skelim pasin bilong ol na 
mekim save long ol
                                lain i save mekim rong. Na em i save bosim gut 
na lukautim ol
                                manmeri i aninit long em. Dispela buk i stori 
long bilip bilong ol
                                manmeri bilong bipo tru, bai ol lain i kamap 
bihain, ol tu i ken
                                ritim na i stap strong long bilip. </p>
                </div>
        </div>

        <div class="group">

                <div class="secondary">

                        <p>
                                <v id="1"/>In the beginning, God <f 
caller="+">The Hebrew word
                                        rendered “God” is “אֱלֹהִ֑ים” 
(Elohim).</f> created the
                                heavens and the earth. <ve/>
                                <v id="2"/>The earth was formless and empty. 
Darkness was on the
                                surface of the deep and God’s Spirit was 
hovering over the surface
                                of the waters. <ve/></p>

                        <p>
                                <v id="3"/>God said, “Let there be light,” and 
there was light. <ve/>
                                <v id="4"/>God saw the light, and saw that it 
was good. God divided
                                the light from the darkness. <ve/>
                                <v id="5"/>God called the light “day”, and the 
darkness he called
                                “night”. There was evening and there was 
morning, the first day.
                                <ve/></p>
                </div>

                <div class="primary">

                        <c id="1"/>

                        <p sfm="ms" style="Section Head Major">God i mekim 
kamap olgeta samting </p>

                        <p sfm="mr" style="Section Range">(Sapta 1-2) </p>

                        <s>Stori bilong God i mekim kamap olgeta samting </s>

                        <p>
                                <v id="1"/>Bipo bipo tru God i
                                mekim kamap skai na graun na olgeta samting i 
stap long en. <ve/>
                                <v id="2"/>Tasol graun i no bin i stap
                                olsem yumi save lukim nau. Nogat. Em i stap 
nating na i narakain
                                tru. Tudak i karamapim bikpela wara na spirit 
bilong God i go i kam
                                antap long en. <ve/>
                                <v id="3"/>Na God i tok olsem, “Lait i mas 
kamap.”
                                Orait lait i kamap. <ve/>
                                <v id="4"/>God i lukim lait i gutpela, na em i 
amamas. Na em i
                                brukim tudak na tulait. <ve/>
                                <v id="5"/>Tulait em i kolim “De,” na tudak em 
i kolim “Nait.” Nait
                                i go pinis na moning i kamap. Em i de namba 
wan. <ve/></p>
                </div>
        </div>

        <div class="group">

                <div class="secondary">

                        <p>
                                <v id="6"/>God said, “Let there be an expanse 
in the middle of the
                                waters, and let it divide the waters from the 
waters.” <ve/>
                                <v id="7"/>God made the expanse, and divided 
the waters which were
                                under the expanse from the waters which were 
above the expanse; and
                                it was so. <ve/>
                                <v id="8"/>God called the expanse “sky”. There 
was evening and there
                                was morning, a second day. <ve/></p>
                </div>

                <div class="primary">

                        <p>
                                <v id="6-7"/>Bihain God i tok olsem, “Wanpela 
banis i mas
                                kamap bilong banisim wara, bai wara i stap long 
tupela hap.” Orait
                                dispela banis i kamap. God i mekim dispela 
banis i kamap bilong
                                banisim wara antap na wara daunbilo. <ve/>
                                <v id="8"/>Na dispela banis em i kolim “Skai.” 
Nait i go pinis na
                                moning i kamap. Em i de namba 2. <ve/></p>
                </div>
        </div>

        <div class="group">

               <div class="secondary">

                        <p>
                                <v id="9"/>God said, “Let the waters under the 
sky be gathered
                                together to one place, and let the dry land 
appear”; and it was so. <ve/>
                                <v id="10"/>God called the dry land “earth”, 
and the gathering
                                together of the waters he called “seas”. God 
saw that it was good. <ve/>
                                <v id="11"/>God said, “Let the earth yield 
grass, herbs yielding
                                seeds, and fruit trees bearing fruit after 
their kind, with their
                                seeds in it, on the earth”; and it was so. <ve/>
                                <v id="12"/>The earth yielded grass, herbs 
yielding seed after their
                                kind, and trees bearing fruit, with their seeds 
in it, after their
                                kind; and God saw that it was good. <ve/>
                                <v id="13"/>There was evening and there was 
morning, a third day.
                                <ve/></p>
                </div>

                <div class="primary">

                        <p>
                                <v id="9"/>Bihain God i tok olsem, “Wara i stap 
aninit long skai i
                                mas i go bung long wanpela hap tasol, bai ples 
drai i kamap.” Orait
                                ples drai i kamap. <ve/>
                                <v id="10"/>Dispela ples drai God i kolim 
“Graun.” Na ol wara i bung
                                pinis long wanpela hap em i kolim “Solwara.” 
God i lukim olgeta
                                dispela samting i gutpela, na em i amamas. <ve/>
                                <v id="11"/>Bihain God i tok olsem, “Graun i 
mas kamapim ol kain
                                kain diwai na gras na kaikai samting.” Orait 
dispela samting i
                                kamap. <ve/>
                                <v id="12"/>Ol kain kain diwai na gras na 
kaikai samting i kamap
                                long graun. God i lukim olgeta dispela samting 
i gutpela, na em i
                                amamas. <ve/>
                                <v id="13"/>Nait i go pinis na moning i kamap. 
Em i de namba 3.
                                <ve/></p>

                </div>
        </div>

        <div class="group">
                <div class="secondary">

                        <p>
                                <v id="14"/>God said, “Let there be lights in 
the expanse of sky to
                                divide the day from the night; and let them be 
for signs to mark
                                seasons, days, and years; <ve/>
                                <v id="15"/>and let them be for lights in the 
expanse of sky to give
                                light on the earth”; and it was so. <ve/>
                                <v id="16"/>God made the two great lights: the 
greater light to rule
                                the day, and the lesser light to rule the 
night. He also made the
                                stars. <ve/>
                                <v id="17"/>God set them in the expanse of sky 
to give light to the
                                earth, <ve/>
                                <v id="18"/>and to rule over the day and over 
the night, and to
                                divide the light from the darkness. God saw 
that it was good. <ve/>
                                <v id="19"/>There was evening and there was 
morning, a fourth day.
                                <ve/></p>
                </div>

Resulting pdf where primary text is outside and secondary text is inside.  This 
is a proof of concept. I will add the verse numbers and better formatting. I 
just wanted to be sure I could handle the alignment at paragraphs correctly.
Tok Pisin is wordier so I may adjust column sizes to help minimize page count.





My problem is how do I select text from secondary document to correspond to the 
primary at paragraph level of primary document?

<?xml version="1.0" encoding="UTF-8"?>
<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:variable name="secondary" select="document('../secondary/041MRK.usx')"/>

<xsl:template match="book">
    <xsl:element name="book">
        <xsl:attribute name="id" select="@code"/>
       <xsl:apply-templates select="following-sibling::para"/>
    </xsl:element>
</xsl:template>
        
 <xsl:template match="para">
    <xsl:call-template name="makeGroup">
    <xsl:with-param  name="cvStart" select="@cvStart"/>
    <xsl:with-param name="cvEnd" select="@cvEnd"/>
    </xsl:call-template>
</xsl:template> 
 
<xsl:template name="makeGroup">
    <xsl:param name="cvStart" select="."/>
    <xsl:param name="cvEnd" select="."/>
   <xsl:element name="group">
        <xsl:element name="secondary">
            <xsl:element name="p">
                <xsl:attribute name="class" select="@style"/>
                      <xsl:value-of select="$secondary//para[@cvStart = '1.1' 
]"/>
           </xsl:element>

            <xsl:element name="p">
                <xsl:attribute name="class" select="@style"/>
<!--              <xsl:apply-templates />-->
            </xsl:element>
            
        </xsl:element>
    </xsl:element>
</xsl:template>

Problems
1.                   <xsl:value-of select="$secondary//para[10 ]"/>  correctly 
selects the tenth paragraph from secondary text
But      [@cvStart = '1.1' ] fails so does
                       [@cvStart = $cvStart] fails also
2. If I use <apply-templates select=….    I get into an endless loop. There 
must be an easy solution to stop this.

Any help is appreciated.

Jim Albright
704-562-1529 unlimited cell
Wycliffe Bible Translators


PDF or picture available.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>