Forum Moderators: coopster

Message Too Old, No Replies

XSLTProcessor not closing some tags

XSLTProcessor,

         

eltreno

6:28 pm on Feb 8, 2008 (gmt 0)

10+ Year Member



HI

I have an issue with parsing xml to html using the code below that the <img> and <br> tags are not closed.

I have found a few different opinions regarding php bugs etc but cannot fin a resolve

PHP example code
$xml2 = new DOMDocument;
if ($xml2->loadXML('<?xml version="1.0" encoding="iso-8859-1"?' .'>' .$XML_content)){

$xsl = new DOMDocument;
$xsl->load(xsl("article_publish.xsl"));

// Configure the transform
$proc = new XSLTProcessor;
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsl); // attach the xsl rules

$finalContentRightNav = htmlspecialchars_decode($proc->transformToXML($xml2));

XSLT header code
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php">
<xsl:output method="html" encoding="ISO-8859-1" indent="no"/>
<xsl:namespace-alias stylesheet-prefix="php" result-prefix="xsl" />

Is there a way to make the tags close properly when pringed to html? Or os it a php version problem. I'm using PHP 5.2.0-8

Or do I need a regex to add the end tag in after processing :(

NOTE: I am calling some php functions and I have tried <xsl:output method="xml", which causes grief re javascript and some html layouts etc etc

It's killing my validation instantly, and me slowly!

Thanks
Trent

[edited by: eelixduppy at 7:08 pm (utc) on Feb. 8, 2008]
[edit reason] disabled smileys [/edit]

eltreno

11:32 am on Feb 14, 2008 (gmt 0)

10+ Year Member



Small bump,nudge,cry

coopster

3:49 pm on Feb 16, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



There were a lot of bug fixes, Trent. My advice would be to load a current version of PHP5 (5.2.5) and see if your issue still exists.

eltreno

10:34 am on Feb 18, 2008 (gmt 0)

10+ Year Member



Thanks Coopster,

I found a solution which seem to work fine for me incase some one is looking for a solution.

original code
// Configure the transform
$proc = new XSLTProcessor;
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsl);
$finalContentHTML = $proc->transformToXML($xml);

New code
// Configure the transform
$proc = new XSLTProcessor;
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsl);
$finalContentHTML_Doc = $proc->transformToDoc($xml);
$finalContentHTML = $finalContentHTML_Doc->saveXML();

Cheers