Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML parser error 4: not well-formed (invalid token)

Status
Not open for further replies.

hame22

Programmer
Apr 25, 2005
9
GB
Hi all

I am try to perform an xsl transform in php

I have a php page that produces the xml data:

<?php

header("content-type: text/xml");


//$prod_id = $_GET['product_id'];

mysql_connect('localhost', 'fenman_act_user', 'mfx671zdv');

mysql_select_db('fenman_act_db') or exit("cannot connect");

$result = mysql_query("Select * from activities where product_id = 'DTL01'");




$row = mysql_fetch_array($result);

$title = $row['title'];
$description = $row['long_desc'];
$keyword = $row['keywords'];




print "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
//print "<?xml-stylesheet type=\"text/xsl\" href=\"xml2.xsl\"


print "<Lom
xmlns:ims_lom=\" xmlns:xsi=\"
>\r\n";

print "\t<general>\r\n";

print '<title>'.$title.' </title>';
print '<description>'.$description.'</description>';


print "\t</general>\r\n";

print "<lifecycle>
<version>version</version>
<source>source</source>
</lifecycle>

<metametadata>
<metadatascheme>metadatascheme</metadatascheme>
</metametadata>

<technical>
<format>format</format>
<location link=\"location\">location</location>
</technical>

<rights>
<copyrightandotherrestrictions>
<value>copyr_value</value>
</copyrightandotherrestrictions>
</rights>


<classification>
<purpose>
<value>class_value</value>
</purpose>
</classification>";






print "</Lom>";

?>


and an xsl style sheet:

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"
xmlns:xsl="<xsl:eek:utput method="html"/>
<xsl:template match="/">
<html>
<head><title>test</title></head>
<body>
<h2>Activity</h2>

<xsl:for-each select ="Lom/general">
<h3> Activity Name: <p><B> <xsl:value-of select="title"/></B></p></h3>
</xsl:for-each>


<xsl:for-each select="Lom/technical">

<p>Activity format: <xsl:value-of select="format"/></p>
</xsl:for-each>
<xsl:for-each select="Lom/technical/location">
<a href="{@link}">



<p>Click to access</p>
</a>

</xsl:for-each>





</body>
</html>
</xsl:template></xsl:stylesheet>

and a PHP pae that performs the transform:

<?

// Xml and XSL files
$xml_file = "test.php";
$xsl_file = "xml2.xsl";

// Allocate a new XSLT processor
$xh = xslt_create();
$fileBase = 'file://' . getcwd () . '/';
xslt_set_base ( $xh, $fileBase );

// Process the document
$result = xslt_process($xh, $xml_file, $xsl_file);
if (!$result) {
// Something croaked. Show the error
echo 'XSLT processing error: ' .xslt_error($xh) ;
}
else {
// Output the resulting HTML
echo $result;
}

// Destroy the XSLT processor
xslt_free($xh);

?>

However i get the following error;

Warning: Sablotron error on line 26: XML parser error 4: not well-formed (invalid token)

i dont understand where the problems lies, is it because my xml is in a php file??

thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top