🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.text.xml
Article #414

Table des matières

#414
From: Cbc
Date: Wed, 18 Jul 2007 12:48
53 lines
2092 bytes
Bonjour,

Soit un document :

<h1>Partie 1</h1>
<p>...</p>
<p>...</p>
<h2>Sous-partie 1.1</h2>
<p>...</p>
<h2>Sous-partie 1.2</h2>
<p>...</p>
<p>...</p>
<h1>Partie 2</h1>
<p>...</p>

Je voudrai le transformer par XSLT en :

<ul>
   <li>Partie 1</li>
   <ul>
     <li>Sous-partie 1.1</li>
     <li>Sous-partie 1.2</li>
   </ul>
   <li>Partie 2</li>
</ul>


J'ai essay� :

<xsl:template match="/root">
   <xsl:apply-templates select="h1" mode="toc"/>
</xsl:template>

<xsl:template match="h1" mode="toc">
   <ul>
     <li><xsl:value-of select="text()" /></li>
     <xsl:apply-templates 
select="//h2[preceding-sibling::h1[position()=1]=self::h1]" mode="toc"/>
   </ul>
</xsl:template>

<xsl:template match="h2" mode="toc">
   <ul>
     <li><xsl:value-of select="text()" /></li>
   </ul>
</xsl:template>

mais �a ne me donne que les noms de parties de niveau 1, ce qui signifie 
que l'expression "//h2[preceding-sibling::h1[position()=1]=self::h1]" 
pour s�lectionner les <h2/> tels que le premier <h1/> pr�c�dent soit le 
noeud courant, n'est pas correcte. Comment faire?

Merci
Technical Details
Message-ID: <469e0c0e$0$25927$ba4acef3@news.orange.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!exabot.com!freenix!news.wanadoo.fr!news.wanadoo.fr!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114f60,1af0c9cb3eb6a3ce,start
X-Google-Attributes: gid114f60,public,usenet
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!exabot.com!freenix!news.wanadoo.fr!news.wanadoo.fr!not-for-mail
Date: Wed, 18 Jul 2007 14:48:08 +0200
From: Cbc <cbc@yahooNS.fr>
User-Agent: Thunderbird 1.5.0.5 (Windows/20060719)
MIME-Version: 1.0
Newsgroups: fr.comp.text.xml
Subject: Table des matières
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Antivirus: avast! (VPS 000757-3, 17/07/2007), Outbound message
X-Antivirus-Status: Clean
Lines: 53
Message-ID: <469e0c0e$0$25927$ba4acef3@news.orange.fr>
Organization: les newsgroups par Orange
NNTP-Posting-Date: 18 Jul 2007 14:48:15 CEST
NNTP-Posting-Host: 86.212.20.36
X-Trace: 1184762895 news.orange.fr 25927 86.212.20.36:4115
X-Complaints-To: abuse@orange.fr