XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Dev PatelSubject: Generating flexible multi-level recursive nested lists-Challenging
Author: Dev Patel
Date: 06 Jun 2006 06:07 PM
Originally Posted: 06 Jun 2006 05:16 PM
Hello,

I was wondering if somebody can help me to generate Multilevel OL and LI. Here is the input and output expected. If we add some more levels like level4 or level5, xslt should be able generate output without any change in it.

I have been trying this since many days.

I would highly appreciate your help. Thanks in advance.

INPUT xml file
-------------

<doc>
<p style="level1">
ALevel1
</p>
<p style="level1">
BLevel1
</p>
<p style="level2">
aLevel2
</p>
<p style="level2">
bLevel2
</p>
<p style="level1">
CLevel1
</p>
<p style="level1">
DLevel1
</p>
<p style="level2">
aLevel2
</p>
<p style="level2">
bLevel2
</p>
<p style="level3">
iLevel3
</p>
<p style="level3">
iiLevel3
</p>
<p style="level2">
cLevel2
</p>
<p style="level1">
ELevel1
</p>
</doc>


OUTPUT EXPECTED- html file
---------------
<html>
<body>
<ol>
<li>
ALevel1
</li>
<li>
BLevel1
</li>
<ol>
<li>
aLevel2
</li>
<li>
bLevel2
</li>
</ol>
<li>
CLevel1
</li>
<li>
DLevel1
</li>
<ol>
<li>
aLevel2
</li>
<li>
bLevel2
</li>
<ol>
<li>
iLevel3
</li>
<li>
iiLevel3
</li>
</ol>
<li>
cLevel2
</li>
</ol>
<li>
ELevel1
</li>
</ol>
</body>
</html>

Postnext
Ivan PedruzziSubject: Generating flexible multi-level recursive nested lists-Challenging
Author: Ivan Pedruzzi
Date: 07 Jun 2006 12:40 AM
Originally Posted: 07 Jun 2006 12:39 AM
Dev,

The attached solution assumes that the attribute "style" value has numbers only at the end, for example: style1, style2, ..., style100

It uses the translate function to preserve only characters that represents digits. For example if @style is style1 it returns 1

translate(@style, translate(@style, '1234567890', ''),'')

Hope this helps
Ivan Pedruzzi
Stylus Studio Team


Documentlevels(1).xsl

Posttop
Dev PatelSubject: Generating flexible multi-level recursive nested lists-Challenging
Author: Dev Patel
Date: 07 Jun 2006 05:22 PM
Thank you very much for your help.

Regards,

Dev

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.