himanshu.padmanabhi has asked for the wisdom of the Perl Monks concerning the following question:

abc.cgi my $parser = XML::LibXML->new(); my $xslt = XML::LibXSLT->new(); my $source = $parser->parse_file("abc.xml"); my $style_doc = $parser->parse_file("abc.xsl"); my $stylesheet = $xslt->parse_stylesheet($style_doc); my $results = $stylesheet->transform($source, args => "' '",val => "'2 +'"); print $stylesheet->output_string($results);
abc.xml <?xml version='1.0'?> <?xml-stylesheet href="abc.xsl" type="text/xsl"?> <tracks> <abc> <label>machine name</label> <desc>specify machine name</desc> </abc> </tracks>
abc.xsl <xsl:template match="tracks"> <form name="form1" method="POST" action="logic.cgi"> <table border="1"> <tr> <td> Parameter </td> <td> Description </td> <td> Value </td> </tr> <xsl:apply-templates/> </table> </form> <script> document.form1.submit(); </script> </xsl:template> <xsl:template match="abc"> <tr> <td> <xsl:value-of select="label"/> </td> <td> <xsl:value-of select="desc"/> </td> <td> <xsl:if test="label = 'machine name'"> <input type="text" name="args1" value=""> </input> </xsl:if> </td> </tr> </xsl:template> </xsl:stylesheet>
abc.cgi works as stated here. But if I take it under my form
print "<form action=someform.cgi method=post name=somename>"; abc.cgi code print "</form>";
then it I get my form elements printed from XSL file,but form1.submit from it doesn't work. Please help.Since this is combination of XML,XSL,CGI,I am unware which forum should i try.

Replies are listed 'Best First'.
Re: code under "form" not working
by frieduck (Hermit) on Mar 05, 2009 at 15:53 UTC
    It looks to me like your alphabet soup combination will result in "form1" being nested inside another form ("somename"). According to the HTML spec, this is forbidden.
Re: code under "form" not working
by dHarry (Abbot) on Mar 05, 2009 at 16:03 UTC

    When I open the xml file in Firefox I get a:

    XML Parsing Error: prefix not bound to a namespace Location: file:///home/hmetselaar/tmp/abc.xsl Line Number 1, Column 1:<xsl:template match="tracks"> ^

    After adding the following element to the stylesheet:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    I get the following output:

    Parameter Description Value machine name specify machine name document +.form1.submit();

    Probably not what you intended;-) I think the stylesheet needs a little work. I strongly advice to use a XSLT debugger. Under Windows XMLSpy is good/the best, a good multi-platform alternative is oXygen.