Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Numbering paragraphs

Reply
Thread Tools

Numbering paragraphs

 
 
ar
Guest
Posts: n/a
 
      06-25-2003
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


 
Reply With Quote
 
 
 
 
Marrow
Guest
Posts: n/a
 
      06-25-2003
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="paragraph"/>
</body>
</html>
</xsl:template>

<xsl:template match="paragraph">
<xslaram 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" <(E-Mail Removed)> wrote in message
news:bdbokp$2g7$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie: css & "removing blank line between paragraphs" Jeff HTML 3 04-13-2010 09:27 AM
Default leading for paragraphs City Dweller HTML 13 04-08-2006 10:37 AM
Collapsable paragraphs... Rlrcstr ASP .Net 7 05-17-2005 12:34 AM
allowing user to enter paragraphs Jesse Engle C Programming 13 03-07-2004 08:20 AM
"left floated" paragraphs and images using CSS? jersie0 HTML 0 11-23-2003 02:43 AM



Advertisments