473,657 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xsl:processing-instruction name="php"

brettl
41 New Member
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="sectionh eadsm">
<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="eb atr('710',this. href,'news','ne ws.com+Creates+ Virtual+Carpet+ Samples','by+La ura+B.+Weiss',' 2007-09-10T00%3A00%3A00 Z');">Carpet.co m Creates Virtual Carpet Samples</a>
<br/>
<div class="publicat ion">

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($differen ce / 84600);
$difference -= 84600 * floor($differen ce / 84600);
echo ' days, ';
echo floor($differen ce / 3600);
$difference -= 3600 * floor($differen ce / 3600);
echo ' hours, ';
echo floor($differen ce / 60);
$difference -= 60 * floor($differen ce / 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 3725
pbmods
5,821 Recognized Expert Expert
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 New Member
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
1675
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? Can someone tell me what it means to have it, or omit it? Naturally, you can't search Google for the "@" character. :-( I'm lost. thanks...
5
4145
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 scrolling-preview, but with page breaks and page numbering appropriate to the paper size. I have a sense that this can be done in xsl, since xsl defines the format for everything else in the report. My goal is to avoid the time and expense of...
0
8323
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.