spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column62


WMLScript Primer

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

Compilation Units and Pragmas

WMLScript is a compiled language and uses Compilation Units and Pragmas. A certain application may include separate scripts that were individually and independently compiled. A compilation unit can call functions that are defined in another compilation unit. WMLScript uses pragmas to identify other compilation units that it uses.

The use url pragma specifies the location (URL) of the external WMLScript resource and gives it a local name. This name can then be used inside a function declarations to make external function calls. Let's examine the following example:

use url DocJS "http://www.docjavascript.com/mylibs/mywmlscript"

function divide(nom, denom) {
  if (denominator == 0) return invalid;
  return DocJS#mydiv(nom, denom);
}

The sequence of operations that take place here is fairly intuitive. The use url pragma specifies a URL to a WMLScript compilation unit, http://www.docjavascript.com/mylibs/mywmlscript. If the file extension is omitted (as above), the user agent will look for the extension .wmlsc, i.e. it will look for http://www.docjavascript.com/mylibs/mywmlscript.wmlsc. As we explained in our previous column, WMLScript scripts are stored under .wmls file extension and their compilation results are stored under .wmlsc.

Once the file is found, the function call DocJS#mydiv() triggers the loading of the external compilation unit, http://www.docjavascript.com/mylibs/mywmlscript.wmlsc. Upon successful loading of the external resource, its content is verified to have the definition of the mydiv() function, and it is actually executed with the calling parameters, mydiv(nom, denom). The use url pragma has its own name space for local names, but they must be unique within the same compilation unit.

Another type of pragma is the access control pragma. Every compilation unit can have only one access control pragma. The access control pragram specify which URLs can call the external functions in the access-controlled compilation unit. The syntax of access control pragma may be specified in any one of the following forms:

use access domain 
use access domain ;
use access path ;
use access domain  path ;

The referring compilation unit's URL must match the access control specification. A URL consists of a domain name and a path. The referring compilation unit's domain name is matched with the access domain specification, while the compilation unit's path is matched with the access path specification. The domain matching is guided by two principles. First, they are suffix matched, i.e. matching is done from right to left. Secondly, entire sub-domain elements mush match. Given the following access control for a compilation unit:

use access domain "webreference.com" path "/js";

The following URLs would be allowed to call the external function in the access-controlled compilation unit above:

http://webreference.com/js/tips.cgi
https://www.webreference.com/js/categories.wmlsc
http://www.webreference.com/js/tools/newtool.cgi?x=123<y=456

But the following URLs would not be allowed to call the external functions:

http://www.microsoft.com/javascript
http://www.webreference.com/dhtml/mytool.cgi

As you can notice, the access path is prefix-matched, i.e. from left to right. The same principles hold here as well, including that entire sub elements must be matched. The path /js will not match /j/mytools, for example. By default, access control is disabled, so all external functions have public access.

The third type of pragmas is the meta information pragma. It conveys information between different players of the wireless communication: originating servers, connecting servers, and user agents. The name meta pragma may be used by the originating servers for different kind of information. Here is an example:

use meta name "Created" "22-May-00";

The HTTP equiv meta pragma is used to specify HTTP header information for those mediating servers that transfer the compilation unit. Here is an example:

use meta http equiv "Keywords" "Script, Language";

And finally, the user agent should also be able to receive information from the server. Here is an example:

use meta user agent "Type" "Test"

Next: How to read the Mortgage example

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Crucial Triples Up With New Three-Channel DDR3 Kits · Meet the Finalists: Excellence in Technology Awards · Tealeaf Offers Insight to Mobile Customer Behavior


Created: May 22, 2000
Revised: May 22, 2000

URL: http://www.webreference.com/js/column62/4.html