From: chris bable (bable2m3@yahoo.fr)
Date: 26/11/2003 - 23:42
Bonjour,
je souhaite obtenir un fichier menu.html du type (avec en plus une mise en page particulière) :
-----------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- __________________________________________________________________________________ -->
<!-- ne rien changer dans le xsl -->
<!-- __________________________________________________________________________________ -->
<script type="text/javascript">
<!--
function montre(id) {
if (document.getElementById) {
document.getElementById(id).style.display="block";
} else if (document.all) {
document.all[id].style.display="block";
} else if (document.layers) {
document.layers[id].display="block";
} }
function cache(id) {
if (document.getElementById) {
document.getElementById(id).style.display="none";
} else if (document.all) {
document.all[id].style.display="none";
} else if (document.layers) {
document.layers[id].display="none";
} }
//-->
</script>
<style type="text/css">
<!--
ul, li {
margin: 0;
padding: 0;
list-style-type: none;
font-size: 10px;
font-family: verdana, arial, sans-serif;
font-weight: normal;
}
.menu {
clear: both;
margin-top: 5px;
width: 150px;
height: 20px;
border: 1px solid #ccc;
background-color: #ddd;
text-align: center;
font-size: 12px;
font-weight: bold;
}
#smenu1, #smenu2, #smenu3, #smenu4 {
float: left;
display: none;
font-size: 8px;
padding: 5px 0 5px 0;
width: 150px;
background-color: #eee;
}
a {text-decoration: none;
color: #222;
}
a:hover{text-decoration: underline;
}
-->
</style>
<!-- __________________________________________________________________________________ -->
<!-- fin de ne rien changer dans le xsl -->
<!-- __________________________________________________________________________________ -->
</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#000000">
<tr>
<td width="100%" align="center" valign="top">
<table width="100%" height="100%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td width="189" align="center" valign="top" bgcolor="#4f5a73">
<!-- ______________________________________________________________________ -->
<!-- c'est là que ça coince -->
<!-- ______________________________________________________________________ -->
<ul>
<li class="menu" onmouseover="montre('smenu1');" onmouseout="cache('smenu1');">Menu 1</li>
<ul id="smenu1" onmouseover="montre('smenu1');" onmouseout="cache('smenu1');">
<li>SousMenu 1</li>
<li>SousMenu 2</li>
<li>SousMenu 3</li>
</ul>
<li class="menu" onmouseover="montre('smenu2');" onmouseout="cache('smenu2');">Menu 2</li>
<ul id="smenu2" onmouseover="montre('smenu2');" onmouseout="cache('smenu2');">
<li>SousMenu 1</li>
<li>SousMenu 2</li>
<li>SousMenu 3</li>
</ul>
</ul>
<!-- _____________________________________________________________________________ -->
<!-- fin de c'est là que ça coince -->
<!-- _____________________________________________________________________________ -->
</td>
<td valign="top" align="center" bgcolor="#4f5a73">
TOTO
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Avec le fichier menu.xml :
--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="planche.xslt" ?>
<root>
<menu><nom>toto</nom></menu>
<menu>
<nom>titi</nom>
<sous_menu>titi 1</sous_menu>
<sous_menu>titi 2</sous_menu>
<sous_menu>titi 3</sous_menu>
</menu>
<menu>
<nom>tata</nom>
<sous_menu>tata 1</sous_menu>
<sous_menu>tata 2</sous_menu>
</menu>
</root>
J'ai écrit le fichier menu.xsl, mais ça ne marche pas :
-------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- __________________________________________________________________________________ -->
<!-- ne rien changer dans le xsl -->
<!-- __________________________________________________________________________________ -->
<script type="text/javascript">
function montre(id) {
if (document.getElementById) {
document.getElementById(id).style.display="block";
} else if (document.all) {
document.all[id].style.display="block";
} else if (document.layers) {
document.layers[id].display="block";
} }
function cache(id) {
if (document.getElementById) {
document.getElementById(id).style.display="none";
} else if (document.all) {
document.all[id].style.display="none";
} else if (document.layers) {
document.layers[id].display="none";
} }
</script>
<style type="text/css">
ul, li {
margin: 0;
padding: 0;
list-style-type: none;
font-size: 10px;
font-family: verdana, arial, sans-serif;
font-weight: normal;
}
.menu {
clear: both;
margin-top: 5px;
width: 150px;
height: 20px;
border: 1px solid #000000;
background-color: #008B8B;
text-align: center;
font-size: 12px;
font-weight: bold;
}
<xsl:for-each select="root/menu/nom">#<xsl:value-of select="."/> {
float: left;
display: none;
font-size: 8px;
padding: 5px 0 5px 0;
width: 150px;
background-color: #FF0000;
}
</xsl:for-each>
a {text-decoration: none;
color: #FFA500;
}
a:hover{text-decoration: underline;
}
</style>
<!-- __________________________________________________________________________________ -->
<!-- fin de ne rien changer dans le xsl -->
<!-- __________________________________________________________________________________ -->
</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#000000">
<tr>
<td width="100%" align="center" valign="top">
<table width="100%" height="100%" cellpadding="0" cellspacing="1" border="0">
<tr>
<td width="100" align="center" valign="top">
<!-- _________________________________________________ -->
<!-- ici commence ce qui nous intéresse et qui pose pb -->
<!-- _________________________________________________ -->
<ul>
<xsl:for-each select="root/menu">
<li class="menu">
<xsl:attribute name="onmouseover">montre(<xsl:value-of select="root/menu/nom"/>)</xsl:attribute>
<xsl:attribute name="onmouseout">cache(<xsl:value-of select="root/menu/nom"/>)</xsl:attribute>
<!-- ______________________________________________ -->
<!-- le value-of qui suit n'est pas pris en compte -->
<!-- ______________________________________________ -->
<xsl:value-of select="root/menu/nom"/>
</li>
<ul>
<xsl:attribute name="id">montre(<xsl:value-of select="root/menu/nom"/>)</xsl:attribute>
<xsl:attribute name="onmouseout">cache(<xsl:value-of select="root/menu/nom"/>)</xsl:attribute>
<xsl:for-each select="root/menu/sous_menu">
<!-- ______________________________________________ -->
<!-- le value-of qui suit n'est pas pris en compte -->
<!-- ______________________________________________ -->
<li><xsl:value-of select="root/menu/sous_menu"/></li>
</xsl:for-each>
</ul>
</xsl:for-each>
</ul>
<!-- ___________________________________________ -->
<!-- fin de : ici commence ce qui nous intéresse -->
<!-- ___________________________________________ -->
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Voilà.
Si quelqu'un peut m'aider, ce serait sympa.
Merci,
Christophe
---------------------------------
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Testez le nouveau Yahoo! Mail
--
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:06 UTC
webmaster@xmlfr.org
|