Problem with php and xml

Tried a few forums and had no result in anyone knowing even close how to solve this issue, so really hope someone here does, else I’m at the end of hopes.

The errors are quite vague for me.
Basically:
[php][10-Feb-2012 10:15:07] PHP Warning: XSLTProcessor::transformToXml()
[xsltprocessor.transformtoxml]:
xmlXPathCompiledEval: 2 object left on the stack in /home/ansem/public_html/utils.php on line 119
[10-Feb-2012 10:15:07] PHP Warning: XSLTProcessor::transformToXml()
[xsltprocessor.transformtoxml]:
runtime error: file /home/ansem/public_html/templates/utils.xsl line 104 element variable in /home/ansem/public_html/utils.php on line 119
[/php]
( Added some enters so the page won’t stretch )

Content of the bottom part of the file:
[php] ////////////////////////
/// XSL Transformations

function Numbers($from, $to) // creates comma-separated list of all integer values from interval <$from, $to>
{
	if ($from <= $to) return implode(",", array_keys(array_fill($from, $to - $from + 1, 0)));
	else return "";
}

function array2xml(array $array)
{
	$text = "";
	foreach($array as $key => $value)
	{
		if( is_numeric($key) )
			$key = "k".$key;

		if( !is_array($value) ) 
			$text .= "<$key>".htmlencode($value)."</$key>"; 
		else
			$text .= "<$key>".array2xml($value)."</$key>";
	}
	return $text;
}

function XSLT($xslpath, array $params)
{
	// set up xslt
	$xsldoc = new DOMDocument();
	$xsldoc->load($xslpath);
	$xsl = new XSLTProcessor();
	$xsl->importStyleSheet($xsldoc);
	$xsl->registerPHPFunctions();

	// set up the params tree
	$tree = '<?xml version="1.0" encoding="UTF-8"?>'.'<params>'.array2xml($params).'</params>';

	// convert tree into xml document
	$xmldoc = new DOMDocument();
	$xmldoc->loadXML($tree, LIBXML_NOERROR);
	if( $xmldoc->hasChildNodes() == FALSE )
	{
		echo 'utils::XSLT : failed to load $params, check if there aren\'t any invalid characters in key names.'."\n\n";
		print_r($params);
		die();
	}

	// generate output
	return $xsl->transformToXML($xmldoc);
}

?>[/php]
With the second last line:
[php] // generate output
return $xsl->transformToXML($xmldoc);[/php]
being line 118 and 119

in utils.xml
[php]<func:function name=“am:datetime”>
<xsl:param name=“datetime” as=“xs:string” />
<xsl:param name=“timezone” as=“xs:string” select="’+0’" />
<xsl:variable name=“date” select=“str:replace($datetime, ’ ', ‘T’)” />
<xsl:variable name=“zone” select=“concat(‘Etc/GMT’, str:replace(str:replace(str:replace($timezone, ‘+’, ‘’), ‘-’, ‘+’), '’, ‘-’))” />
<func:result select=“php:functionString(‘ZoneTime’, $date, $zone, ‘H:i, j. M, Y’)” />
</func:function>[/php]
with
[php] <xsl:variable name=“date” select=“str:replace($datetime, ’ ', ‘T’)” />[/php]
being line 104

So what is going wrong ?
And could anyone help me fix it.
( Maybe a little explanation so I won’t make the same mistake next time :wink: )

Bump

Sponsor our Newsletter | Privacy Policy | Terms of Service