🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Table des matières

#415
From: Philippe Poulard
Date: Wed, 18 Jul 2007 13:32
83 lines
3051 bytes
Cbc a �crit :
> 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>

<li><xsl:apply-templates select="." /></li>
<!--s'il y a de la mise en forme dans <h1>, il suffira de faire des 
templates pour <b>, <i> etc-->

>     <xsl:apply-templates 
> select="//h2[preceding-sibling::h1[position()=1]=self::h1]" mode="toc"/>

      <xsl:apply-templates
  select=".//h2[preceding-sibling::h1[1]=self::h1]" mode="toc"/>

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

<li><xsl:apply-templates select="." /></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?

//truc est un raccourci pour /descendant-or-self::node()/truc
donc il ne faut pas partir de la racine :
.//h1

> 
> Merci


-- 
Cordialement,

               ///
              (. .)
  --------ooO--(_)--Ooo--------
|      Philippe Poulard       |
  -----------------------------
  http://reflex.gforge.inria.fr/
        Have the RefleX !
Technical Details
Message-ID: <f7l4p7$tgg$1@news-sop.inria.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!club-internet.fr!feedme-small.clubint.net!proxad.net!feeder1-1.proxad.net!oleane.net!oleane!ciril.fr!news-rocq.inria.fr!news-sop.inria.fr!not-for-mail
References: <469e0c0e$0$25927$ba4acef3@news.orange.fr>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114f60,1af0c9cb3eb6a3ce
X-Google-Attributes: gid114f60,public,usenet
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!club-internet.fr!feedme-small.clubint.net!proxad.net!feeder1-1.proxad.net!oleane.net!oleane!ciril.fr!news-rocq.inria.fr!news-sop.inria.fr!not-for-mail
From: Philippe Poulard <philippe.poulardNO@SPAMinria.fr>
Newsgroups: fr.comp.text.xml
Subject: Re: Table des matières
Date: Wed, 18 Jul 2007 15:32:26 +0200
Organization: INRIA - Unite de Recherche Sophia Antipolis (France)
Lines: 83
Message-ID: <f7l4p7$tgg$1@news-sop.inria.fr>
References: <469e0c0e$0$25927$ba4acef3@news.orange.fr>
NNTP-Posting-Host: dahu2.inria.fr
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: janus.inria.fr 1184765543 30224 138.96.213.1 (18 Jul 2007 13:32:23 GMT)
X-Complaints-To: abuse@sophia.inria.fr
User-Agent: Thunderbird 1.5.0.12 (X11/20070604)
In-Reply-To: <469e0c0e$0$25927$ba4acef3@news.orange.fr>