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

Re: Constructing multi-level lists - any better than

Subject: Re: Constructing multi-level lists - any better than this?
From: Michael Müller-Hillebrand <mmh@xxxxxxxxxxxxx>
Date: Mon, 17 Sep 2007 09:29:54 +0200
Re:  Constructing multi-level lists - any better than
Geert, Andrew, Abel,

Thanks a lot for your input to a (kind-of) solved problem. I really
appreciate the support from more experienced programmers.

Geert's solution is along what in the FAQs is called "tree-walking".
I like that it is shorter than mine and does not need to use
priority. It is easier to understand/explain and can be extended to
the case I have on my desk. And I thought xsl:key is always the
coolest solution... you still have to think 'around the corner' with
this tree-walker.

Andrew: I was longing for a solution with some XSLT2 but I have a
problem with group-starting-with="*[self::p]", because the p elements
are just placeholders for any other element that does not belong to a
list and may appear any number of times. So the source XML is a
mixture of some non-list elements followed by some list elements
followed by some non-list elements... The source may even begin with
some list elements. Perhaps my example was too much stripped down.
This would have illustrated it better:

<?xml version="1.0" encoding="UTF-8"?>
<levels>
<li1>1</li1>
<li2>2.1</li2>
<li2>2.2</li2>
<li1>3</li1>
<li1>4</li1>
<p/>
<any/>
<li1>5</li1>
<li1>6</li1>
<li2>7.1</li2>
<li2>7.2</li2>
<any/>
<p/>
<li2>8.1</li2>
<li2>8.2</li2>
<li1>9</li1>
<li1>10</li1>
<any/>
<p/>
</levels>

Abel, thanks for dealing with the more general issue of multiple
levels. Your way of doing it seems like a hybrid of for-each-group
and the tree-walker. It seems to me it uses the group only to get the
first element and then walks the tree, then creates a sub-group...
Oh, I have to look more into this, especially into the the use of
xsl:function which helps to clean-up the code (which I need, because
the elements I have are a bit more complicated than in my example).

For today, I'll go with Geert's approach, enhanced by some
xsl:function to make the match attributes in my real world case more
readable.

Thanks again for shifting my mind into XSL more than  I could have
achieved on my own!

- Michael M|ller-Hillebrand

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.