RE: Applying XSL to XML with PHP
| From: | ctan | Date: | Fri, 26 Jul 2002 10:42:15 +0000 |
| Subject: | RE: Applying XSL to XML with PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-109698@lists.php.net to get a copy of this message | ||
Still no good sir. New problem... But I do realised what you mean and now
the $xml is now a string before going into the $arguments. When executing
script, PHP returns:
Warning: Sablotron error on line 2: 'arg:/argument.dtd' not found in
/home/httpd/html/ctan/resultworkingcopy2.php on line 91
XSLT processing error: 'arg:/argument.dtd' not found
Refering to the xslt_process line. What does this mean?
Chia
-----Original Message-----
From: Peter Clarke [mailto:peter@jingo.com]
Sent: 25 July 2002 16:47
To: ctan
Cc: php-general@lists.php.net
Subject: Re: Applying XSL to XML with PHP
ctan wrote:
> The XML would be something like this...
>
> <?xml version="1.0" encoding="UTF-8"?>
<snip xml>
Just noticed something...
$line = mysql_fetch_array($result, MYSQL_ASSOC);
returns an array. Your $arguments array wants a string.
So..
$xml = join($line, '');
$arguments = array('/_xml'=> $xml);
Peter
>
> Hope this helps...
>
> chia
>
> -----Original Message-----
> From: Peter Clarke [mailto:peter@jingo.com]
> Sent: 25 July 2002 13:06
> To: Ctan
> Cc: php-general@lists.php.net
> Subject: Re: Applying XSL to XML with PHP
>
>
> Ctan wrote:
>
>>I'm trying to apply XSL to XML stored in a MySQL database with PHP.
>>How do I go about doing this? I've tried following the example on
>>php.net but I seem to run into a lot of trouble. Here's how the code
>>looks like (BTW aml is XML stored in the argument Table):
>>
>>
>>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);
>>
>>// Create an array
>>$arguments = array('/_xml'=> $line);
>>
>>//XSL file
>>$xsl = "./sheet1.xsl";
>>
>>// Create an XSLT processor
>>$xslthandler = xslt_create();
>>
>>// Perform the transformation
>>$html = xslt_process( $xslthandler, 'arg:/_xml', $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;
>>
>>
>>What I get on the screen is:
>>
>>
>>Array ( [0] => "With the contents of my variable...")
>>
>>
>>And:
>>
>>
>>Warning: Sablotron error on line 1: XML parser error 2: syntax error
>>in /home/httpd/html/ctan/resultworkingcopy2.php on line 93 XSLT
>>processing
>>error: XML parser error 2: syntax error
>>
>>
>>What gives? I really need to solve this urgent. Thanks...
>>
>>Chia
>
>
> What is the xml. There may be a content encoding problem or some other
> xml issue.
>
> Peter
>
>
>
>