473,402 Members | 2,050 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,402 software developers and data experts.

Numbering paragraphs

ar
Hello,

My XML document is :
....
<paragraph title="Level 1 - Number 1">
<paragraph title="Level 2 - Number 1">
<paragraph title="Level 3 - Number 1">
...
</paragraph>
<paragraph title="Level 3 - Number 2">
...
</paragraph>
</paragraph>

<paragraph title="Level 2 - Number 2">
<paragraph title="Level 3 - Number 1">
...
</paragraph>
<paragraph title="Level 3 - Number 2">
...
</paragraph>
</paragraph>

</paragraph>
....

I'd like to number these paragraphs
1 - Level 1 - Number 1
1.1 - Level 2 - Number 1
1.1.1 - Level 3 - Number 1
1.1.2 - Level 3 - Number 2
1.2 - Level 2 - Number 2
1.2.1 - Level 3 - Number 1
1.2.2 - Level 3 - Number 2

I can have any number of paragraph levels.

Any idea on how to do that ?

Best regards
AR
Jul 20 '05 #1
1 1858
Hi AR,

Do you mean in XSLT?

If so, then <xsl:number> will do exactly what you want - for example...

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="paragraph"/>
</body>
</html>
</xsl:template>

<xsl:template match="paragraph">
<xsl:param name="level" select="0"/>
<div style="margin-left: {15 * $level}px;">
<xsl:number count="paragraph" level="multiple"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@title"/>
<xsl:apply-templates select="paragraph">
<xsl:with-param name="level" select="$level + 1"/>
</xsl:apply-templates>
</div>
</xsl:template>
</xsl:stylesheet>

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator

"ar" <bi***@email.com> wrote in message
news:bd**********@news-reader4.wanadoo.fr...
Hello,

My XML document is :
...
<paragraph title="Level 1 - Number 1">
<paragraph title="Level 2 - Number 1">
<paragraph title="Level 3 - Number 1">
...
</paragraph>
<paragraph title="Level 3 - Number 2">
...
</paragraph>
</paragraph>

<paragraph title="Level 2 - Number 2">
<paragraph title="Level 3 - Number 1">
...
</paragraph>
<paragraph title="Level 3 - Number 2">
...
</paragraph>
</paragraph>

</paragraph>
...

I'd like to number these paragraphs
1 - Level 1 - Number 1
1.1 - Level 2 - Number 1
1.1.1 - Level 3 - Number 1
1.1.2 - Level 3 - Number 2
1.2 - Level 2 - Number 2
1.2.1 - Level 3 - Number 1
1.2.2 - Level 3 - Number 2

I can have any number of paragraph levels.

Any idea on how to do that ?

Best regards
AR

Jul 20 '05 #2

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

Similar topics

2
by: Andy Glew | last post by:
I have long looked for (and occasionally posted questions to groups such as this about) a tool that can take a group of HTML pages (nowadays XHTML, or XML) and produce a nicely formatted...
6
by: Stanimir Stamenkov | last post by:
So if the 'type' attribute of the OL element is deprecated and authors should rely only on stylesheets how one could use a reference (as clear text) in the content to a particular list element? ...
40
by: | last post by:
Could someone cite some offical rule or documentation with regard to the <P> tag? I've seen folks put it in between paragraphs... and others wrap it around a paragraph. I'd think to use it...
2
by: needhelp | last post by:
This one ought to be simple, but I have dug myself deeper and deeper, and gone farther and farther from what I wanted and I'm giving up. And my html that I've written is so bolloxed up now that...
6
by: Christian Roth | last post by:
Hello, how do I offset the numbering of a list in XHTML Strict (+CSS) in current browsers? What I want is something like: 5. Item a 6. Item b 7. Item c
7
by: Joe | last post by:
Hello, The code below is an entire HTML page that has a problem when using a <p> tag inside a CSS box (when running IE6). I was being a good boy and I replaced my single-cell <table> elements...
5
by: Charles McCaffery | last post by:
I have written a database with auto-numbering and now wish to remove alkl of my test data and set the auto-numbering back to one. How do I do this please? Charles McCaffery.
7
by: Jukka K. Korpela | last post by:
After noticing that IE 7 beta supports selectors like p+p, I started wondering how to achieve a simple rendering of paragraphs so that 1) there is no vertical spacing between paragraphs (i.e. the...
5
by: keoo | last post by:
Im putting the part of the code which is relevant to my question......The program is opening the texfile which i already have created..Im not quite managing to make the program count the number of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.