XSLT transformation of dynamic xml by php
Posted: Wed Jul 20, 2005 10:19 am
Hi I have an xsl file and a php file that dynamicaly produces XML page from a mysq database.
I now need another php page to perform the transformations of these pages.
The code I have at present thows up the following errors
\r\n"; //print "\r\n"; print "\t\r\n"; print ''; print ''.$description.''; print "\t\r\n"; print " version source metadatascheme format location copyr_value class_value "; print ""; ?>
Warning: Sablotron error on line 26: XML parser error 4: not well-formed (invalid token) in /usr/local/home/httpd/vhtdocs/fenman/web/activities/dev/keywords/dynamic.php on line 20
My code is as follows
php file to produce xml:
xsl file:
and the php code to transform
this problem has been bugging me for days, can perform the transformation within the one file but I want to use 3 seperate files.
Could any one help!??
thanks in advance
alex
I now need another php page to perform the transformations of these pages.
The code I have at present thows up the following errors
\r\n"; //print "\r\n"; print "\t\r\n"; print ''; print ''.$description.''; print "\t\r\n"; print " version source metadatascheme format location copyr_value class_value "; print ""; ?>
Warning: Sablotron error on line 26: XML parser error 4: not well-formed (invalid token) in /usr/local/home/httpd/vhtdocs/fenman/web/activities/dev/keywords/dynamic.php on line 20
My code is as follows
php file to produce xml:
Code: Select all
<?php
header("e;content-type: text/xml"e;);
//$prod_id = $_GETї'product_id'];
mysql_connect('localhost', 'fenman_act_user', 'mfx671zdv');
mysql_select_db('fenman_act_db') or exit("e;cannot connect"e;);
$result = mysql_query("e;Select * from activities where product_id = 'DTL01'"e;);
$row = mysql_fetch_array($result);
$title = $rowї'title'];
$description = $rowї'long_desc'];
$keyword = $rowї'keywords'];
print "e;<?xml version=\"e;1.0\"e; encoding=\"e;UTF-8\"e; ?>\r\n"e;;
//print "e;<?xml-stylesheet type=\"e;text/xsl\"e; href=\"e;xml2.xsl\"e;
print "e;<Lom
xmlns:ims_lom=\"e;http://www.imsglobal.org/xsd/imsmd_v1p2\"e;
xmlns:xsi=\"e;http://www.w3.org/2001/XMLSchema-instance\"e;
>\r\n"e;;
print "e;\t<general>\r\n"e;;
print '<title>'.$title.' </title>';
print '<description>'.$description.'</description>';
print "e;\t</general>\r\n"e;;
print "e;<lifecycle>
<version>version</version>
<source>source</source>
</lifecycle>
<metametadata>
<metadatascheme>metadatascheme</metadatascheme>
</metametadata>
<technical>
<format>format</format>
<location link=\"e;location\"e;>location</location>
</technical>
<rights>
<copyrightandotherrestrictions>
<value>copyr_value</value>
</copyrightandotherrestrictions>
</rights>
<classification>
<purpose>
<value>class_value</value>
</purpose>
</classification>"e;;
print "e;</Lom>"e;;
?>Code: Select all
<?xml version="e;1.0"e; encoding="e;ISO-8859-1"e;?><xsl:stylesheet version="e;1.0"e;
xmlns:xsl="e;http://www.w3.org/1999/XSL/Transform"e;>
<xsl:output method="e;html"e;/>
<xsl:template match="e;/"e;>
<html>
<head><title>test</title></head>
<body>
<h2>Activity</h2>
<xsl:for-each select ="e;Lom/general"e;>
<h3> Activity Name: <p><B> <xsl:value-of select="e;title"e;/></B></p></h3>
</xsl:for-each>
<xsl:for-each select="e;Lom/technical"e;>
<p>Activity format: <xsl:value-of select="e;format"e;/></p>
</xsl:for-each>
<xsl:for-each select="e;Lom/technical/location"e;>
<a href="e;{@link}"e;>
<p>Click to access</p>
</a>
</xsl:for-each>
</body>
</html>
</xsl:template></xsl:stylesheet>and the php code to transform
Code: Select all
<?php
// Gonna contain PHP-XML output
$xh = xslt_create();
// Read plain PHP-XML output
$xmlData = fopen ('test.php', "e;r"e;);
// Stack up output into one String
while ($line = fgets ($xmlData))
$xml .= $line;
print $xml;
$arguments = array(
'/_xml' => $xml,
);
// Process the document
$result = xslt_process($xh, 'arg:/_xml', 'xml2.xsl', NULL, $arguments);
// Print out your transformed document
echo $result;
xslt_free($xh);
?>this problem has been bugging me for days, can perform the transformation within the one file but I want to use 3 seperate files.
Could any one help!??
thanks in advance
alex