Topic: Successfully including php output in xsl stylesheet (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=25380" title="Pages that link to Topic: Successfully including php output in xsl stylesheet (Page 1 of 1)" rel="nofollow" >Topic: Successfully including php output in xsl stylesheet <span class="small">(Page 1 of 1)</span>\

 
mberning
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Mar 2005

posted posted 03-31-2005 16:18

Hi all. I've been working on the problem in the subject for several days and haven't been able to google an answer to save my life. Here's the situation.

I'm generating standard html webpages from xml using xslt. My university has a php script that generates and returns html for news blurbs to be inserted into pages. My department would like to insert these news items into their pages. I've tried to call the news script directly using xsl:value-of and the document() function. When doing this I get warning about malformed data after the head node, and the page is rendered without the news items. I've also tried to enclose the xsl:value-of inside xsl:text but I get the error that xsl:value-of isn't allowed to appear in this section. Inserting the news items via xsl isn't a requirement, at this point i'm looking for anything that will get the job done. Any help would be greatly appreciated.

Thanks
mb

Nathus
Bipolar (III) Inmate

From: Minnesota
Insane since: Aug 2003

posted posted 03-31-2005 17:19

you can try the xsl:processing-instruction element. set the attribute name="php" in it.

code:
<xsl:processing-instruction name="php">
include "document.php";
</xsl:processing-instruction>



If you have the output mode set to html, you will possibly need to put a ? before the </xsl:processing-instruction> depending on the method you are using to transform the xml (Sablotron or DOM-XSLT)

(Edited by Nathus on 03-31-2005 17:20)

mberning
Obsessive-Compulsive (I) Inmate

From:
Insane since: Mar 2005

posted posted 03-31-2005 18:39

That correctly adds

code:
<?php
include "document.php";
?>



to my html files but apache is not configured to send html files through the php processor. I doub't that my boss would like adding very many <File> and <FileMatch> directives to httpd.conf or running every html file throught the php processor. I've tried storing the output of the script into an xsl variable and then using a xsl:value-of to get the value of the variable, but that produces tag errors. What I would like to do is capture the output of the news.php script and simply copy that text to the resulting html file.

Thanks for all your help,
mb

Nathus
Bipolar (III) Inmate

From: Minnesota
Insane since: Aug 2003

posted posted 03-31-2005 21:45

I take it you are writing the output of the xslt to a static html page then.

You could put some form of placeholder tag into the xslt, take the result of the xslt transformation, then before you write it to file, pass it through a function to replace that placeholder with the newsfeed, then write it to file.

mberning
Obsessive-Compulsive (I) Inmate

From:
Insane since: Mar 2005

posted posted 04-07-2005 14:44

Solution:

Create a symbolic link from page.html to page.php and then publish the pages normally. PHP gets properly executed and it still looks like an html file to the rest of the world.

Thanks for all your help,
Mike



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu