I've got a problem with a xsl output (see former xsl thread) resulting in php code (inserted via <xsl:processing-instruction>) printed out to the page and not parsed.
Right now I have a workaround for that, but I consider it rather, er, crude
Expand|Select|Wrap|Line Numbers
- <!-- previous html code from the site script -->
- <?php
- // $inhalt as instance of a custom class defined elsewhere
- if ($text = $inhalt->DataInhalt()) { // apply only if content comes from the xslt processing
- $suche = '@<\?php([^\?]+)\?>@'; // get the PIs
- preg_match_all($suche, $text, $treffer, PREG_OFFSET_CAPTURE);
- $start = 0;
- foreach ($treffer[0] as $key => $val) {
- echo substr($text, $start, $val[1]-$start); // split the text and print it
- $start = $val[1] + strlen($val[0]);
- eval(trim($treffer[1][$key][0])); // process the php code
- }
- echo substr($text, $start);
- }
- ?>
- <!-- further html code -->
I would have used something like preg_replace_callback() but callback functions can't use eval().
Unfortunately I'm not able to do the processing in the class itself, because the object that is to be processed in the xsl code produces an error (respectively a script exit) when called inside the outer class...
I've even tried to set the xsl result mime type to text/php but no response from the parser.
Any ideas to clean that code up are highly appreciated
Thanks in advance, Dormilich
(involved files are shown in the above mentioned thead)