[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: "Michael H. Semcheski" <mhs-list@xxxxxxxxx>
Date: Wed, 18 Dec 2002 14:26:37 -0500
jitt durusau donnell
I started thinking about this, and I think I have an approach somewhere in between the JITT and the BUVH. Its pretty simple, actually, so I am wondering if there is a reason that this didn't already come up. I can't really play around with it anymore, but this might be a step...

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/quote">
<xsl:for-each select="verse">
<xsl:call-template name="showverse">
<xsl:with-param name="vcont" select="."></xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>


<xsl:template name="showverse">
<xsl:param name="vcont"/>
<xsl:call-template name="nextsib">
<xsl:with-param name="csib" select="following::*"/>
</xsl:call-template><hr/>
</xsl:template>
<xsl:template name="nextsib">
<xsl:param name="csib"/>
<xsl:value-of select="$csib[1]"/>
<xsl:if test="name($csib[1])!='endVerse'">
<xsl:call-template name="nextsib">
<xsl:with-param name="csib" select="$csib/descendant::*"/>
</xsl:call-template>
<xsl:if test="not($csib/descendant::endVerse)">
<xsl:call-template name="nextsib">
<xsl:with-param name="csib" select="$csib/following::*"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>



One approach is to go "bottom up". This is what Patrick Durusau and Matthew O'Donnell, who (AFAIK) have done the most work in public with this problem, call a "bottom-up virtual hierarchy" (BUVH). One pass flattens *everything* into milestones; the second interpolates the hierarchy you want. (Actually this is a simplification of what they did, though I don't see why it wouldn't work.) This is doable, but quite hairy if you want to preserve any of the original hierarchy, and so processor intensive that you don't want to be trying it on large texts. More lately, their efforts have shifted to an approach they call JITTs ("Just-in-Time Trees"), in which the verse starts and ends are promoted from atomic milestones into real element starts and ends. (A pre-XML-parse process then extracts the hierarchy you want.) While charmingly enunciated, and (I believe) ultimately on the right track, this approach suffers (IMHO) because it tries to repeal the First Law of XML Markup: "Thou Shalt be Cleanly Nested", thereby risking unnecessary Uncertainty and Doubt, if not actually Fear.




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.