...

View Full Version : Processing XSLT with PHP Problem



jneugass@godadd
06-10-2004, 11:16 PM
From what I understand, browsers sometimes display extra space between table rows if there is a newline after a </td> tag. It seems that this should fix the problem:

<xsl:output method="html" encoding="ISO-8859-1" indent="no" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>

but when I view source, my code is still being indented. I think the problem must be in the way the php must be processing the template.

Here is my processing code:

$xsl_file = $config[ 'PATH_TEMPLATE' ]."/$file";
$arguments = array(
'/_xml' => $xml,
);
$xh = xslt_create();
$result = xslt_process($xh, 'arg:/_xml', $xsl_file, NULL, $arguments);
if ($result) {
print $result;

}
else {
print "Sorry, sample.xml could not be transformed by sample.xsl into";
print " the \$result variable the reason is that " . xslt_error($xh) .
print " and the error code is " . xslt_errno($xh);
}
xslt_free($xh);

Anyone have any ideas?

carl_mcdade
06-11-2004, 02:06 PM
When you look at your source how are you doing it? I believe that IE an maybe mozilla have have auto formatting of XML. Does the source look the same if you save the output to a text file and view it with notepad?

jneugass@godadd
06-15-2004, 10:58 PM
The output does look the same either way. Ack...this is driving me nuts.

carl_mcdade
06-15-2004, 11:04 PM
I do a lot of text file manipulation. There are some PHP functions that add a \n or &nbsp;\n to the end of a line when reading files. Try using trim() on all your strings going in and coming out.

jneugass@godadd
06-15-2004, 11:20 PM
Got it working...

This did the trick:

$result = xslt_process($xh, 'arg:/_xml', $xsl_file, NULL, $arguments);
if ($result) {
$result = preg_replace( "/>\s*</", "><", $result );
echo ( $result );
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum