[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: Wed, 18 Dec 2002 11:54:52 -0500
html scraping perl
[Jim_Albright@xxxxxxxxxxxx]

> Yes the example I gave was simplified. There can be other 
> elements present that would exclude a simple text() answer.
> 

I thought it might be too simplified, but you have picked up on a useful
way of thinking about the problem, which is what I hoped to convey.

> But it got me thinking. Is there a way of saying
> 
> the intersection of
> all nodes following verse    with id="BCV-GEN-1.1"
> AND
> all nodes preceding verseEnd with id="BCV-GEN-1.1-END"
> 
> If so that would give me all the nodes contained within 
> verse. My vocabulary is of Venn diagrams.
> 

Yes, in xslt 1.0 you can form intersections.  How to do so is a bit
arcane - for two node sets $A and $B, the intersection is

$A[count(.|$B) = count($B)]

This expression selects nodes that are common to both $A and $B.  The
idiom is in various FAQs and is shown in the 2nd edition of Mike Kay's
book "XSLT Programmer's reference) on page 425.  Some processors have
extensions for intersections, and xslt2.0 will make it easier, I
understand.

This approach will work as long as you can specify the criteria for
inclusion in the intersection.  However, for a large work, it may
execute slowly since the processor may have to look through and check
each element (or each verse element) in the document, perhaps several
times, as it checks each member of the two sets.  That is one reason why
it is usually better to use containing elements rather than marker
elements (your verse elements function as markers in the text).

However, if you cannot redesign the xml format then this approach ought
to work.  I have used it for screen-scraping html pages with good
success.

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.