XML Hell
Posted: Thu Apr 01, 2004 2:39 am
Hi im trying to use xslt in PHP to pass a xml doc and output a html page, and i had it working for about 30 secs now i only get the same error message for hours on end no matter what i do. the error is (69: Unknown encoding '') so i have an html form with a file select box and a submit button method="post", enctype="multipart/form-data". then i perform the transform like so in php
And i know the xsl doc works but here it is anyway:
Admin Edit: added tags around the XSLT.[/size][/color]
So is it this or is it my xml doc encoding or what, ive looked around and alot of people have this problem but sort it out through the config of php, which i have no option in as its a uni server.
Thanks for any help
James Baker
Code: Select all
<?php
function transformxml ($sourcexml, $sourcexsl)
{
$sourcexml = 'file://' . $sourcexml;
$sourcexsl = 'file://' . $sourcexsl;
$xslt = xslt_create();
//process the document
if(!$result = @xslt_process($xslt, $sourcexml, $sourcexsl))
{
print ("Error: " . xslt_error($xslt) . " Error Num: " . xslt_errno($xslt));
die();
}
xslt_free($xslt);
return $result;
}
//get source file locations
$sourcexsl = $_POST["delnotexsl"];
$sourcexml = $_POST["delnotexml"];
//delnotexml is the post name of the file and delnotexsl is a hidden
//field with the location of my xsl doc
print (transformxml($sourcexml, $sourcexsl));
?>Admin Edit: added
Code: Select all
Code: Select all
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<body>
<h3>Please select a dvd to add to the database</h3>
<table>
<tr> <th>Title</th><th>Duration</th><th>Release Date</th><th>Price</th><th>Quan.</th></tr>
<xsl:for-each select="//DVD">
<tr>
<form action="insertfromxml.php" method="post">
<xsl:apply-templates select="DVD_TITLE"/>
<xsl:apply-templates select="DVD_DURATION"/>
<xsl:apply-templates select="DVD_RELEASE_DATE"/>
<xsl:apply-templates select="DVD_PRICE"/>
<xsl:apply-templates select="QUANTITY"/>
<td> <input type="submit" value="Insert This DVD" /></td>
</form>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="DVD_TITLE">
<td>
<input type="text" size="30" name="txtTITLE">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
<xsl:template match="DVD_DURATION">
<td>
<input type="text" size="5" name="txtDURATION">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
<xsl:template match="DVD_RELEASE_DATE">
<td>
<input type="text" size="15" name="txtRELEASE">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
<xsl:template match="DVD_PRICE">
<td>
<input type="text" size="6" name="txtPRICE">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
<xsl:template match="QUANTITY">
<td>
<input type="text" size="4" name="txtQUANTITY">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
</xsl:stylesheet>Thanks for any help
James Baker