[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Processing milestoned XML leads to many preceding:
On 21/02/2012 09:07, MatDj Cepl wrote:
There are quite a few things that can be done to improve your XSLT code, as Andrew has pointed out; especially if you move to an XSLT 2.0 processor. But the problem is not a superficial coding problem, it's the basic algorithmic design. Looking at that horrendous XPath expression select="count(./preceding::kap[1]/following::*[not(count(preceding-sibling::vers|current()) = count(preceding-sibling::vers))])" XSLT 2.0 allows you to simplify the predicate to [not(preceding-sibling::vers intersect current())], but that isn't going to solve the problem for you: no processor I can think of will improve preceding::x/following::x so that it isn't quadratic in the size of the document, and you are doing this once for each verse, so that makes it cubic. I think the right way to tackle this is to do a 2-phase transformation. The first should convert your milestoned XML into normal hierarchic XML, and the second should process the hierarchic XML to do whatever you want to do with it. The first phase will typically use sibling recursion if you use XSLT 1.0, or positional grouping if you use XSLT 2.0. Either way, it should have linear performance (though with XSLT 1.0 you may hit stack overflow problems if the recursion goes too deep). Michael Kay Saxonica
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|