[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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
|