Re: [xsl] getting combo value,not textbox value

Subject: Re: [xsl] getting combo value,not textbox value
From: himanshu padmanabhi <himanshu.padmanabhi@xxxxxxxxx>
Date: Sat, 28 Feb 2009 15:48:51 +0530
Thank you for solution again.
This is my simple HTML file generated from XSL script.(this alone can
submit the form)
-----------------------------------------------------------------------------
-------
<table border="1">
<tr>
     <td> Parameter </td>
     <td> Description </td>
     <td> Value	</td>
</tr>

<form name="form1" method="POST" action="one.cgi">
<tr>
     <td>machine name</td>
     <td>specify machine name</td>
     <td><select name="machine_name"><option></option></select></td>
</tr>

<tr>
     <td>limit</td>
      <td>specify limit which should not exceed</td>
      <td><input type="text" name="limit" value=""></td>
</tr>
</form></body></html>

<script type="text/javascript">
	document.form1.submit();
</script>
</table>
-----------------------------------------------------------------------------
--
and this is my modified XSL file which is generating above html code.
It shows table with all elements as expected.Only form.submit not working.
please help.Is there any other way of form.submit.
Should I use hidden button to submit?

<xsl:template match="Records">
    <html>
    <body>
    <form name="form1" method="POST" action="one.cgi">
    <tr>
        <td>
            <xsl:value-of select="label1"/>
        </td>
        <td>
            <xsl:value-of select="desc1"/>
        </td>
        <td>
            <xsl:if test="label1 = 'machine name'">
                <select name="machine_name">
                    <xsl:call-template name="str:tokenize">
                    </xsl:call-template>
                </select>
            </xsl:if>
        </td>
    </tr>

     <tr>
         <td>
               <xsl:value-of select="label2"/>
         </td>
         <td>
               <xsl:value-of select="desc2"/>
        </td>
        <td>
            <xsl:if test="label2 = 'limit'">
                <input type="text" name="limit" value="" />
            </xsl:if>
        </td>
    </tr>
    </form>
    </body>
    </html>
    <script type="text/javascript">
          document.form1.submit();
    </script>
</xsl:template>
-----------------------------------------------------------------------------
-

On Fri, Feb 27, 2009 at 5:26 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
>
> As has been explained, your problem is not to do with xslt, it is simply
> an error in your generated html.
>
> Your posted xsl (it would be better to post complete but small
> stylesheet rather than a fragment) if made into a working stylesheet, looks
> like this:
>
> <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>  xmlns:str="http://exslt.org/strings";
>>
>
> <xsl:import
href="http://www.exslt.org/str/functions/tokenize/str.tokenize.template.xsl";
/>
>
> <xsl:output indent="yes"/>
> <xsl:variable name="idx" select="'???'"/>
> <xsl:variable name="sidx" select="'???'"/>
> <xsl:variable name="input" select="'???'"/>
> <xsl:variable name="new" select="'???'"/>
>
>  <xsl:template match="records">
>    <table border="1">
>        <tr>
>            <td> Parameter </td>
>            <td> Description </td>
>            <td> Value </td>
>        </tr>
>        <xsl:apply-templates/>
>    </table>
> </xsl:template>
>
> <xsl:template match="one">
>    <form name="form1" method="POST" action="one.cgi">
>    <tr>
>        <td>
>            <xsl:value-of select="label"/>
>        </td>
>        <td>
>            <xsl:value-of select="desc"/>
>        </td>
>        <td>
>            <xsl:if test="label = 'machine name'">
>                    <select name="machine_name">
>                      <xsl:call-template name="str:tokenize">
>                      </xsl:call-template>
>                     </select>
>             </xsl:if>
>             <xsl:if test="label = 'limit'">
>                  <input type="text" name="limit" value="">
>                  </input>
>             </xsl:if>
>        </td>
>         <input type="hidden" name="idx" value="{$idx}"/>
>         <input type="hidden" name="sidx" value="{$sidx}"/>
>         <input type="hidden" name="new" value="{$new}" />
>    </tr>
>    </form>
>    <script>
>        document.form1.submit();
>    </script>
> </xsl:template>
>
> </xsl:stylesheet>
>
> If run on your example input it produces the html below which has two
> forms with the same name. So first you need to correct the html to
> either have one form, or two forms with different names. Once you have
> working html then you should be able to write the xslt to generate the
> required html.
>
> Don't try to debug your stylesheet by executing the generated code
> directly in a browser. Do it in two separate steps, so you can -see_ the
> output from xslt.
>
> The output from the above is:
>
> $ saxon abc.xml abc.xsl
> <?xml version="1.0" encoding="utf-8"?>
> <table xmlns:str="http://exslt.org/strings"; border="1">
>   <tr>
>      <td> Parameter </td>
>      <td> Description </td>
>      <td> Value </td>
>   </tr>
>
>   <form name="form1" method="POST" action="one.cgi">
>      <tr>
>         <td>machine name</td>
>         <td>specify machine name</td>
>         <td>
>            <select name="machine_name"/>
>         </td>
>         <input type="hidden" name="idx" value="???"/>
>         <input type="hidden" name="sidx" value="???"/>
>         <input type="hidden" name="new" value="???"/>
>      </tr>
>   </form>
>   <script>
>        document.form1.submit();
>    </script>
>
>   <form name="form1" method="POST" action="one.cgi">
>      <tr>
>         <td>limit</td>
>         <td>specify limit which should not exceed</td>
>         <td>
>            <input type="text" name="limit" value=""/>
>         </td>
>         <input type="hidden" name="idx" value="???"/>
>         <input type="hidden" name="sidx" value="???"/>
>         <input type="hidden" name="new" value="???"/>
>      </tr>
>   </form>
>   <script>
>        document.form1.submit();
>    </script>
>
> </table>
>
>
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________
>
>



--
Regards,
Himanshu Padmanabhi

Current Thread