This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: How to make the user selecting a view in a XSL stylesheet from a button
- To: <xsl-list at mulberrytech dot com>
- Subject: RE: How to make the user selecting a view in a XSL stylesheet from a button
- From: "Chris Bayes" <Chris at Bayes dot co dot uk>
- Date: Fri, 11 Aug 2000 16:26:22 +0100
- Reply-To: xsl-list at mulberrytech dot com
Having played around with the Change Stylesheet Power Toy (beta testers
wanted) you might want to change
document.body.innerHTML = proc.output;
to
var newDoc = document.open("text/html", "replace");
newDoc.write(proc.output);
newDoc.close();
this avoids you putting <head>... inside the body
Ciao Chris
XML/XSL Portal
http://www.bayes.co.uk/xml
>-----Original Message-----
>From: owner-xsl-list@mulberrytech.com
>[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of Stéphane Mamdy
>Sent: 11 August 2000 16:13
>To: xsl-list@mulberrytech.com
>Subject: RE: How to make the user selecting a view in a XSL stylesheet
>from a button
>
>
>Yes. Here are the 2 files needed.
>It works with IE5 and MSXML 3.0.
>
>But it's not perfect !
>I would l like to put in the subject (GRAIN of advise) selection list only
>the advise 's subjects (= CONSEIL/SUJET)whitch exist for the selected date
>(actually, i list all the subjects without checking if the advise exists at
>that date). I don't find how to do that yet.
>
>Your remarks to improve the processing are wellcome...
>
>Maybye this files will give some ideas...
>
>Stéphane Mamdy.
>
>
>************ conseil.xml ******************
><?xml version="1.0" encoding="ISO-8859-1" ?>
><?xml:stylesheet type="text/xsl" href="liste_conseils.xsl" ?>
><LISTE_CONSEIL>
><LISTE_DATE>
><DATE_CONSEIL SELECTION="2000/08/01">01/08/2000</DATE_CONSEIL>
><DATE_CONSEIL SELECTION="2000/07/04">04/07/2000</DATE_CONSEIL>
></LISTE_DATE>
><LISTE_GRAIN>
><GRAIN>Blé tendre</GRAIN>
><GRAIN>Maïs</GRAIN>
><GRAIN>Orge de mouture</GRAIN>
><GRAIN>soja</GRAIN>
></LISTE_GRAIN>
><CONSEIL ID="123">
> <DATE>2000/08/01</DATE> <DATEC>01/08/2000</DATEC>
> <CATEGORIE>Céréales</CATEGORIE>
> <SUJET>Blé tendre</SUJET>
> <ID>Blé tendre</ID>
> <COMMENTAIRE>La récolte bat son plein avec quelques jours sans
>pluie.....</COMMENTAIRE>
></CONSEIL>
><CONSEIL ID="125">
> <DATE>2000/08/01</DATE> <DATEC>01/08/2000</DATEC>
> <CATEGORIE>Céréales</CATEGORIE>
> <SUJET>Maïs</SUJET>
> <ID>Maïs</ID>
> <COMMENTAIRE>Peut-on encore parler d'ancienne campagne, tant les
>disponibilités sont maigres. ...</COMMENTAIRE>
></CONSEIL>
><CONSEIL ID="124">
> <DATE>2000/08/01</DATE> <DATEC>01/08/2000</DATEC>
> <CATEGORIE>Céréales</CATEGORIE>
> <SUJET>Orge de mouture</SUJET>
> <ID>Orge de mouture</ID>
> <COMMENTAIRE>Petite vitesse de croisière car la demande est
>réduite....</COMMENTAIRE>
></CONSEIL>
><CONSEIL ID="81">
> <DATE>2000/07/04</DATE> <DATEC>04/07/2000</DATEC>
> <CATEGORIE>Céréale</CATEGORIE>
> <SUJET>Blé tendre</SUJET>
> <ID>Blé tendre</ID>
> <COMMENTAIRE>La situation ne s'est pas sensiblement améliorée depuis
>mardi.....</COMMENTAIRE>
></CONSEIL>
><CONSEIL ID="83">
> <DATE>2000/07/04</DATE> <DATEC>04/07/2000</DATEC>
> <CATEGORIE>Céréale</CATEGORIE>
> <SUJET>Maïs</SUJET>
> <ID>Maïs</ID>
> <COMMENTAIRE>Toujours l'article fort.....</COMMENTAIRE>
></CONSEIL>
><CONSEIL ID="82">
> <DATE>2000/07/04</DATE> <DATEC>04/07/2000</DATEC>
> <CATEGORIE>Céréale</CATEGORIE>
> <SUJET>Orge de mouture</SUJET>
> <ID>Orge de mouture</ID>
> <COMMENTAIRE>Petit courant d'affaires sur le rapproché pour quelques
>utilisateurs métropolitains.....</COMMENTAIRE>
></CONSEIL>
><CONSEIL ID="13">
> <DATE>2000/07/04</DATE> <DATEC>04/07/2000</DATEC>
> <CATEGORIE>Oléoprotéagineux</CATEGORIE>
> <SUJET>Graines de colza</SUJET>
> <ID>Graines de colza</ID>
> <COMMENTAIRE>Le retrait mesuré du dollar depuis la fin de la semaine
>dernière a calmé le marché...</COMMENTAIRE>
></CONSEIL>
></LISTE_CONSEIL>
>
>************ liste_conseils.xsl ******************
>
><?xml version="1.0" encoding="ISO-8859-1" ?>
><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="mynamespace"
>version="1.0">
><xsl:output method="html" version="4.0"/>
>
><xsl:param name="param" />
><xsl:param name="param_date" />
> <xsl:template match="/">
><HTML>
><HEAD>
> <title>Cotations des cereales</title>
> <style type="text/css">
> .SSTITRE {
> font-weight:bold;
> text-decoration:none;
> };
>
> .DATE {
> font: 8pt verdana, arial, helvetica, sans-serif; };
> .TJ {
> text-align:justify; };
> </style>
>
><SCRIPT><xsl:comment><![CDATA[
>function Selection_grain(e){
>
> var tem = new ActiveXObject("MSXML2.XSLTemplate");
> tem.stylesheet = stylesheet;
> var proc = tem.createProcessor();
>
>proc.addParameter("param",e.grain.options[e.grain.selectedIndex].value);
>
>proc.addParameter("param_date",e.date_rapport.options[e.date_rappor
>t.selecte
>dIndex].value);
> proc.input = source;
> proc.transform();
> document.body.innerHTML = proc.output;
>
>}
>function Selection_date(e) {
> var tem = new ActiveXObject("MSXML2.XSLTemplate");
> tem.stylesheet = stylesheet;
> var proc = tem.createProcessor();
>
>proc.addParameter("param",e.grain.options[e.grain.selectedIndex].value);
>
>proc.addParameter("param_date",e.date_rapport.options[e.date_rappor
>t.selecte
>dIndex].value);
> proc.input = source;
> proc.transform();
> document.body.innerHTML = proc.output;
>
>}
>]]></xsl:comment></SCRIPT>
>
><SCRIPT for="window" event="onload"><xsl:comment><![CDATA[
>
>// stylesheet=document.XSLDocument;
> stylesheet = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
> stylesheet .async = false;
> stylesheet
>.load("http://agritest:81/cotation/xsl/liste_conseils.xsl");
>
> source=document.XMLDocument;
>
>]]></xsl:comment></SCRIPT>
> </HEAD>
> <BODY>
> <CENTER>
> <H1>Conseils <xsl:value-of select="$param" /> </H1>
> <xsl:call-template name="CONSTRUCTION-FORMULAIRE" />
> <p/>
> <table>
> <xsl:choose>
> <xsl:when test="$param='' and $param_date=''">
> <xsl:call-template name="AFFICHE-DERNIER" />
> </xsl:when>
> <xsl:when test="$param=''">
> <xsl:apply-templates
>select="/LISTE_CONSEIL/CONSEIL[DATE=$param_date]" />
> </xsl:when>
> <xsl:when test="$param_date=''">
> <xsl:apply-templates
>select="/LISTE_CONSEIL/CONSEIL[SUJET=$param]" />
> </xsl:when>
> <xsl:otherwise>
> <xsl:apply-templates
>select="/LISTE_CONSEIL/CONSEIL[DATE=$param_date and
>SUJET=$param]" />
> </xsl:otherwise>
> </xsl:choose>
> </table>
>
> </CENTER>
> </BODY>
> </HTML>
> </xsl:template>
>
><xsl:template match="CONSEIL">
> <tr><td> </td><td> </td></tr>
> <tr><td><xsl:value-of select="SUJET"/></td><td align="right"><div
>class="DATE"><span class="DATE"><xsl:value-of
>select="DATE"/></span></div></td></tr>
> <tr><td> </td><td> </td></tr>
> <tr><td colspan = "2"> <div class="tj"><span
>class="tj"><xsl:value-of
>select="COMMENTAIRE"/> <br/><center><hr
>width="200"/></center></span></div></td></tr>
> <tr><td></td><td></td></tr>
></xsl:template>
>
><xsl:template name="AFFICHE-DERNIER">
><tr><td><p>Sélectionnez une date et un sujet dans la liste...</p></td></tr>
></xsl:template>
>
><xsl:template name="AFFICHE-CHOISI">
><p>CHOISI <xsl:value-of select="$param" /></p>
></xsl:template>
>
>
><xsl:template name="CONSTRUCTION-FORMULAIRE">
> <center>
> <form name="formulaire">
> <table CELLPADDING="5" CELLSPACING="0" border="1"
>bordercolor="#A8D000" >
> <tr>
> <td>
> <table CELLPADDING="0" CELLSPACING="0" width="650">
> <tr>
> <td>Selectionner une date </td>
> <td> <select name="date_rapport" id="date_rapport"
>onchange="Selection_date(document.forms[0])" >
> <option value=""></option>
> <xsl:apply-templates select="LISTE_CONSEIL/LISTE_DATE/*" >
> <xsl:sort data-type="text" order="descending"
>select="DATE" />
> </xsl:apply-templates>
> </select>
> </td>
> </tr>
> <tr>
> <td>Selectionner un sujet </td>
> <td> <select name="grain" id="grain"
>onchange="Selection_grain(document.forms[0])">
> <option value=""></option>
> <xsl:apply-templates select="LISTE_CONSEIL/LISTE_GRAIN/*" >
> <xsl:sort data-type="text" order="ascending" select="." />
> </xsl:apply-templates>
> </select></td></tr>
> <tr><td colspan="2">
><!-- <input type="button"
>onclick="Selection_grain(document.forms[0])"
>value="Selectionner" /> -->
> </td></tr>
> </table>
> </td></tr></table>
> </form>
> </center>
></xsl:template>
>
><xsl:template match="DATE_CONSEIL">
> <OPTION value="{@SELECTION}"><xsl:if test="@SELECTION =
>$param_date"><xsl:attribute
>name="SELECTED">1</xsl:attribute></xsl:if><xsl:value-of select="."
>/></OPTION>
></xsl:template>
>
><xsl:template match="GRAIN">
> <OPTION value="{.}"><xsl:if test=". = $param"><xsl:attribute
>name="SELECTED">1</xsl:attribute></xsl:if><xsl:value-of select="."
>/></OPTION>
></xsl:template>
>
>
>
></xsl:stylesheet>
>**************************************************
>
>-----Message d'origine-----
>De : owner-xsl-list@mulberrytech.com
>[mailto:owner-xsl-list@mulberrytech.com]De la part de Chris Bayes
>Envoyé : jeudi 10 août 2000 22:03
>À : xsl-list@mulberrytech.com
>Objet : RE: How to make the user selecting a view in a XSL stylesheet
>from a button
>
>
>
>>Thanks, Chris
>>It works fine !!!
>>
>>Stéphane Mamdy.
>
>Great ;-)
>Can we see the result?
>
>Ciao Chris
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list