[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: [XSL] extracting a verse

Subject: RE: [XSL] extracting a verse
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Tue, 17 Dec 2002 17:11:40 -0500
tom turkey s verse
[ Jim_Albright@xxxxxxxxxxxx]

> 
>    <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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.