[PHP] Re: Applying XSL to XML with PHP

2002-07-25 Thread Peter Clarke

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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] RE: Applying XSL to XML with PHP

2002-07-25 Thread ctan

The XML would be something like this... 

?xml version=1.0 encoding=UTF-8?

ARG
  SCHEMESET
SCHEME
  NAMEArgument from Position to Know/NAME
  FORM
PREMISEa is in a position to know whether A is true/PREMISE
PREMISEa asserts that A is true/PREMISE
CONCLUSIONA is true/CONCLUSION
  /FORM
  CQIs a in a position to know whether A is true?/CQ
  CQIs a an honest (trustworthy, reliable) source?/CQ
  CQDid a actually assert that A is true?/CQ
/SCHEME
  /SCHEMESET

 !-- The Text of the AML--
  TEXTIf 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=367we are likely to suffer higher
casualties/PROPTEXT
/PROP
REFUTATION
  AU
PROP identifier=A missing=no
  PROPTEXT offset=468we are not likely to suffer higher
casualties/PROPTEXT
/PROP
  /AU
/REFUTATION
CA
  AU
PROP identifier=D missing=no
  PROPTEXT offset=304the enemy will be prepared/PROPTEXT
/PROP
CA
  AU
PROP identifier=F missing=no
  PROPTEXT offset=202our troops will not have the advantage
of surprise/PROPTEXT
/PROP
CA
  AU
PROP identifier=G missing=no
  PROPTEXT offset=171invasion is not a secret/PROPTEXT
/PROP
LA
  AU
PROP identifier=I missing=no
  PROPTEXT offset=0If 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=93the newspapers print the
news/PROPTEXT
/PROP
  /AU
/LA
  /AU
/CA
  /AU
/CA
  /AU
/CA
  /AU
/ARG


Hope this helps...

chia

-Original Message-
From: Peter Clarke [mailto:[EMAIL PROTECTED]] 
Sent: 25 July 2002 13:06
To: Ctan
Cc: [EMAIL PROTECTED]
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



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Applying XSL to XML with PHP

2002-07-25 Thread Peter Clarke


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:[EMAIL PROTECTED]] 
 Sent: 25 July 2002 13:06
 To: Ctan
 Cc: [EMAIL PROTECTED]
 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
 
 
 
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php