[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Fwd: [whatwg] (deferred) script tags with document.write built in

Brett Zamir brettz9 at yahoo.com
Sun Jul 25 14:43:07 PDT 2010


  Fwd: [whatwg] (deferred) script tags with
	document.write built in
  I should have cc'd this with my original post to the HTML5 working 
group list, though I'll cross-post here now if anyone is interested in a 
proposal that might make the XQuery declarative style possible in HTML...

-------- Original Message --------
Subject: 	[whatwg] (deferred) script tags with document.write built in
Date: 	Sat, 24 Jul 2010 21:43:35 +0800
From: 	Brett Zamir <http://x-query.com/mailman/listinfo/talk>
To: 	whatwg <http://x-query.com/mailman/listinfo/talk>



Might there be a way that <script/> tags could add an attribute which 
combined the meaning of both "defer" and "document.write", whereby the 
last statement was evaluated to a string, but ideally treated, as far as 
the DOM, with the string being parsed and replacing the containing 
script node.

For example:

<script  write>
     '<span  onmouseover="alert(\''+(new Date())+'\')">I\'ve got the date</span>'
</script>


If E4X were supported (since we otherwise lamentably have no PHP-style 
HEREDOC syntax in JavaScript to minimize the few warts above), allowing 
this to be used could be especially convenient:

<script  write>
     <span  onmouseover="alert(new Date())">I've got the date</span>
</script>


(Maybe even a new <write/> tag could be made to do this exclusively and 
more succinctly.)

I chose "defer" as the default behavior so as to be XHTML-friendly, to 
allow convenient reference by default to other DOM elements without the 
need for adding a listener, and the more appealing default behavior of 
not blocking other content from appearing.

Since it doesn't seem that XQuery support will be making it into 
browsers anytime soon, it would be nice to be able to emulate its clean 
template-friendly declarative style, dropping the need to find and 
append to elements, etc..

Brett
----------------------------------
As an addendum to this original post, I might add that if more browsers 
add support for E4X (maybe an easier sell), if browsers will implement 
the tag proposal, and if we do get a JavaScript library built for 
parsing XQuery, we be able to use XQuery as easily (or at least 
declaratively) as the following (notice in particular the circumventing 
of JavaScript's lack of string HEREDOC syntax, allowing us to have 
strings spanning multiple lines without any escaping or concatenation):

<write>
     $XQ(<x><![CDATA[
         declaredefault  element namespace"http://www.w3.org/1999/xhtml";
         <div>  {
             for  $ain  doc()//a
             return  $a
         }  </div>
     ]]></x>.toString());
</write>


Even if the tag proposal is not accepted, our XQuery wrapper function 
could be used inside a regular <script/> tag and append the results to a 
specific element ID provided to the function as a second argument.

This could thus work whether the data sources were from locally culled 
HTML5 IndexedDB files, from files obtained by Ajax, whether from live or 
cached XML, or possibly via server-side JavaScript.

But without E4X (or an amendment to JavaScript allowing HEREDOC-like 
syntax), XQuery in the browser will be a little bit inconvenient (unless 
the XQuery was obtained from separate files, say via Ajax).

best wishes,
Brett

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20100725/1b977a34/attachment-0001.htm


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-2011 All Rights Reserved.