xsl-list
[Top] [All Lists]

Re: [XSL] extracting a verse

2002-12-18 16:21:43
Hi Michael,

At 05:21 PM 12/18/2002, you wrote:
Thanks for the encouragement. I can't really say that I will be able to spend any more time on this, but it seemed like there should be a relatively simple tale-recursive solution. (which is what the third template below name="nextsib") really is. The rest is just wrapping.

Heh -- you're not the first one to say this. (I said it myself when I started looking at this problem, two years ago or so. The last time I said it ... Jeni made fun of me. Not that I mind *that* attention, mind you.) "The rest is just wrapping", indeed. :->

A simpler example to chew on -- transform

<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>
(from Rob't Browning, "Childe Roland to the Dark Tower Came", 61-66)

into

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

When the second verse is processed, we have to include a <q> with the text node "See", but none of the <q> element's other text node children. Fine. But we also need the next verse to contain a new <q> element to wrap the text node "Or shut your eyes". Likewise in later lines, which contain an extended quote that has either to be split among three verses (and it would be nice if they pointed to one another), or inverted to contain them (as a poor alternative). The solution to this problem also has to be recursive, since again things could be arbitrarily deep (we might be deeper than a single <q> when a line breaks).

The lesson for now seems to be to narrow the problem, if possible, into something easier than the general case (that still achieves your goals), and go for that.

Mind you, I'm not saying the general solution isn't possible, especially given more than one pass (maybe a flattening pass followed by a rebuilding pass). This list has already sponsored more than its share of creative leaps.

Cheers,
Wendell



======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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