From: Laurent Raffalli (laurent.raffalli@auto-contact.com)
Date: 30/01/2001 - 11:13
la page suivante permet en fonction de plusieurs variables de sélectionner
les produits à afficher. Jusque là tout va bien.
je voulais savoir s'il était possible de réaliser la même chose d'une
manière plus simple ????
voici ma page XSL
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:variable name="etat">R</xsl:variable>
<xsl:variable name="categorie"></xsl:variable>
<xsl:template match="/">
<HTML>
<HEAD>
</HEAD>
<BODY>
<b><u>PRODUIT</u></b>
<p></p>
<div id="page">
<table border="1" cellspacing="1">
<tr>
<th>Commander</th>
<th>Désignation</th>
<th width="40%">Description</th>
<th>Prix (Francs)</th>
</tr>
<xsl:choose>
<xsl:when test="$categorie=''">
<xsl:choose>
<xsl:when test="$etat=''">
<xsl:apply-templates
select="PRODUITS/PRODUIT[ACTIF='O']">
<xsl:sort select="LIBELLE"
order="ascending"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates
select="PRODUITS/PRODUIT[ACTIF='O' and ETAT=$etat]">
<xsl:sort select="LIBELLE"
order="ascending"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$etat=''">
<xsl:apply-templates
select="PRODUITS/PRODUIT[ACTIF='O' and CATEGORIE=$categorie]">
<xsl:sort select="LIBELLE"
order="ascending"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates
select="PRODUITS/PRODUIT[ACTIF='O' and CATEGORIE=$categorie and
ETAT=$etat]">
<xsl:sort select="LIBELLE"
order="ascending"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</table>
</div>
<input type="button"
onclick="javascript:alert(document.body.innerHTML);"/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="PRODUIT">
<tr>
<td><input type="checkbox" name="panier" value="{ID}"></input></td>
<td><xsl:value-of select="LIBELLE"/></td>
<td><xsl:value-of select="DESCRIPTIF"/></td>
<td align="center">
<xsl:choose>
<xsl:when test="PRIXSPECIAL[.='']"><xsl:value-of
select="PRIX"/></xsl:when>
<xsl:otherwise><s><xsl:value-of select="PRIX"/></s>/<xsl:value-of
select="PRIXSPECIAL"/></xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Laurent RAFFALLI
AUTO CONTACT
210, rue du Jardin Public
33 000 BORDEAUX
Tél: 05 56 69 21 44
e-mail : laurent.raffalli@auto-contact.com
--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !
Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).
Cette liste est a votre disposition pour discuter en francais de
tout sujet technique lie a XML.
Pour resilier votre abonnement, envoyez un message contenant
la commande "unsubscribe" a xml-tech-request@xmlfr.org
(mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
Archive générée par hypermail 2.1.3 le 28/06/2004 - 11:05 UTC
webmaster@xmlfr.org
|