[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: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 19 Dec 2002 00:57:49 GMT
eternal providence
I missed the start of this thread but is d-o-e acceptable?

If so it seems fairly easy, something like

<x>

<quote>
<verse/>No! penury, inertness and grimace,<endVerse/>
<verse/>In some strange sort, were the land's portion. <q>See<endVerse/>
<verse/>Or shut your eyes,</q> said Nature peevishly,<endVerse/>
<verse/><q>It nothing skills: I cannot help my case:<endVerse/>
<verse/>'Tis the Last Judgment's fire must cure this place,<endVerse/>
<verse/>Calcine its clods and set my prisoners free.</q><endVerse/>
</quote>

<quote>
<verse/><s><seg>Of Man's first disobedience,</seg> <seg>and the
fruit<endVerse/>
<verse/>Of that forbidden tree whose mortal taste <endVerse/>
<verse/>Brought death into the World,</seg> <seg>and all our
woe,</seg><endVerse/>
<verse/><seg>With loss of Eden,</seg> <seg>till one greater Man
<endVerse/>
<verse/>Restore us,</seg> <seg>and regain the blissful
seat,</seg><endVerse/>
<verse/><seg>Sing,</seg> <seg>Heavenly Muse,</seg> <seg>that,</seg>
<seg>on
the secret top <endVerse/>
<verse/>Of Oreb,</seg> <seg>or of Sinai,</seg> <seg>didst inspire
<endVerse/>
<verse/>That Shepherd who first taught the chosen seed <endVerse/>
<verse/>In the beginning how the heavens and earth <endVerse/>
<verse/>Rose out of Chaos:</seg> <seg>or,</seg> <seg>if Sion hill
<endVerse/>
<verse/>Delight thee more,</seg> <seg>and Siloa's brook that flowed
<endVerse/>
<verse/>Fast by the oracle of God,</seg> <seg>I thence <endVerse/>
<verse/>Invoke thy aid to my adventurous song,</seg><seg><endVerse/>
<verse/>That with no middle flight intends to soar <endVerse/>
<verse/>Above th' Aonian mount,</seg> <seg>while it pursues <endVerse/>
<verse/>Things unattempted yet in prose or rhyme.</seg></s><endVerse/>
<verse/><s><seg>And chiefly thou,</seg> <seg>O Spirit,</seg> <seg>that
dost
prefer <endVerse/>
<verse/>Before all temples th' upright heart and
pure,</seg><seg><endVerse/>
<verse/>Instruct me,</seg> <seg>for Thou know'st;</seg> <seg>Thou from
the
first <endVerse/>
<verse/>Wast present,</seg> <seg>and,</seg> <seg>with mighty wings
outspread, </seg><seg><endVerse/>
<verse/>Dove-like sat'st brooding on the vast Abyss,
</seg><seg><endVerse/>
<verse/>And mad'st it pregnant:</seg> <seg>what in me is dark
<endVerse/>
<verse/>Illumine,</seg> <seg>what is low raise and
support;</seg><seg><endVerse/>
<verse/>That,</seg> <seg>to the height of this great
argument,</seg><seg><endVerse/>
<verse/>I may assert Eternal Providence,</seg><seg><endVerse/>
<verse/>And justify the ways of God to men.</seg></s><endVerse/>
</quote>

</x>



gets transformed to


<?xml version="1.0" encoding="utf-8"?><x>

<quote>
<verse>No! penury, inertness and grimace,</verse>
<verse>In some strange sort, were the land's portion. <q>See</q></verse>
<verse><q>Or shut your eyes,</q> said Nature peevishly,</verse>
<verse><q>It nothing skills: I cannot help my case:</q></verse>
<verse><q>'Tis the Last Judgment's fire must cure this
place,</q></verse>
<verse><q>Calcine its clods and set my prisoners free.</q></verse>
</quote>

<quote>
<verse><s><seg>Of Man's first disobedience,</seg> <seg>and the
fruit</seg></s></verse>
<verse><s><seg>Of that forbidden tree whose mortal taste
</seg></s></verse>
<verse><s><seg>Brought death into the World,</seg> <seg>and all our
woe,</seg></s></verse>
<verse><s><seg>With loss of Eden,</seg> <seg>till one greater Man
</seg></s></verse>
<verse><s><seg>Restore us,</seg> <seg>and regain the blissful
seat,</seg></s></verse>
<verse><s><seg>Sing,</seg> <seg>Heavenly Muse,</seg> <seg>that,</seg>
<seg>on
the secret top </seg></s></verse>
<verse><s><seg>Of Oreb,</seg> <seg>or of Sinai,</seg> <seg>didst inspire
</seg></s></verse>
<verse><s><seg>That Shepherd who first taught the chosen seed
</seg></s></verse>
<verse><s><seg>In the beginning how the heavens and earth
</seg></s></verse>
<verse><s><seg>Rose out of Chaos:</seg> <seg>or,</seg> <seg>if Sion hill
</seg></s></verse>
<verse><s><seg>Delight thee more,</seg> <seg>and Siloa's brook that
flowed </seg></s></verse>
<verse><s><seg>Fast by the oracle of God,</seg> <seg>I thence
</seg></s></verse>
<verse><s><seg>Invoke thy aid to my adventurous
song,</seg><seg></seg></s></verse>
<verse><s><seg>That with no middle flight intends to soar
</seg></s></verse>
<verse><s><seg>Above th' Aonian mount,</seg> <seg>while it pursues
</seg></s></verse>
<verse><s><seg>Things unattempted yet in prose or
rhyme.</seg></s></verse>
<verse><s><seg>And chiefly thou,</seg> <seg>O Spirit,</seg> <seg>that
dost
prefer </seg></s></verse>
<verse><s><seg>Before all temples th' upright heart and
pure,</seg><seg></seg></s></verse>
<verse><s><seg>Instruct me,</seg> <seg>for Thou know'st;</seg> <seg>Thou
from the
first </seg></s></verse>
<verse><s><seg>Wast present,</seg> <seg>and,</seg> <seg>with mighty
wings
outspread, </seg><seg></seg></s></verse>
<verse><s><seg>Dove-like sat'st brooding on the vast Abyss,
</seg><seg></seg></s></verse>
<verse><s><seg>And mad'st it pregnant:</seg> <seg>what in me is dark
</seg></s></verse>
<verse><s><seg>Illumine,</seg> <seg>what is low raise and
support;</seg><seg></seg></s></verse>
<verse><s><seg>That,</seg> <seg>to the height of this great
argument,</seg><seg></seg></s></verse>
<verse><s><seg>I may assert Eternal
Providence,</seg><seg></seg></s></verse>
<verse><s><seg>And justify the ways of God to men.</seg></s></verse>
</quote>

</x>




by



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:output method="xml"/>

<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="verse">
<xsl:text disable-output-escaping="yes">&lt;verse></xsl:text>
<xsl:for-each select="ancestor::*[ancestor::quote]">
<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text disable-output-escaping="yes">></xsl:text>
</xsl:for-each>
</xsl:template>

<xsl:template match="endVerse">
<xsl:for-each select="ancestor::*[ancestor::quote]">
<xsl:sort select="-count(ancestor::*)" data-type="number"/>
<xsl:text disable-output-escaping="yes">&lt;/</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text disable-output-escaping="yes">></xsl:text>
</xsl:for-each>
<xsl:text disable-output-escaping="yes">&lt;/verse></xsl:text>
</xsl:template>

</xsl:stylesheet>

David

 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.