PHP Code inside XSL

Having trouble installing Oxygen? Got a bug to report? Post it all here.
deltaevo1
Posts: 3
Joined: Sun Oct 24, 2004 4:41 am

PHP Code inside XSL

Post by deltaevo1 »

hi,

I am evaluating oxygen and I have a question about PHP code :

-Objctive: Build a home page using XML/XSL and PHP

-Context : 1 xml file that contain my web page datas, 1 xsl file that contains the design of my page.

-Problem : I need to display the date on my home page, In the past I made a php script that displays the date of the day in a specific format.

The problem is that when I include in my xsl file the necessary php code to display the date where I wanted it to appear (<?php include ('date/date.php'); ?>), it does not display the date.

In the html code generated by my xsl transformation, no sign of my php code ???

anyone can help ??


Thanks in advance

PS: For now I appreciate Oxygen :-)

fp
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

In order to generate the

Code: Select all


(<?php include ('date/date.php'); ?>)
processing instruction in your result file yoo need in your stylesheet something like

Code: Select all


<xsl:text>(</xsl:text>
<xsl:processing-instruction name="php">
<xsl:text>include ('date/date.php');</xsl:text>
</xsl:processing-instruction>
<xsl:text>)</xsl:text>
Best Regards,
George
deltaevo1
Posts: 3
Joined: Sun Oct 24, 2004 4:41 am

Post by deltaevo1 »

It Works, thanks a lot for the help :-)
pk_mkhalid
Posts: 3
Joined: Thu Mar 17, 2005 11:07 am
Location: Lahore, Punjab, Pakistan

Post by pk_mkhalid »

This is not working on my site... Can you help me where the problem is... I worte the same code inside my xsl file.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

It is impossible to tell what is wrong in something I do not see :). Try to get a small stylesheet and XML file that show your problem and post them here (in general people find the problem themselves in this process).

Best Regards,
George
pk_mkhalid
Posts: 3
Joined: Thu Mar 17, 2005 11:07 am
Location: Lahore, Punjab, Pakistan

Post by pk_mkhalid »

Thanx for reply. My code is

Code: Select all


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<xsl:output method="html" indent="yes" encoding="utf-8"/>

<xsl:template match="/">
<xsl:processing-instruction name="php">
<xsl:text>include ('date.php');</xsl:text>
</xsl:processing-instruction>
</xsl:template>

</xsl:stylesheet>
Remember I am using PHP and Sablotron for parsing xsl, xml in PHP
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

I do not see any problem with this using Saxon and Xalan. I do not know about Sablotron, sorry. What output do you get and what do you expect?

Best Regards,
George
Post Reply