Please help. I'm a newbie and I'm drastically stuck. [icon_sad.gif]
I have a database which stores data in xml format but I want to parse it with xslt to produce the format I want. The problem is I have followed everything on php.net to the letter and yet still I'm nowhere. Please take a look at the code below and tell me where I've gone wrong. (Details worth mentioning is that I'm working with PHP to design a website which will be driven by this database. The database is done in MySQL)
Code:
if (! empty($searchword ))
$query = "SELECT aml FROM arguments WHERE aml LIKE '%$searchword%'";
$result = mysql_query($query)
or die ("Query failed");
$line = mysql_fetch_array($result, MYSQL_ASSOC);
// var_dump($line);
// Create an array
$arguments = array( 'xml' => $line);
// Checking if array works
if ( is_array($arguments) )
print "It's an array! ";
// Show contents of an array
print_r ($arguments);
// Create an XSLT processor
$xsltHandler = xslt_create();
// Perform the transformation
$html = xslt_process($xsltHandler, 'arg:xml' , 'sheet1.xsl', NULL, $arguments);
// Detect errors
if (!$html) die ('XSLT processing error: '.xslt_error($xsltHandler));
// Destroy the XSLT processor
xslt_free($xsltHandler);
// Output the resulting HTML
print $html;
The screen returns:
"Warning: Sablotron error on line 1: XML parser error 2: syntex error in /home/httpd/html/ctan/resultworkingcopy2.php on line 88
XSLT processing error: XML parser error 3: syntex error "
WHAT GIVES?
I'm hopelessly lost and would greatly appreciate it if a kind soul would help me out! Cheers and thanks in advance!
Regards,
Chia
PS: Oh yeah... other details are the XML and XSL files.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!--<xsl:template match="ARG">
<body>
<xsl:apply-templates/>
</body>
</xsl:template>
-->
<!-- This is the title of the page -->
<xsl:template match="CQ">
<b><u>
<xsl:value-of select="."/>
</u></b>
</xsl:template>
<xsl:template match="PROP">
<p/><b>
<xsl:value-of select="."/>
</b><br/>
</xsl:template>
</xsl:stylesheet>
That's the xsl stylesheet....
This is what the xml document would look like from the MySQL database:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<ARG>
<SCHEMESET>
<SCHEME>
<NAME>Argument from Position to Know</NAME>
<FORM>
<PREMISE>a is in a position to know whether A is true</PREMISE>
<PREMISE>a asserts that A is true</PREMISE>
<CONCLUSION>A is true</CONCLUSION>
</FORM>
<CQ>Is a in a position to know whether A is true?</CQ>
<CQ>Is a an honest (trustworthy, reliable) source?</CQ>
<CQ>Did a actually assert that A is true?</CQ>
</SCHEME>
</SCHEMESET>
<!-- The Text of the AML-->
<TEXT>If any journalists learn about the invasion, then the newspapers will print the news. And if the newspapers print the news, then the invasion will not be a secret. If the invasion is not a secret, then our troops will not have the advantage of surprise. If we do not have the advantage of surprise, then the enemy will be prepared. And if the enemy is prepared, then we are likely to suffer higher casualties. But no journalists learned about the invasion. Therefore, we are not likely to suffer higher casualties.</TEXT>
<!-- The components of the argument-->
<AU>
<PROP identifier="C" missing="no">
<PROPTEXT offset="367">we are likely to suffer higher casualties</PROPTEXT>
</PROP>
<REFUTATION>
<AU>
<PROP identifier="A" missing="no">
<PROPTEXT offset="468">we are not likely to suffer higher casualties</PROPTEXT>
</PROP>
</AU>
</REFUTATION>
<CA>
<AU>
<PROP identifier="D" missing="no">
<PROPTEXT offset="304">the enemy will be prepared</PROPTEXT>
</PROP>
<CA>
<AU>
<PROP identifier="F" missing="no">
<PROPTEXT offset="202">our troops will not have the advantage of surprise</PROPTEXT>
</PROP>
<CA>
<AU>
<PROP identifier="G" missing="no">
<PROPTEXT offset="171">invasion is not a secret</PROPTEXT>
</PROP>
<LA>
<AU>
<PROP identifier="I" missing="no">
<PROPTEXT offset="0">If any journalists learn about the invasion</PROPTEXT>
</PROP>
<REFUTATION>
<AU>
<PROP identifier="B" missing="no">
<PROPTEXT offset="413"> no journalists learned about the invasion</PROPTEXT>
</PROP>
</AU>
</REFUTATION>
</AU>
<AU>
<PROP identifier="H" missing="no">
<PROPTEXT offset="93">the newspapers print the news</PROPTEXT>
</PROP>
</AU>
</LA>
</AU>
</CA>
</AU>
</CA>
</AU>
</CA>
</AU>
</ARG>
Thanks again for your time and help!