Email conversation
From | Michael Kalua |
To | Me |
Subject | Is XMLHttpRequest the only way to Support My Opera and Safari Users? |
Date | 8 November 2004 21:46 |
Good Afternoon,
I am a very amateur programmer, less than 3 months of experience. I have
been assigned the task of taking an xml file and providing my company's
website with the ability to manipulate and display its contents in a
specified layout given to me by the site's graphic designer. Using php and
xsl I have achieved my goals after hours of toiling behind a simple text
editor and pouring over books, forums, online tutorials and manuals.
Triumphantly I presented my results to the graphic designer only to be cut
down at the knees when he viewed my achievement with Safari 1.2. I tested
all of my code in IE 6.0.2 and it works flawlessly. In Safari my wonderful
xsl stylesheet is discarded and a large blob of unfriendly black text on a
white background is all that he can see.
I read your website, most of which flew straight over my head since I have
not learned javascript, and it looks as if you have the solution. I will be
diving in to your tutorial, how to's and the world of javascript later this
evening. Thank you in advance for providing this information.
Finally my question: is your XMLHttpRequest javascript the only life
preserver out there? I noticed an email posting on your site that spoke of
server side xsl. Is there any way you could provide me with a more in depth
explanation of this possibility? All I want to do is take this xml file and
show the world what is inside it within the layout given to me by my graphic
designer. Unfortunately for me the only ones who can see what I have done
are the borg that have been assimilated with IE 6.
Thank you in advance for any help you may give me,
Cheers
Mike K
From | Me |
To | Michael Kalua |
Subject | Re: Is XMLHttpRequest the only way to Support My Opera and Safari Users? |
Date | 9 November 2004 8:24 |
Mike,
W3Schools have a fairly good tutorial on XSLT, including some pages on
using the server to parse it instead of the client. Much more browser
friendly. This is the preferred solution, because not only can you use the
template you have already produced (and therefore avoid extra work), but it
is also the most accessible technique, as it does not require a specialised
browser.
http://www.w3schools.com/xsl/xsl_server.asp
If you are unable to process this on your server due to some server
restriction then yes, the importing XML is the only real solution. And
although I do not want to sing my own praises too much, mine offers the
highest level of browser compatibility of any client side XML importing
script. The only warning is that Opera 7.6 (the first Opera version to be
able to import natively) is still in preview, due for release later this
year. Earlier versions should work, but there is a possibility that on slow
connections with extremely large XML files, they might find some of the
content missing. If you suffer from this, get back in touch, because I have
a possible solution that might help.
Other than that, as an Opera (and Safari) user, please pass my thanks back
to the people who make the decision to support us, it is much appreciated.
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Michael Kalua |
To | Me |
Subject | XSLT in PHP5 for supporting my Opera and Safari users |
Date | 10 November 2004 20:05 |
Good Afternoon,
Thank you so much for replying to my last email asking if your script was
the only life preserver out there for supporting my opera and safari users.
When you suggested that I use server side scripting via *.asp I began to
research the possibility immediately. As I googled and read, googled and
read some more I came across a new function of PHP5 that I had not yet
investigated; XsltProcessor(). This has turned out to be the answer to what
I want to do.
The code that I used to achieve this is not of my own making, which irks me
to no end. I do not like taking samples of code from people and calling
them my own. I do not have this person's real name but their handle on the
forum I found was "diagi," so the credit goes to them. Code is as follows:
<?
$xml = new DomDocument();
$xml->load('news.xml');
$xsl = new DomDocument();
$xsl->load('news.xsl');
$xslt = new XsltProcessor();
$xslt->importStylesheet($xsl);
$transformation = $xslt->transformToXml($xml);
echo $transformation;
?>
The original code had different file names, of course, so I edited that
portion and executed the code. All came out perfect. I have in front of
me, three monitors. Each one is viewing the same page, one with safari, one
with mozilla and one with IE6. They all look identical.
I am getting ready to show my graphic designer, the one that cut me off at
the knees about safari and opera. Wish me luck. Server side scripting
works for me!
Good day to you!
Cheers,
Mike K
From | Me |
To | Michael Kalua |
Subject | Re: XSLT in PHP5 for supporting my Opera and Safari users |
Date | 11 November 2004 8:14 |
Mike,
That is excellent. Very very useful, thanks for letting me know. I will add
a note about this to my page.
Always seems to be the way with PHP - if you want to do something, someone
else will already have thought about it and done it for you. But I honestly
never realised it would be that easy to do XSLT.
Tarquin