OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] [ANN] XQuery in the Browser, JavaScript Edition

As a follow-up, I've been playing with xqib-js on my laptop most of the evening, and my reaction to this has escalated from "cool" to "incredible!" to "this is a frigging game changer!!". I've already started writing an article on it, should have something published over the weekend.

I've just been playing around with it, after installing the archive, and have ended up with a quick "test" script:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <title>XQIB: Sample page</title>
    <meta charset="UTF-8"/>
    <script type="text/javascript" src=""mxqueryjs/mxqueryjs.nocache.js"></script>
    <script type="text/xml" src=""/lib/resources/colors.xml"" id="data"></script>
    <script type="text/xquery">
       declare variable $foo := "XQuery!";
        declare function local:get-color-list($url as xs:string) as node(){
          (let $colors := fn:doc($url) return
           <div style="background-color:lightGray;">
            for $term in $colors//*:term 
                <li style="color:{$term/*:value}">
                    <span style="color:black">{fn:string($term/*:label)}</span>

       declare updating function local:main() {
         let $eltnames := ("h1","h2","h3","h4","h5","h6","fieldset")
         let $elts := for $eltname in $eltnames return element {$eltname} {"This is a test. This is only a test."}
         let $bar := b:dom()//div[@id='bar']
         let $table := 
                 <th>Element Name</th>
                 <th>Example Text</th>
               {for $index in (1 to fn:count($elts))
                return <tr>
         return (
      insert node <div>{$elts}</div> as first into $bar,
      insert node $table as last into $bar,
      insert node <div>{fn:string-join(fn:tokenize("red,green,blue,yellow",","),";")}</div>  as last into $bar,
      insert node local:get-color-list("http://localhost:8100/lib/resources/colors.xml") as last into $bar,
      insert node <div>{$foo}</div> as last into $bar)
    <h1>Test Page</h1>
    <div id="bar"></div>

The scripts are fast too - running this in both Chrome and Firefox, the refresh is a shade slower than what you'd expect for JavaScript by itself, but far faster than the plugin (which had a bad tendency to crash on me when I used it).

On game-changing - one of the central problems that XML has had on the web is that XML parsing using DOM is, to put it bluntly, a pain in the butt, yet it is how an overwhelming majority of the people working with web page content deal with it. Not surprisingly, this has led to the rise of JSON, which is certainly parseable in the Javascript world, but for people working with XML content on the server, JSON is a pain as well. 

If the test that I see here is any indication, xqib-js may change that equation dramatically. I could easily see this as the foundation for an XQuery based XForms system. It makes both inline and externally loaded XML manipulation possible - indeed, makes it trivially simple. It puts XQuery into the hands of web developers, rather than just database developers, which should increase the number of XQuery skilled devs. It provides another client for XRX applications (I'm already envisioning how you could make a very effective database "reader" with it). It makes binding easy - instead of needing a specialized function for retrieving items of a given class, you can get a list of all items of a given class as 

let $class-items := b:dom()//*[$class = tokenize(@class," ")]

and then bind these to sets of events that generate differing representations depending upon the state of the relevant elements and the events in question.

Eagerly awaiting the completed suite,

Kurt Cagle
Managing Editor, xmltoday.org

On Thu, Jan 6, 2011 at 7:08 PM, Kurt Cagle <kurt.cagle@gmail.com> wrote:

Just been playing with it in ff4 on my Android ... very, very cool

On Jan 3, 2011 9:01 AM, "Fourny Ghislain" <gfourny@inf.ethz.ch> wrote:
> Dear all,
> Last year, at XML Prague 2010, we presented our latest release of the XQuery in the Browser plugin. While the audience seemed enthusiastic about this idea, using a plugin was seen as insurmountable obstacle to a wider adoption of using XQuery on the client layer.
> So we decided to get rid of the plugin.
> It is our pleasure to introduce an alpha preview of XQuery in the Browser, JavaScript Edition. The principle remains the same: the XQuery code put inside a script tag (type text/xquery) gets executed. The difference is: there is nothing to install.
> A preview of some samples is available under http://www.xqib.org/js
> More information (supported browsers, how to write your own XQuery code…) is available under http://www.xqib.org
> Your feedback is welcome.
> Kind regards and happy new year,
> Ghislain
> _______________________________________________________________________
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS