by Ian Oeschger
   Other articles in this feature:

XHTML: The Clean Code Solution

Extensible Graphics with SVG

The X-Acronyms

What Does XUL Have to Do With XML?

XUL Syntax and Rules

XUL (eXtensible User-Interface Language)is a standards-based interface definition language. It attempts to balance precise control of layout with flexibility and ease of use, and in this respect it does a great job. Using a combination of XUL's ready-made widgets (for example, menubar, scrollbar, progress meter, and so on) and XUL's incorporation of such standards as HTML 4.0, DOM 1 and 2, and Cascading Style Sheets, you can design any interface that you can imagine, using any number of different features, tools, and methodologies.

There are many times, for example, when you may use JavaScript tricks to add extra behavior. But the necessary tradeoff for XUL's flexibility is a lack of implicit functionality -- the lack of intuition, you might say, that XUL has in interpreting what it is you want. In order to provide flexibility to you as a designer of interfaces, XUL offers no flexibility to you as a coder. You must be very careful about your syntax, and in particular about these four cardinal rules of XUL:

Topics in this article:

• XUL Syntax & Rules

• XML Made XUL

• Gecko Reads XUL

  • All events and attributes must be written in lowercase.
    Unlike HTML, XUL is very sensitive to case. All of the events and attributes -- even the JavaScript event listeners normally formatted in the JavaScript world with uppercase verbs (such as onClick and onLoad) -- must be lowercase or they are invalid.

  • All strings must be double quoted.
    All of the values for all of the attributes declared in XUL are strings. When an attribute is assigned a value (for example, flex="1" or "onload='doInterestingStartupThing()'") that value must be double-quoted.

  • Every XUL widget must use close tags to be well-formed
    HTML allows some elements, such as <br> and <hr>, to be neither closed nor matched with a closing element. In XUL, elements must either be of the form <tag></tag> or <tag /> to be valid. For example, <html:img src="box.gif" /> is valid, but <html:img src="box.gif"> is not.

  • All attributes must have a value.

XUL Is Made Out of XML

You don't need to know all about XML in order to use XUL, but you may want to read through this article to get a sense of XUL's pedigree as a specialized markup language. XUL is based upon XML, so it inherits a lot of the rules and syntax described above from this "meta-language," as you will see. Any familiarity you already have with XML will help you quickly get up to speed developing with XUL.

Pages: 1, 2

Next Pagearrow