Re: [xsl] url query works with mozilla; not IE

Subject: Re: [xsl] url query works with mozilla; not IE
From: "William S." <wstan@xxxxxxxxx>
Date: Fri, 4 Jul 2003 16:34:58 +0200
On Fri, Jul 04, 2003 at 11:32:20AM +0100, Jim Fuller wrote:
> I am certain that we can get something working for you, if u give us a complete example.
> 
Here is a scaled down version of what I am doing.
My original problem was that the "url query" does
_not_ work with Internet Explorer (6.0) but is
OK with Mozilla 1.4. Part of the url is cut off.
The failure is in the "second page".
I am using Sablotron and have GD compiled in as well.
Hope I did not post too much here but am unsure
which detail might be significant.

****BEGINNING OF FIRST PAGE CONTENT
---begin "first.php"
<?php
$xml = "./first.xml";
$xsl = "./first.xsl";
ob_start();

$_parser = xslt_create();

if( !$result = @xslt_process(  $_parser,    // resource xh
                               $xml,        // string xsl
                               $xsl,
                               NULL,
                               array()
                             ) ) {
    printf( "Sablotron Error (%s): <br /><strong>%s</strong>",
            xslt_errno($_parser), xslt_error($_parser) );
}
ob_end_clean();
xslt_free($_parser);
echo $result;
?>
---end "first.php"
---begin "first.xsl"
<?xml version='1.0' encoding='iso-8859-1' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="/">
<html><head>
<title>FIRST</title>
</head>
<body>
<xsl:apply-templates select="data1" />
</body></html>
</xsl:template>

<xsl:template match="data1">
<xsl:for-each select="record">

<xsl:value-of select="desc"/>

<form action="second.php" method="POST">
<input>
<xsl:attribute name="type">image</xsl:attribute>
<xsl:attribute name="name">myvar</xsl:attribute>
<xsl:attribute name="src">first-gd.php?item1=<xsl:value-of select="insert"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="insert"/></xsl:attribute>
<xsl:attribute name="alt">bar</xsl:attribute>
</input>
</form>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
---end "first.xsl"
---begin "first.xml"
<?xml version='1.0' encoding='ISO-8859-1'?>
<data1>
<record>
<desc>foo</desc>
<insert>hello.png</insert>
</record>
</data1>
---end "first.xml"
---begin "first-gd.php
<?php
$image = $_GET['item1'];
$src_img = ImageCreateFrompng($image);
$dst_img = ImageCreatetruecolor("50", "50");
ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, 50, 50, 330, 274);
header("Content-type: image/png");
imagePNG($dst_img);
ImageDestroy ($src_img);
ImageDestroy ($dst_img);
?>
---end "first-gd.php
****END OF FIRST PAGE CONTENT
****BEGINNING OF SECOND PAGE CONTENT
---begin "second.php"
<?php
$myvar = $_POST['myvar'];
$xml = "./second.xml";
$xsl = "./second.xsl";
$parameters = array(
	myvar => $myvar
);
$parameters['myvar'] = iconv("ISO-8859-1","UTF-8",$myvar);
ob_start();

$_parser = xslt_create();

if( !$result = @xslt_process(  $_parser,    // resource xh
                               $xml,        // string xsl
                               $xsl,
                               NULL,
                               array(),
			       $parameters
                             ) ) {
    printf( "Sablotron Error (%s): <br /><strong>%s</strong>",
            xslt_errno($_parser), xslt_error($_parser) );
}
ob_end_clean();
xslt_free($_parser);
echo $result;
?>
---end "second.php"
---begin "second.xsl"
<?xml version='1.0' encoding='iso-8859-1' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:param name="myvar" select="/.."/>

<xsl:template match="/">
<html><head>
<title>SECOND</title>
</head>
<body>
<xsl:apply-templates select="data2" />
</body></html>
</xsl:template>

<xsl:template match="data2">
<xsl:for-each select="record">

<xsl:value-of select="desc"/><br/>
<img text="foo" alt="foo" src="second-gd.php?item2={$myvar}"></img>
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>
---end "second.xsl"
---begin "second.xml"
<?xml version='1.0' encoding='ISO-8859-1'?>
<data2>
<record>
<desc>bar</desc>
</record>
</data2>
---end "second.xml"
---begin "second-gd.php"
<?php
$id = $_GET['item2'];
$image = imagecreatefrompng($id);
$yellow = imagecolorallocate($image, 200,200,0);
imagestring($image, 4, 10, 10, "Hello World", $yellow);
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
?>
---end "second-gd.php"
****END OF SECOND PAGE CONTENT
-- 
Bill
Amsterdam, NL

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread