xsl-list
[Top] [All Lists]

RE: [XSL] extracting a verse

2002-12-17 15:11:40
[ Jim_Albright(_at_)wycliffe(_dot_)org]


   <text>
      <div>
         <chapter id="BCV-GEN-1" to="BCV-GEN-1-END" value="1"/>
         <head>The Story of#Creation</head>
         <p>
            <verse id="BCV-GEN-1.1" to="BCV-GEN-1.1-END" 
value="1"/>In the beginning, when God created the universe,
            <verseEnd id="BCV-GEN-1.1-END" from="BCV-GEN-1.1"/>
            <verse id="BCV-GEN-1.2" to="BCV-GEN-1.2-END" 
value="2"/>the earth was formless and desolate. The raging 
ocean that covered everything
was engulfed in total darkness, and the ......         </p>

Starting with this piece of Scripture I would like to extract 
just the contents of  verse 1. I have the start of the verse 
and verseEnd identified. Is there an easy way of doing the 
extraction? I know I can change it all to a verse centric 
model and do the extraction but in this paragraph centric 
model is it possible?


It is actually easy for the sample you supplied -

<xsl:template match="/text">
<results>
        <xsl:for-each select='div/p/verse'>
                <verse><xsl:value-of
select='following-sibling::text()[1]'/></verse>
        </xsl:for-each>
</results>
</xsl:template>

(You do not actually need the [1] in text()[1], but it shows the intent
clearly).

You can easily change the template if you just want a series of text
verses with no wrapper elements, but you will then want to use the
"text" output method, and insert newlines where necessary.

This was easy, but it would be harder if you had other elements embedded
in the verse.  It would have been better to wrap each verse in an
element rather than preceding it by a marker element.  In your sample,
though, it makes little difference.

Cheers,

Tom P

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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