Article View: fr.comp.text.xml
Article #412Re: [XSLT] regrouper plusieurs balises
From: Philippe Poulard
Date: Mon, 16 Jul 2007 15:32
Date: Mon, 16 Jul 2007 15:32
79 lines
2901 bytes
2901 bytes
bon, je me lance ; si la liste des �l�ments ne fait pas 3km de long,
c'est jouable malgr� les aller-retours...
<!--on est sur le premier tag d'une liste-->
<xsl:template
match="tag[not(preceding-sibling::*[1]=preceding-sibling::tag[1])]">
<tags>
<!--on s�lectionne le premier tag, et les suivants qui
n'ont pas de pr�c�dent non-"tag" qui soit apr�s le
premier (vous suivez ?)-->
<xsl:apply-template select="self::tag |
following-sibling::tag[not(preceding-sibling::*[not(self::tag)][.=current()/following-sibling::*[not(self::tag)]])]"
mode="display"/>
</tags>
</xsl:template>
<!--on est sur les tags d'une liste, mais pas le premier-->
<xsl:template match="tag"/>
<!--pour copier les tags-->
<xsl:template match="tag" mode="display">
<xsl:copy-of select="."/>
</xsl:template>
voil� : pas test�, en direct, et sans filet
j'esp�re ne pas m'�craser trop violemment :)
Cbc a �crit :
> Bonjour,
>
> dans un document XML, j'ai :
>
> ...
> <a>...</a>
> <b>...</b>
> <tag>...</tag>
> <tag>...</tag>
> <tag>...</tag>
> <c>...</c>
> <tag>...</tag>
> <tag>...</tag>
> <d>...</d>
> <e>...</e>
> ...
>
> que je voudrais remplacer en XSLT par :
>
> ...
> <a>...</a>
> <b>...</b>
> <tags>
> <tag>...</tag>
> <tag>...</tag>
> <tag>...</tag>
> </tags>
> <c>...</c>
> <tags>
> <tag>...</tag>
> <tag>...</tag>
> </tags>
> <d>...</d>
> <e>...</e>
> ...
>
> Comment faire?
>
> Merci
--
Cordialement,
///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
Technical Details
Message-ID:
<f7g335$4n4$1@news-sop.inria.fr>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!62.216.30.27.MISMATCH!newsgate.cistron.nl!xs4all!feeder.news-service.com!club-internet.fr!feedme-small.clubint.net!grolier!ciril.fr!news-rocq.inria.fr!news-sop.inria.fr!not-for-mailReferences:
<4698f085$0$5092$ba4acef3@news.orange.fr>Show Full Headers
Complete Article Headers
X-Google-Thread: 114f60,a24909d6001453e7 X-Google-Attributes: gid114f60,public,usenet X-Google-Language: FRENCH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!62.216.30.27.MISMATCH!newsgate.cistron.nl!xs4all!feeder.news-service.com!club-internet.fr!feedme-small.clubint.net!grolier!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: [XSLT] regrouper plusieurs balises Date: Mon, 16 Jul 2007 17:32:55 +0200 Organization: INRIA - Unite de Recherche Sophia Antipolis (France) Lines: 79 Message-ID: <f7g335$4n4$1@news-sop.inria.fr> References: <4698f085$0$5092$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 1184599973 4836 138.96.213.1 (16 Jul 2007 15:32:53 GMT) X-Complaints-To: abuse@sophia.inria.fr User-Agent: Thunderbird 1.5.0.12 (X11/20070604) In-Reply-To: <4698f085$0$5092$ba4acef3@news.orange.fr>