The Artima Developer Community
Sponsored Link

Java Buzz Forum
E4X: Is ECMAScript the glue language we have wanted? It powers the browser VM.

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
E4X: Is ECMAScript the glue language we have wanted? It powers the browser VM. Posted: Feb 25, 2005 8:38 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: E4X: Is ECMAScript the glue language we have wanted? It powers the browser VM.
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
JavaScript has a bit of a tough label. Many developers think of it as a hackers web scripting language which is good for alert("foo") and document.*. The language is really growing up now though, and we have good implementations on the Java side such as Rhino. Rhino even implements the latest and greatest of ECMAScript: ECMAScript for XML (E4X). Now, XML is a first class citizen in the language which allows you to do some of the following: Create a DOM from XML var order = <order> <customer> <firstname>John</firstname> <lastname>Doe</lastname> </customer> <item> <description>Big Screen Television</description> <price>1299.99</price> <quantity>1</quantity> </item> </order> Walk the XML tree a la XPath etc // Construct the full customer name var name = order.customer.firstname + " " + order.customer.lastname; // Calculate the total price var total = order.item.price * order.item.quantity; Construct a new XML object using expando and super-expando properties var order = <order/>; order.customer.name = "Fred Jones"; order.customer.address.street = "123 Long Lang"; order.customer.address.city = "Underwood"; order.customer.address.state = "CA"; order.item[0] = ""; order.item[0].description = "Small Rodents"; order.item[0].quantity = 10; order.item[0].price = 6.95; Playing with SOAP var message = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <soap:Body> <m:GetLastTradePrice xmlns:m="http://mycompany.com/stocks"> <symbol>DIS</symbol> </m:GetLastTradePrice> </soap:Body> </soap:Envelope> // declare the SOAP and stocks namespaces var soap = new Namespace("http://schemas.xmlsoap.org/soap/envelope/"); var stock = new Namespace ("http://mycompany.com/stocks"); // extract the soap encoding style and body from the soap message var encodingStyle = message.@soap::encodingStyle; print("The encoding style of the soap message is specified by:\n" + encodingStyle); // change the stock symbol message.soap::Body.stock::GetLastTradePrice.symbol = "MYCO"; var body = message.soap::Body; Conclusion It is interesting to see ECMAScript leading the way in some areas. It is an interesting idea to have XML as such as first class citizen. I don't remember having "tab delimited data" at the same level, and it is a little worrying to think about XML abuse that could occur because of it. However, maybe it is time to take ECMAScript more seriously. It is installed in all browser VMs so to speak, and with implementations like Rhino, allows you to script Java in a simple way :)

Read: E4X: Is ECMAScript the glue language we have wanted? It powers the browser VM.

Topic: The First Questions for Every Entrepreneur Previous Topic   Next Topic Topic: PHP: Not being a snob

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use