473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

XSLT Table of Contens

Can someone help me! I'am trying to develope a XSTL that make me
automatic a "Table of Centens" from a XML Document.

my XLM File looks like this:
-------------------------------------
<section>
<title>Index1</title>
</section>
<section>
<title>Index2</title>
<section>
<title>Index21</title>
<section>
<title>Index211</title>
</section>
</section>
<section>
<title>Index22</title>
</section>
</section>
<section>
<title>Index3</title>
</section>
-------------------------------------

And a want to get this output:
-------------------------------------
<h2>Toc<h2>
<ol>
<li>Index1 </li>
<li>Index2
<ol>
<li>Index21
<ol>
<li>Index211</li>
</ol>
</li>
<li>Index22</li>
</ol>
</li>
<li>Index3</li>
</ol>
Alexander W. (wa******@web.de)
Jul 20 '05 #1
2 1506
wa******@web.de a écrit :
Can someone help me! I'am trying to develope a XSTL that make me
automatic a "Table of Centens" from a XML Document.


This should do it :

<xsl:template match="/">
<h2>Toc</h2>
<ol>
<xsl:apply-templates />
</ol>
</xsl:template>

<xsl:template match="section">
<li><xsl:apply-templates select="title" />
<xsl:if test="count(section)&gt;0">
<ol>
<xsl:apply-templates select="section"/>
</ol>
</xsl:if>
</li>
</xsl:template>

A good entry point about XSLT :
http://www.zvon.org/xxl/XSLTutorial/Output/index.html

Hth

--
Rémi Peyronnet
Jul 20 '05 #2
Thanks Rémi Peyronnet! Works fine.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Doug Farrell | last post by:
Hi all, I'm trying to use the 4Suite xml/xsl tools to transform some XML data into HTML. I'm using some examples from the O'Reilly book "Python and XML" and things are blowing up. Here is the...
12
by: gipsy boy | last post by:
Hello, I have sort of a big problem. I would really appreciate any help you could give me. I made a web service in C++ that throws XML to the client (browser). But, the XSLT transormation...
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
1
by: Thom Anderson | last post by:
Hi, I'm a newbee at XML so I need to ask this. I have an xml data like follows. <?xml version="1.0" encoding="utf-8" ?> <salesRep repnum="123" orgdate="16"> <fname>Joe</fname>...
2
by: Scamjunk | last post by:
I have been desperately looking for a treeview-type solution for my problem for the past three weeks and have been greatly unsuccessful. I am totally new to the world of XSLT and I *don't know*...
0
by: DAnne | last post by:
Hi, I'm very new to xslt and this is my first time posting to a Forum so please forgive me if I transgress any protocols. I have to do a tally report. This report is divided up into sections....
2
by: Adam dR. | last post by:
I have an xml file similar to: <menu> <menuitem name="home" show="false"/> <menuitem name="about" show="true"/> <menuitem name="links" show="true"/> <menuitem name="games" show="true"/>...
2
by: Jonny B | last post by:
Hi all, I'm working on an a clientside xslt using jscript that passes a parameter to the xsl. I've got it working no problem in IE but cant get it to work in Mozilla. Can anyone help? This is...
2
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.