[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl:apply-templates in javascript

Subject: Re: xsl:apply-templates in javascript
From: "Brandon Borkholder" <borkholder1879@xxxxxxxxxxx>
Date: Wed, 25 May 2005 21:07:13 -0500
javascript apply xsl
That sounds interesting, but I'm not sure what you mean by a "whole branch" in XSLT.

I've tried the disable-output-escaping, and that only works if your template escapes the tags in the first place, ie &lt;. I understand this is a horrible misuse of XSL and it's a shame to do it, but I'd like not to load all these images when the page loads, and only load them on demand. The document.write() mechanizm is the only way I know how to do it so far.


----- Original Message ----- From: "Wendell Piez" <wapiez@xxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, May 25, 2005 11.22 AM
Subject: Re: xsl:apply-templates in javascript



Brandon,

Thinking about this further, I suppose it actually would not be impossible to use the regular serializer: build a whole branch in your XSLT (in the midst of script-as-literal-text) and let the regular HTML serializer write it out. But you wouldn't have control over whitespace and other syntactic details over how the HTML snippets would be written out in the Javascript, so this approach would be potentially troublesome, non-portable and so forth. (For example, you couldn't control whether attributes values were delimited with " or '.)

On the other hand, this whole issue is confusing ... not having my hands on it, I can't be absolutely sure I'm not just tangling my brain up thinking about it.

Cheers,
Wendell

At 11:32 AM 5/25/2005, I wrote:
Brandon,

Is it really necessary to load part of your document dynamically? (I'd consider the simpler solution of simply hiding the content and exposing it dynamically, if I could.)

If so, you might ask that question -- how do I load part of a document dynamically -- in whatever scripting forum is appropriate. (I don't know what kinds of constraints over your scripting you face: e.g. must this be multi-platform. But those aren't XSLT questions.)

In general, your question is difficult because two different paradigms of document processing are colliding. In general, the Javascript method of "tag-writing" output back to the browser is inimical to (though as you have supposed, not impossible in) XSLT, where we prefer to serialize whole document trees, not just fragments at a time (thus it's an architectural question). Fortunately, these days one has the DOM, and the browsers support methods for working with sets of nodes (elements and attributes) rather than writing tags. I'd try writing my Javascript to use such methods, rather than doing tag writing.

But none of that is really pertinent to XSLT. To answer the question as given: you can "tag write" HTML if you want to (just as you can "tag write" a representation of the XML source), using disable-output-escaping. It would be a terrible shame, but it could be done.

I have my doubts that the resulting Javascript would be either as robust or as portable as Javascript DOM methods, however.


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.