🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: XSL : insrtion conditionnelle de balise HTML

#8766
From: Thomas Broyer
Date: Tue, 24 Jul 2001 20:18
55 lines
2397 bytes
In <9jkin3$5k2$1@fenris.isp.9tel.net>, Christian Delaunay wrote:
> dans un fichier xsl, je voudrais rendre conditionnelle l'insertion d'une
> balise HTML, ce qui donnerait ( dans mon cas ) qqchose comme :
> 
> ...
> <xsl:if test="...">
>     <TR>
>     <TBODY>
> </xsl:if>
> ...
> 
> Le probl�me est que le parseur ( MSXML 3 depuis IE 5 )
> ne d�tectant pas les balises </TBODY> et </TR> g�n�re une erreur.
> 
> Y a t il une astuce pour r�soudre ce genre de probl�me ?

Il y a un article sur IBM developerWorks
http://www-106.ibm.com/developerworks/library/x-divel.html?n-x-7121

Sinon, l'"astuce" la plus simple est d'aller au plus logique :
  <xsl:choose>
  <xsl:when test="...">
    <tbody>
    <tr>
      <!-- ici le traitement "normal" -->
    </tr>
    </tbody>
  </xsl:when>
  <xsl:otherwise>
    <!-- ici le traitement "normal" -->
  </xsl:otherwise>
  </xsl:choose>

Et tu as la possibilit� de "factoriser" le �traitement "normal"� en passant 
par un template nomm� :
  <xsl:template name="foo">
    <!-- ici le traitement "normal" -->
  </xsl:template>

  ...
  <xsl:choose>
  <xsl:when test="...">
    <tbody>
    <tr>
      <xsl:call-template name="foo"/>
    </tr>
    </tbody>
  </xsl:when>
  <xsl:otherwise>
     <xsl:call-template name="foo"/>
  </xsl:otherwise>
  </xsl:choose>
  ...

Tom.
Technical Details
Message-ID: <15563145.eYUQgxmLvF@ltgt.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.usenet-edu.net!usenet-edu.net!wanadoo.fr!proxad.net!feeder2-1.proxad.net!nnrp4.proxad.net.POSTED!not-for-mail
References: <9jkin3$5k2$1@fenris.isp.9tel.net>

Show Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII
X-Google-Thread: 114f60,c86f9bd60a4a1cf7
X-Google-Attributes: gid114f60,public
X-Google-ArrivalTime: 2001-07-24 13:18:15 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.usenet-edu.net!usenet-edu.net!wanadoo.fr!proxad.net!feeder2-1.proxad.net!nnrp4.proxad.net.POSTED!not-for-mail
Message-ID: <15563145.eYUQgxmLvF@ltgt.net>
From: Thomas Broyer <ptittom+news@free.fr>
Subject: Re: XSL : insrtion conditionnelle de balise HTML
Newsgroups: fr.comp.text.xml
References: <9jkin3$5k2$1@fenris.isp.9tel.net>
Lines: 55
Organization: </>
User-Agent: KNode/0.5.6
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8Bit
Date: Tue, 24 Jul 2001 20:18:15 GMT
NNTP-Posting-Host: 193.251.185.50
X-Complaints-To: abuse@proxad.net
X-Trace: nnrp4.proxad.net 996005895 193.251.185.50 (Tue, 24 Jul 2001 22:18:15 CEST)
NNTP-Posting-Date: Tue, 24 Jul 2001 22:18:15 CEST