Click to See Complete Forum and Search --> : Client-side Dynamic XML Transforms?


tonyh
02-21-2004, 09:01 PM
I've been researching XML for about a week now, and have had extreme difficulty finding info on "dynamic" XHTML, XML, XSL, thus the XML equivalent of DHTML. I understand the three ways of implementing XSLT on the Internet (I am aware that it is designed for several ouputs, but lets keep this simple): browser, client and server.

Unfortunately only the most recent browsers implement XSL and even then their parsers seem to have difficulties or do not adhere to the W3 recommendations correctly. This alone makes one question if XML implementation is viable considering cross-browser compatibility issues. I'm not even sure if all browsers can recognize XHTML Strict. Thus I've come to the conclusion that XML transformations in the browser is not a solution at this time.

I do believe that for the time being that XSLT server-side transformations are the best solution. However, there leaves the problem of soft refresh dynamically created content, which is what XSLT was designed for. To be able to display XML files dynamically within the client including data reorganization and styles.

Which leaves JavaScript, but as Charles would tell you, there comes the problem of accessibility laws and enabled browsers. Not to mention all the problems regarding cross-browser compatible code.

So to satisfy Charles, lets say we've designed a site using a static menu system that doesn't use JavaScript and fills in all the other requirements and suggestions for disabilities. Now we built a second site which is dynamic, how would I dynamically create XHTML using XML, with XSL styles and transforms on the client? The only server-side script (PHP, ASP, I don't care, it's moot to this discussion) I want to use is onClick or OnLoad.

For example I want to build a dynamically created three tier expandable vertical menu like CssCreator's MultiMenu (http://www.csscreator.com/menu/multimenu.php) using one XML file describing the menu and one XSL file that will display parent and child node(s) according to the parents location in the main menu. I haven't studied long enough to explain this the way it's in my head, and unfortunately I don't have any code to show either. Just use the above link for a visual reference.

Remember, I said I only want one XSL file, as that should all be that's needed to manipulate the one XML menu descriptor file. Atleast that's my understanding of XSLT. Therefore, I want this XSL file to be rewrote with each mouseEvent over the main menu (parent.) I can do this easily with server-side if the menu uses anchors or images including an href when it's clicked, as a mouse click will cause an hard refresh. I should also mention that layout designs (div/tables) and display/visibility should be handled using XSL as well and not CSS (W3School Article (http://www.w3schools.com/xml/xml_display.asp).)

Originally posted by Robert Wellock
XHTML and CSS-P are a stable diet for any serious Web Author. PHP is a time saver and adds dynamic capacity to a website and helps interact with a Server to generate XHTML from templates or connect to a Database Driven site much like this forum.

But what if I want this same functionality with an Event Handler (http://www.w3schools.com/dhtml/dhtml_events.asp)?

Here lies the problem, unless someone can tell me otherwise, is that client-side script cannot write a file. I have read threads discussing dynamically generated JavaScript using XSL, but can we dynamically generate XSL with JavaScript? Bare in mind that if adding JavaScript to CSS files is not recommended ( QuirksMode Article (http://www.quirksmode.org/css/javascript.html)) then adding JS to XSL shouldn't be recommended either. Of course, we could always write several XSL pages for each particular event, but with the potential of a three tiered menu, that may require a database to itself.

So how do we create dynamic content on the client, as oposed to the server, with the XML family?

tonyh
02-21-2004, 09:36 PM
Please delete I hit quote instead of edit by mistake.

Khalid Ali
02-22-2004, 10:38 AM
Simple answer is (as of today) you can not create completely dynamic contents without increasing server hits.
As you mentioned your self,not most of the browser even has a built in XSL processor(only IE6+ adn NS6+ offer this functionality)

In my opinion sticking to an absolute approach is not a workable solution.You will end up mixing and matching technologies by adhering to standards as much as possible and create your pages.

Best option still will be to user server side XSL processing, and make sure that your logic does not require a server hit at every click on the menu.

tonyh
02-22-2004, 04:04 PM
Originally posted by Khalid Ali
Best option still will be to user server side XSL processing, and make sure that your logic does not require a server hit at every click on the menu.
I agree to an extent, but I was attempting to provide an example where "a server hit at every click" is not warranted. An event handler such as onmouse[...] is not a click; therefore, server side script will not be executed. Or am I wrong?

I would also like to expand on my previous example, regarding its implementation: table or div. If the menu is designed using listed links, then a three column table format is logical, with one XSL file to be dynamically written for the organization of rows. But, depending on layout design, a div implementation may be more versatile. For a three tier model a minimum of three divs would be required, thus three XSL classes or namespaces? The question is not how to manipulate the visibility of the div or column, but how to manipulate the XSL file defining the organization of each column or div without using server side script?

Since we are trying to implement this type of functionality on the client the answer would be XSLT or client side script. Until the ECMA E4X (http://www.ecma-international.org/news/ECMA%20E4X%20Final%20Final%20Web.htm) language is released, atleast I hope it's a language and not just another specification as suggested by "The enhancements known as E4X (ECMAScript for XML) standardize the syntax and semantics of a general-purpose, cross-platform, vendor-neutral set of programming language extensions [...]," we are left with Java(J)Script or XSLT. But as already stated XSLT is not implemented in most commonly used browsers, so we're stuck with JS. Despite the fact that a discussion of JS belongs in it's own forum, this particular discussion is strictly XML in nature, thus I believe belongs here for easy reference and search. So what is the JS solution?

Barring in mind that the above is only one common real world implementation, one can see the potential of modifying content in div, span, img or even positioning with XML and XSL. The question continues to be how to implement the equivalent of DHTML with XML/XSL? I suppose one could ask why CSS is continued to be developed if it's already implemented in XSL? Or one step further, will XSL 2.0 be able to implement CSS2 and CSS3?