473,597 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.o rg.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

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

Apr 2 '06 #1
3 1751


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 "traditiona l" 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
2931
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... How can this be accomplished with CSS? Thanks,
2
1747
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 is send/received between both is encrypted and signed to keep hackers away Now, the problem is, that I haven't found a way to 'add' a certificate to my web service object (in VB.NET). The class NetworkCredentials does not seem to support this (or am...
1
2013
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 which evaluates to a "division by zero" on purpose to raise an alarm (dirty) This is the statement: SELECT
0
1069
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 integration for working with ASP.NET Web Services. It provides a mechanism of adding a Web Reference using a IDE feature. What this feature basically does is use the WSDL utility(WSDL.exe) (DISCLAIMER: as I understand it!) and generate the proxy...
0
1049
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 my client essentially needs it & thats "1 Dot Half Tone Pattern". Please help me achieving this or explaining about this particular pattern. Rachit
1
1045
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 loaded, it's displayed in the message textbox. Currently, this is the end of the XML phase. Now the user can edit the textbox before sending the message and the content of the textbox will be sent when the user hits send. Now to thicken the...
6
2067
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 DeviceManager which is only interested in CD/DVD devices. I want to get the list of CD/DVD devices and "be informed when a disc inserted into a device". I am developing this on Linux. So, I used HAL API and read some system (actually /proc) files to gather...
6
1992
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 error on them now. The error occurs when I attempt a series of SQL statements wrapped in a TransactionScope(). It's executing against a different server, so this is where it's elevated to a distributed transaction.
6
9475
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 quickbooks has its make payment form. On QB you select the client and it shows all pending invoices for that client. what I like is that if there are 3 invoices pending #1= $20 #2= $50 #3= $100 it shows you all the and gives you the total at the botom,...
2
2731
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 showing 'Applying Security Settings' screen. But not logging in. Anybody have a solution please..... Prem TeamWork
0
7886
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,...
0
8258
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
6688
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
5847
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
5431
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
3886
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2404
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
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
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.