473,395 Members | 1,977 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,395 software developers and data experts.

Applying CSS to client-side transformed pages

I've been doing XSL transforms, converting XML to HTML, server side since
2000. In those days, clients which could do the transformation client
side didn't exist, so whether to transform client-side or server-side
wasn't an issue.

Recently I've been overhauling the code in order to pass transform to the
client wherever possible, and I've hit two problems

(i) How do I know whether the client can do transforms? Currently I'm
only passing the transform to the client if the client sends an
'Accepts' header which contains either 'application/xml' or
'text/xml'. However, Internet Explorer 6, which apparently can do
transforms client side, doesn't send either of these.

(ii) When the transforms transform XML to HTML which includes a link to a
CSS stylesheet, the visual appearance (in Firefox, anyway) which
results from a client-side transform is quite different from that
which results from a server-side transform, and it appears that the
CSS styling is being applied before the XSL transform is complete.
How can I ensure that the CSS is applied to the completed page?

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

;; when in the shit, the wise man plants courgettes

Apr 2 '06 #1
3 1730


Simon Brooke wrote:
(i) How do I know whether the client can do transforms? Currently I'm
only passing the transform to the client if the client sends an
'Accepts' header which contains either 'application/xml' or
'text/xml'. However, Internet Explorer 6, which apparently can do
transforms client side, doesn't send either of these.
I don't think the HTTP Accept header helps. In the end there is nothing
very reliably that you could do, sniffing the user agent to try to
identify the browser and compare against a list of XSLT capable browsers
you keep is one approach but for various reasons user agent strings are
changed to spoof certain browsers.

And if someone installs e.g. MSXML 3 with IE 5 or IE 5.5 then those
browser support client-side XSLT but their user agent string will not be
different from the original installation of IE 5 or 5.5 not supporting XSLT.

What you could try is to only rely on client-side XSLT run by script and
not run by <?xml-stylesheet?>, with client-side JavaScript you can
nicely check whether certain objects (e.g. XSLTProcessor) are exposed in
the current user agent.

But as IE/MSXML's API to run XSLT transformations is much different from
the API Mozilla provides writing script for both is tedious and
cumbersome (Mozilla allows you to transform to DOM nodes to be inserted
with W3C DOM methods, MSXML allows you to transform to string only to be
inserted with e.g. innerHTML IE's proprietary DOM).

Furthermore I think Safari supports client-side XSLT with
<?xml-stylesheet?> but so far does not expose an API to script to run
transformations.

As you are starting with a working solution doing XSLT on the server and
the way to client-side XSLT is difficult I would rather stay on the server.
(ii) When the transforms transform XML to HTML which includes a link to a
CSS stylesheet, the visual appearance (in Firefox, anyway) which
results from a client-side transform is quite different from that
which results from a server-side transform, and it appears that the
CSS styling is being applied before the XSL transform is complete.
How can I ensure that the CSS is applied to the completed page?


That sounds odd, do you have a simple test case where that fails? Of
couse it could be simply CSS differences depending on whether Firefox
renders in quirks mode or in standard compliants mode (where there are
differences whether the HTML html element or the body element are the
canvas). Thus if you have e.g.
body { background-color: green; }
doing
html, body { background-color: green; }
could help.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 2 '06 #2
Simon Brooke wrote:
I've been doing XSL transforms, converting XML to HTML, server side since
2000. In those days, clients which could do the transformation client
side didn't exist, so whether to transform client-side or server-side
wasn't an issue.

Recently I've been overhauling the code in order to pass transform to the
client wherever possible, and I've hit two problems
Right. Client-side XML isn't worth it unless you can control the browser
version. For some unexplained reason, browser-makers simply haven't put
any effort into fixing client-side transformation yet.
(i) How do I know whether the client can do transforms? Currently I'm
only passing the transform to the client if the client sends an
'Accepts' header which contains either 'application/xml' or
'text/xml'. However, Internet Explorer 6, which apparently can do
transforms client side, doesn't send either of these.
See http://xml.silmaril.ie/users/browsers/
(ii) When the transforms transform XML to HTML which includes a link to a
CSS stylesheet, the visual appearance (in Firefox, anyway) which
results from a client-side transform is quite different from that
which results from a server-side transform, and it appears that the
CSS styling is being applied before the XSL transform is complete.
That sounds unlikely. XSLT transformation undergoes serialisation only
as the last stage (in the applications I have seen) so it ought to apply
CSS only once the output HTML hits the browser's parser. But I guess
it's possible that it works differently internally -- yet another reason
why client-side transformation simply isn't worth it yet.
How can I ensure that the CSS is applied to the completed page?


You can't. IE is hopelessly broken. Firefox is better, but still
incomplete. Opera is slightly better still, but all three do a number
of things differently, and some of them are just plain wrong.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Apr 2 '06 #3

Simon Brooke wrote:
I've been doing XSL transforms, converting XML to HTML, server side since
2000. In those days, clients which could do the transformation client
side didn't exist,
Well they certainly did exist, because I had production code doing this
throughout '99.
so whether to transform client-side or server-side wasn't an issue.
It was a horrible issue - very few clients supported it. Even for IE
you had to be careful just which version of MSXML was available. I had
client-side JScript that could tell, but I had to report this back to
the server with an explicit flag, there wasn't anything in the standard
HTTP headers.

I mainly did it by IP address, or by login credentials. I was doing
AJAX-like downloads of huge browse trees into user controls. Although
it was a useful feature, I just couldn't expect it to work outside our
intranet and some carefully installed IEs with the latest MSXML
deployed to them. The extranet users had to lump it with a server-side
version (fortunately they were just read-only query users, not data
entry).

I also disliked doing pure client-side transforms of the whole page.
Users saw a blank screen while the transform was going on, and if
anything failed they were left with nothing. I much preferred a "data
island" approach where they had a basic no-data page and a "loading..."
message, which then filled out a <div> with ther transform's result.
The "data island" could either by synch (with the <XML> tag) or asynch
(XmlHttpRequest), because it was all IE-only code anyway.

Recently I've been overhauling the code in order to pass transform to the
client wherever possible, and I've hit two problems


I now do it by looking at the HTTP headers for some explicit request
that I add from client-side AJAX code. I (still) just don't bother with
client-side XSLT for "traditional" request-serve HTTP processing. If
you need this transform, then it's for some sophisticated asynchronous
"not quite so thin" client. Basic "do a GET and return HTML" processing
can stick with it server-side.

OK, so I'm not getting the reduced server load and bandwidth shrinkage
of a client-side transform. But servers are fast and pipes are fat
these days. I still get the extra functionality when I want it.

If I do use client-side from a simple GET, it's flagged in the session
state and I've already identified the capability by more sophisticated
means. The flag also goes into the URL, to support re-visiting future
bookmarks. These break if you exchange bookmarks between capable and
non-capable clients, but I have enough basic nav to allow recovery from
this that's only slightly ugly.

Apr 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Neil Zanella | last post by:
Hello, I would like to use CSS to apply a width of 100% to all <input> elements, but to only those that have an type attribute set to "text", without affecting check boxes, radio buttons, etc......
2
by: Ralph Jones | last post by:
Hi I just wrote my first web service and now I want to enable security for both server and client. That's why I decided to use X509- Certificates on both server and client, so that every data that...
1
by: florian.boldt | last post by:
Hi Folks, one of our developers uses a statement with a where clause which usually does not match to any rows. In case of one or more rows found she wrote a an expression in the select clause...
0
by: S.Subramanian Iyer | last post by:
Hello Everyone, This is an interesting issue that needs the community's attention and active participation. Lets begin from the top; Microsoft Visual Studio.NET provides excellent and extensive...
0
by: rachitonline | last post by:
Hi guys, i am working on making a image manipulation program, in that most of the effects i have managed to achieved using ColorMatrix class of .NET. Now i am stucked on getting one effect which...
1
by: Ben R. | last post by:
Hi, I'm writing a .NET winforms app that serves as an email client. Users can store message templates. This is done via an XML document for loading and saving the templates. When the template is...
6
by: Orgun | last post by:
Hi, I sent this message to the moderated c++ group too but it is waiting for moderator approval and I wanted to send here too. I am new to Design Patterns. I want to write a simple...
6
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
Hi - I have 4 webservers in my webfarm. All Win2k3 web edition. Before yesterday, none of them were service packed. I have now applied SP2 to two of them, and I'm getting a very weird MSDTC...
6
by: jdcallejas | last post by:
Hello, I am creating a database for my apartment complex. I have been able to desing it up to invoices... Now I am wondering how to make payments for the invoices. I wanted to have it like...
2
by: premMS143 | last post by:
Sir, In our company we are having around 75 computers. Out of these one of the client's computer having Win 2K OS installed. Nowadays whenever we switched ON the system, its hanging simply by...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.