473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

xsl:processing-instruction name="php"

brettl
41
Hey all.

I'm not sure if this question should be posted here or in the XML forums. Please forgive me if its in the wrong place or feel free to move it.

Any who, I'm using a SOAP service to display a list of news articles. I'm outputing the results using XSLT.

I'm using the following code to strip the returned pubdate and then calculate the time between today's date and the pubdate.

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="f[@n='pubdate']">
  2. <xsl:if test="string-length(current()) &gt; 0">
  3.  
  4. <xsl:processing-instruction name="php">
  5.      $today=time();
  6.     $pubdate="<xsl:value-of select="current()" />";
  7.     $year = substr($pubdate, 0, -16);
  8.     $month = substr($pubdate, 5, -13);
  9.     $day = substr($pubdate, 8, -10 );
  10.     $hour = substr($pubdate, 11, -7 );
  11.     $minute = substr($pubdate, 14 , -4);
  12.     $second = substr($pubdate, 17, -1);
  13.     $newpubdate = mktime($hour, $minute, $second, $month, $day, $year);
  14.     $difference = $today - $newpubdate;
  15.       echo 'Date: ';
  16.       echo floor($difference / 84600);
  17.       $difference -= 84600 * floor($difference / 84600);
  18.       echo ' days, ';
  19.       echo floor($difference / 3600);
  20.       $difference -= 3600 * floor($difference / 3600);
  21.       echo ' hours, ';
  22.       echo floor($difference / 60);
  23.       $difference -= 60 * floor($difference / 60);
  24.       echo ' minutes, and'. $difference.' seconds ago.';
  25.     </xsl:processing-instruction>
  26.  
  27. </xsl:if>
  28. </xsl:template>
  29.  
For some reason I can't get the outputed PHP to run. I get the following page source but the PHP doesn't do anything.


[HTML]<div xmlns:php="http://php.net/xsl" class="sectionheadsm">
<h3>News from the Web</h3>
</div><div xmlns:php="http://php.net/xsl" id="news">
<ul>
<li>
<a href="http://www.news.net/id_newsarticle/CA6476653.html" onmousedown="ebatr('710',this.href,'news','news.co m+Creates+Virtual+Carpet+Samples','by+Laura+B.+Wei ss','2007-09-10T00%3A00%3A00Z');">Carpet.com Creates Virtual Carpet Samples</a>
<br/>
<div class="publication">

Source: News</div>
<div class="date">
<?php
$today=time();
$pubdate="2007-09-10T00:00:00Z";
$year = substr($pubdate, 0, -16);
$month = substr($pubdate, 5, -13);
$day = substr($pubdate, 8, -10 );
$hour = substr($pubdate, 11, -7 );
$minute = substr($pubdate, 14 , -4);
$second = substr($pubdate, 17, -1);
$newpubdate = mktime($hour, $minute, $second, $month, $day, $year);
$difference = $today - $newpubdate;
echo 'Date: ';
echo floor($difference / 84600);
$difference -= 84600 * floor($difference / 84600);
echo ' days, ';
echo floor($difference / 3600);
$difference -= 3600 * floor($difference / 3600);
echo ' hours, ';
echo floor($difference / 60);
$difference -= 60 * floor($difference / 60);
echo ' minutes, and'. $difference.' seconds ago.';
?>
</div>
</li>
</ul>
</div>
</div>[/HTML]



Any help with this would be greatly appreciated.

Thanks
Sep 21 '07 #1
2 3716
pbmods
5,821 Expert 4TB
Heya, Brett.

XSL is evaluated client-side by the browser, whereas PHP is evaluated server-side. The only way to evaluate PHP is to load and execute the file on the server.
Sep 21 '07 #2
brettl
41
Doh!

Thanks for the help pbmods.
Sep 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jeb Hunter | last post by:
Seems to be arbitrarily specified or omitted in various documents. Maybe this is a PHP element that I've not encountered yet, being new to it. Or is there some XSLT-specific reason for this? ...
5
by: bcanavan | last post by:
When I export xml(and xls) from Access 2003 the result is a complete report in a single page. I would like to get the entire report in a single page (one trip to the server) for printing and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.