O'Reilly Network    
 Published on O'Reilly Network (http://www.oreillynet.com/)
 See this if you're having trouble printing code examples


Eric Krock Introduces XUL

by David Sims
03/03/2000

One of the most promising technologies to emerge from the efforts around XML -- at least from the point of view of web and application developers -- is XUL. XUL, the extensible user-interface language, is a standards-based way to create the user interface for a cross-platform application. It allows you to do with a few lines of markup language what until now took many lines of code. Applications interfaces, with their windows, frames, scroll bars, menus, and toolbars, are created easily -- and just as easily customized by the user.

Eric Krock, senior product manager at Netscape, gave a brief but enticing presentation at XTech on XUL. XUL was co-developed by Netscape and the Mozilla project during the last few years of work on the browser. Krock's enthusiasm for XUL rested largely on two capabilities:

  1. XUL is built on Web standards: HTML 4.0, XML, XML namespaces, Cascading Style Sheets (CSS) 1 and 2, and Document Object Model (DOM) 1 and 2. So, theoretically, any interface that supports the standards supports content written in XUL.
  2. Coding in markup language is much easier than the coding that's been necessary to build simple interfaces. "You don't have to be a C++ programmer to build an application interface," Krock told the crowd -- most of whom probably have been C++ programmers at some point in their career.

Why XUL?

XUL emerged from Mozilla/Netscape's efforts to efficiently build cross-platform interfaces. "Building separate front-ends for Windows, Macintosh, and GTK is expensive," Krock said.

Instead, XUL lets you create a browser interface in just a few lines of markup code. He showed the room the code for a menu bar that ran about 12 lines.

"It's going to democratize application development," Krock said.

Here's a sample of window code, take from Krock's presentation, which he has posted online.



<?xml version="1.0"?> 
<?xml-stylesheet href="chrome://global/skin/xul.css"
type="text/css"?>
<!DOCTYPE window>
<window id="main-window"
xmlns:html=http://www.w3.org/TR/REC-html40
xmlns="http://www.mozilla.org/keymaster/gatek eeper/there.is.only.xul">
<menubar><menu name="File">
<menuitem name="Hello World!" onclick="dump('Hello world!\n');"/></menu>
</menubar> 
<html:iframe id="content-frame" src="contentframe.html" flex="100%"/>
</window>

Where XUL's going

For More Information:

• Krock's A Taste of XUL presentation

• Mozilla.org's Introduction to XUL

• Eric Krock's site

XUL is not a standard, but Krock said Netscape intends to submit it to W3C. When the first beta of the Mozilla 5.0 browser is released -- and this is expected to be within a few weeks -- users should begin to have some fun customizing their browser interface with more control than ever before.

Included in the list of future improvements is server-cached XUL, which automatically updates a UI on launch, or on request. I believe we're also destined to see extensions to XUL that make it a more complete application programming environment, with more ways to tie into the functionality of other apps.


Also at XTech 2000: Behlendorf Urges XML Developers to Support Apache Tools

Copyright © 2009 O'Reilly Media, Inc.