hholzgra Thu Jan 17 08:07:49 2002 EDT
Modified files:
/phpdoc/scripts/apply func2methodsyn.php
Log:
create xslt processor only once
return output only if changes were applied
pass xml header to xslt processor
Index: phpdoc/scripts/apply/func2methodsyn.php
diff -u phpdoc/scripts/apply/func2methodsyn.php:1.1
phpdoc/scripts/apply/func2methodsyn.php:1.2
--- phpdoc/scripts/apply/func2methodsyn.php:1.1 Thu Jan 17 05:15:35 2002
+++ phpdoc/scripts/apply/func2methodsyn.php Thu Jan 17 08:07:46 2002
@@ -91,16 +91,17 @@
</xsl:stylesheet>
';
+$xslt_processor = false;
+
function apply($input) {
- global $conversion_xsl;
+ global $conversion_xsl, $xslt_processor;
$output="";
+ $flag=false;
if(!function_exists("xslt_create")) {
die("this conversion requires a PHP executable with XSLT extension");
}
- $xslt = xslt_create();
-
$xmlhead="<?xml version='1.0' encoding='iso-8859-1' ?>\n";
$lines = explode("\n",$input);
@@ -108,7 +109,8 @@
$line = $lines[$nr]."\n";
if(strstr($line,("<funcsynopsis>"))) {
- $funcsyn = str_replace("&","&",$line);
+ $flag=true;
+ $funcsyn = $xmlhead."\n".str_replace("&","&",$line);
do {
$line=$lines[++$nr]."\n";;
$funcsyn .= str_replace("&","&",$line);
@@ -116,22 +118,30 @@
$arguments = array('/_xml' => $funcsyn,
'/_xsl' => $conversion_xsl
);
- $result = xslt_process($xslt, 'arg:/_xml', 'arg:/_xsl', NULL,
$arguments);
- $result = str_replace("&","&",$result);
- $result = explode("\n",$result);
- unset($result[0]);
- $output .= rtrim(join("\n",$result))."\n";
+ if(!is_resource($xslt_processor)) {
+ $xslt_processor = xslt_create();
+ }
+ $result = xslt_process($xslt_processor, 'arg:/_xml',
+'arg:/_xsl', NULL, $arguments);
+
+ if(is_string($result)) {
+ $result = str_replace("&","&",$result);
+ $result = explode("\n",$result);
+ unset($result[0]);
+ $output .= rtrim(join("\n",$result))."\n";
+ } else {
+ echo "line $nr\n";
+ echo $funcsyn;
+ return fasle;
+ }
} else if (strstr($line,("<?xml"))&&($nr==1)) {
$xmlhead=$line;
$output .= $line;
- } else{
+ } else {
$output .= $line;
}
}
- xslt_free($xslt);
-
- return $output;
+ return $flag ? $output : false;
}
?>