I have a scripture file that matches the XSEM definition
see http://www.sil.org/computing/xsem/documentation/Documentation.html
I want to add the <verseEnd/> tag in order to facilitate transformation to
a verse-centric model and also for extracting verses from text.
The <verseEnd/> tag can be contained within <p> and <line> elements.
My problem is being able to specify when to call for the verseEnd.
So far I see two cases:
Case 1. If at a verse there is a preceding-sibling::verse then that should be a
verseEnd
verses: 1, 4, 6, 7, 9, 10, 12 .... see INPUT below
<xsl:template match="verse">
<!-- if this verse has a preceding-sibling verse then add verseEnd-->
<xsl:choose>
<xsl:when test="preceding-sibling::verse">
<!--.....has a preceding sibling verse......--><xsl:call-template
name="verseEnd"/>
</xsl:when>
<xsl:otherwise>
<!-- do nothing -->
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="copy-current-node"/> <!-- identity
transformation-->
</xsl:template>
Case 2. If at a last node of a (p or line) and the next p or line immediately
starts with a verse then that should be a verseEnd
2, 3, 5, 9, 11, 13
Right now I am getting two <verseEnd/> for verse 2 and none for verses 5, 8,
11, 13.
The others are fine.
see INPUT and DESIRED OUTPUT below
<xsl:template match="p/node()[last()] | lineGroup/line[last()]/node()[last
()]" >
<!-- at last node of either p or line -->
<!-- do until we find the next p or line and see if there is a verse
immediately following -->
<xsl:call-template name="isThisPorLineWithVerse"/>
</xsl:template>
<xsl:template name="isThisPorLineWithVerse">
<xsl:for-each select="following::node()[1]">
<xsl:choose>
<xsl:when test="following::node()[1]=following::p[1]|line[1]">
<!--.....p or line found.....-->
<xsl:choose>
<xsl:when test="following::node
()[2]=following::verse[1]">
<!--.....verse found.....--><xsl:call-template name="verseEnd"/>
</xsl:when>
<xsl:otherwise>
<!--....no verse at start of p or line....-->
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<!--....not a p or line.....--><xsl:call-template name
="isThisPorLineWithVerse"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="verseEnd">
<xsl:element name="verseEnd">
<xsl:attribute name="id">
<xsl:value-of select="concat(preceding::verse[1]/@id,'
-END')"/>
</xsl:attribute>
<xsl:attribute name="from">
<xsl:value-of select="preceding::verse[1]/@id"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="@*|node()" name="copy-current-node">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
INPUT:
<text>
<div>
<chapter value="1"/>
<head>The Preaching of#John the#Baptist
</head>
<parallelPassage>
<targetRef book="MAT" chapter="3" verse="1" verseEnd="12"/>
<targetRef book="LUK" chapter="3" verse="1" verseEnd="18"/>
<targetRef book="JHN" chapter="1" verse="19" verseEnd="28"/>
</parallelPassage>
<p>
<verse id="BCV-MRK-1.1" value="1"/>This is the Good News about
Jesus Christ, the Son of God.
<note type="translation">Some#manuscripts#do not have<refText> the Son of
God.</refText>
</note>
<verse id="BCV-MRK-1.2" value="2"/>
<note type="xref">[1:2] <canonRef book="MAL" chapter="3" verse="1"/>
</note> It began as the prophet Isaiah had#written:
</p>
<lineGroup>
<line>God said,
<q to="Q-BCV-MRK-1.2-00001-END" id="Q-BCV-MRK-1.2-00001"/>I will send my
messenger ahead of#you
</line>
<line>to open the way for#you.<qEnd from="Q-BCV-MRK-1.2-00001"
id="Q-BCV-MRK-1.2-00001-END"/>
</line>
</lineGroup>
<lineGroup>
<line>
<verse id="BCV-MRK-1.3" value="3"/>
<note type="xref">[1:3] <canonRef book="ISA" chapter="40"
verse="3"/>
</note> Someone is shouting in the#desert,
</line>
<line>
<q to="Q-BCV-MRK-1.3-00002-END" id="Q-BCV-MRK-1.3-00002"/>Get
the road ready for the#Lord;
</line>
<line>make a straight path for him to#travel!<qEnd
from="Q-BCV-MRK-1.3-00002" id="Q-BCV-MRK-1.3-00002-END"/>#<qEnd/>
</line>
</lineGroup>
<p>
<verse id="BCV-MRK-1.4" value="4"/>So John appeared in the desert,
baptizing and preaching.
<note type="translation">
<refText>John#appeared#in the desert, baptizing and preaching;
</refText>some manuscripts have<reading> John the Baptist appeared in
the desert, preaching.</reading>
</note> Turn away from your sins and be baptized,<qEnd/> he told
the people, and God will forgive your sins.<qEnd/>
<verse id="BCV-MRK-1.5" value="5"/>Many people from the province of
Judea and the city of Jerusalem went out to hear John. They confessed
their sins, and he baptized them in the Jordan#River.
</p>
<p>
<verse id="BCV-MRK-1.6" value="6"/>
<note type="xref">[1:6] <canonRef book="2KI" chapter="1" verse="8"/>
</note> John wore clothes made of camel's hair, with a leather belt
around his waist, and his food was locusts and wild honey.
<verse id="BCV-MRK-1.7" value="7"/>He announced to the people, The man who will
come after me is much greater than I am. I am not good enough even to
bend down and untie his sandals.
<verse id="BCV-MRK-1.8" value="8"/>I#baptize you with water, but he will
baptize you with the Holy#Spirit.<qEnd/>
</p>
</div>
<div>
<chapter value="1"/>
<head>The Baptism and#Temptation of#Jesus
</head>
<parallelPassage>
<targetRef book="MAT" chapter="3" verse="13"/>
<targetRef book="MAT" chapter="4" verse="11"/>
<targetRef book="LUK" chapter="3" verse="21"/>
<targetRef book="LUK" chapter="3" verse="22"/>
<targetRef book="LUK" chapter="4" verse="1" verseEnd="13"/>
</parallelPassage>
<p>
<verse id="BCV-MRK-1.9" value="9"/>Not long afterward Jesus came
from Nazareth in the province of Galilee, and was baptized by John in the
Jordan.
<verse id="BCV-MRK-1.10" value="10"/>As soon as Jesus came up out of the water,
he saw heaven opening and the Spirit coming down on him like a dove.
<verse id="BCV-MRK-1.11" value="11"/>
<note type="xref">[1:11] <canonRef book="GEN" chapter="22"
verse="2"/>
<canonRef book="PSA" chapter="2" verse="7"/>
<canonRef book="ISA" chapter="42" verse="1"/>
<canonRef book="MAT" chapter="3" verse="17"/>
<canonRef book="MAT" chapter="12" verse="18"/>
<canonRef book="MRK" chapter="9" verse="7"/>
<canonRef book="LUK" chapter="3" verse="22"/>
</note> And a voice came from heaven, You are my own dear Son. I am
pleased with#you.<qEnd/>
</p>
<p>
<verse id="BCV-MRK-1.12" value="12"/>At once the Spirit made him go
into the desert,
<verse id="BCV-MRK-1.13" value="13"/>where he stayed forty days, being tempted
by Satan. Wild animals were there also, but angels came and helped#him.
</p>
</div>
</text>
DESIRED OUTPUT:
<text>
<div>
<chapter value="1"/>
<head>The Preaching of#John the#Baptist
</head>
<parallelPassage>
<targetRef book="MAT" chapter="3" verse="1" verseEnd="12"/>
<targetRef book="LUK" chapter="3" verse="1" verseEnd="18"/>
<targetRef book="JHN" chapter="1" verse="19" verseEnd="28"/>
</parallelPassage>
<p>
<verse id="BCV-MRK-1.1" value="1"/>This is the Good News about
Jesus Christ, the Son of God.
<note type="translation">Some#manuscripts#do not have<refText> the Son of
God.</refText>
</note>
<verseEnd id="BCV-MRK-1.1-END" from="BCV-MRK-1.1"/>
<verse id="BCV-MRK-1.2" value="2"/>
<note type="xref">[1:2] <canonRef book="MAL" chapter="3" verse="1"/>
</note> It began as the prophet Isaiah had#written:
</p>
<lineGroup>
<line>God said,
<q to="Q-BCV-MRK-1.2-00001-END" id="Q-BCV-MRK-1.2-00001"/>I will send my
messenger ahead of#you
</line>
<line>to open the way for#you.<qEnd from="Q-BCV-MRK-1.2-00001"
id="Q-BCV-MRK-1.2-00001-END"/>
</line>
</lineGroup>
<lineGroup>
<line>
<verseEnd id="BCV-MRK-1.2-END" from="BCV-MRK-1.2"/>
<verse id="BCV-MRK-1.3" value="3"/>
<note type="xref">[1:3] <canonRef book="ISA" chapter="40"
verse="3"/>
</note> Someone is shouting in the#desert,
</line>
<line>
<q to="Q-BCV-MRK-1.3-00002-END" id="Q-BCV-MRK-1.3-00002"/>Get
the road ready for the#Lord;
</line>
<line>make a straight path for him to#travel!<qEnd
from="Q-BCV-MRK-1.3-00002" id="Q-BCV-MRK-1.3-00002-END"/>#<qEnd/>
<verseEnd id="BCV-MRK-1.4-END" from="BCV-MRK-1.4"/>
</line>
</lineGroup>
<p>
<verse id="BCV-MRK-1.4" value="4"/>So John appeared in the desert,
baptizing and preaching.
<note type="translation">
<refText>John#appeared#in the desert, baptizing and preaching;
</refText>some manuscripts have<reading> John the Baptist appeared in
the desert, preaching.</reading>
</note> Turn away from your sins and be baptized,<qEnd/> he told
the people, and God will forgive your sins.<qEnd/>
<verseEnd id="BCV-MRK-1.4-END" from="BCV-MRK-1.4"/>
<verse id="BCV-MRK-1.5" value="5"/>Many people from the province of
Judea and the city of Jerusalem went out to hear John. They confessed
their sins, and he baptized them in the Jordan#River.
<verseEnd id="BCV-MRK-1.5-END" from="BCV-MRK-1.5"/>
</p>
<p>
<verse id="BCV-MRK-1.6" value="6"/>
<note type="xref">[1:6] <canonRef book="2KI" chapter="1" verse="8"/>
</note> John wore clothes made of camel's hair, with a leather belt
around his waist, and his food was locusts and wild honey.
<verseEnd id="BCV-MRK-1.6-END" from="BCV-MRK-1.6"/>
<verse id="BCV-MRK-1.7" value="7"/>He announced to the people, The man who will
come after me is much greater than I am. I am not good enough even to
bend down and untie his sandals.
<verseEnd id="BCV-MRK-1.7-END" from="BCV-MRK-1.7"/>
<verse id="BCV-MRK-1.8" value="8"/>I#baptize you with water, but he will
baptize you with the Holy#Spirit.<qEnd/>
<verseEnd id="BCV-MRK-1.8-END" from="BCV-MRK-1.8"/>
</p>
</div>
<div>
<chapter value="1"/>
<head>The Baptism and#Temptation of#Jesus
</head>
<parallelPassage>
<targetRef book="MAT" chapter="3" verse="13"/>
<targetRef book="MAT" chapter="4" verse="11"/>
<targetRef book="LUK" chapter="3" verse="21"/>
<targetRef book="LUK" chapter="3" verse="22"/>
<targetRef book="LUK" chapter="4" verse="1" verseEnd="13"/>
</parallelPassage>
<p>
<verse id="BCV-MRK-1.9" value="9"/>Not long afterward Jesus came
from Nazareth in the province of Galilee, and was baptized by John in the
Jordan.
<verseEnd id="BCV-MRK-1.10-END" from="BCV-MRK-1.10"/>
<verse id="BCV-MRK-1.10" value="10"/>As soon as Jesus came up out of the water,
he saw heaven opening and the Spirit coming down on him like a dove.
<verseEnd id="BCV-MRK-1.11-END" from="BCV-MRK-1.11"/>
<verse id="BCV-MRK-1.11" value="11"/>
<note type="xref">[1:11] <canonRef book="GEN" chapter="22"
verse="2"/>
<canonRef book="PSA" chapter="2" verse="7"/>
<canonRef book="ISA" chapter="42" verse="1"/>
<canonRef book="MAT" chapter="3" verse="17"/>
<canonRef book="MAT" chapter="12" verse="18"/>
<canonRef book="MRK" chapter="9" verse="7"/>
<canonRef book="LUK" chapter="3" verse="22"/>
</note> And a voice came from heaven, You are my own dear Son. I am
pleased with#you.<qEnd/>
<verseEnd id="BCV-MRK-1.11-END" from="BCV-MRK-1.11"/>
</p>
<p>
<verse id="BCV-MRK-1.12" value="12"/>At once the Spirit made him go
into the desert,
<verseEnd id="BCV-MRK-1.12-END" from="BCV-MRK-1.12"/>
<verse id="BCV-MRK-1.13" value="13"/>where he stayed forty days, being tempted
by Satan. Wild animals were there also, but angels came and helped#him.
<verseEnd id="BCV-MRK-1.13-END" from="BCV-MRK-1.13"/>
</p>
</div>
</text>
I can create the <verseEnd> correctly with
<xsl:template name="verseEnd">
<xsl:element name="verseEnd">
<xsl:attribute name="id">
<xsl:value-of
select="concat(preceding::verse[1]/@id,'-END')"/>
</xsl:attribute>
<xsl:attribute name="from">
<xsl:value-of select="preceding::verse[1]/@id"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
Thanks for your help. If it is easier in XSLT 2 that is okay if SAXON
handles it now.
Jim Albright
704 843-0582
Wycliffe Bible Translators
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list