[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Optimizing preceding-sibling & following-sibling a

Subject: Re: Optimizing preceding-sibling & following-sibling axes (with key()?)
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 07 Apr 2010 16:13:00 -0400
Re:  Optimizing preceding-sibling & following-sibling a

You could work with a key defined like this:

<xsl:key name="headers-with" match="h6" use="generate-id(preceding-sibling::*

<xsl:key name="headers-with" match="h5" use="generate-id(preceding-sibling::*

<xsl:key name="headers-with" match="h4" use="generate-id(preceding-sibling::*

<xsl:key name="headers-with" match="h3" use="generate-id(preceding-sibling::*

<xsl:key name="headers-with" match="h2" use="generate-id(preceding-sibling::h1[1])"/>

Calling key('headers-with',generate-id(.)) will then get you all the headers that belong to the current node, if it's an h1-h5.

I can't speak for how fast the indexes would be to build -- in general, flat data sets present the potential for problems no matter what -- but they should be plenty fast to use.


At 02:56 PM 4/7/2010, you wrote:

I have such a variable definition (quite cumbersome):

<xsl:variable name="descendant-headings"
select="following-sibling::h:*[self::h:h1 or self::h:h2 or self::h:h3
or self::h:h4 or self::h:h5 or self::h:h6][o2e:heading-level(.) &gt;
o2e:heading-level(current())][preceding-sibling::h:*[self::h:h1 or
self::h:h2 or self::h:h3 or self::h:h4 or self::h:h5 or
self::h:h6][o2e:heading-level(.) = o2e:heading-level(current())][1] is

Basically, I need to select all descendant (level-wise, not as in
descendant axis) headings for the current() one, meaning all following
headings with lower level which go before the next heading one the
same level as current(). This expression gives me what I need.
o2e:heading-level() function simply extracts the level number from
elements name, like 'h3'.

Now, I've read multiple times that preceding-sibling/following-sibling
are slow. I wonder if this expression could be optimized?
I also have a key definition which I use for similar purposes:

<xsl:key name="heading-by-level" match="h:h1 | h:h2 | h:h3 | h:h4 |
h:h5 | h:h6" use="number(substring-after(local-name(), 'h'))"/>

I just can't figure out how combine this key with the sibling axes to
get the same result and improve performance, i.e. that instead of
traversing the whole document it would be enough to traverse key()
values, like in key('heading-by-level', 1 to 6).
Does it make sense?



Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
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

Current Thread


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.
First Name
Last Name
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.