Firefox is a relatively new Web browser and currently the most popular browser built on the Mozilla platform. You've probably heard of it because of its phenomenal growth and its profile as an open source software success story. Perhaps it's even your Web browser of choice, as it is mine. IBM made news earlier this year by encouraging its employees to use Firefox and by standardizing Firefox support with its enterprise help desk. IBM has also been improving Firefox support throughout its product line, including Lotus® Domino®. Other enterprises, impressed by the confidence shown by such a prominent IT company, are moving their internal standards toward Firefox.
One of the advantages of Firefox is that it inherits many XML features from Mozilla. Many of these features have historically been offered partially or tentatively in Mozilla (and Firefox), but in the 1.5 release Firefox made a big leap in the number and quality of XML features. Firefox 1.5 is a good Web browser for XML developers and should help drive the adoption of client-side XML features that have been slow to spread on the Web. It's important to keep in mind that many current developments in Web technologies -- including developments in Firefox browser features -- are making the Web browser an increasingly complete platform for specialized applications development, rather than just a simple tool for browsing the Internet. XML generally plays a significant role in these technological developments, which some commentators refer to as Web 2.0.
In this series, you'll learn about the various XML features in Firefox 1.5. This first article gives you an overview of these features. See Resources for more information about how to grab a copy of Firefox for your own use and development.
From the days of the pioneering Web browser NCSA Mosaic, the role of a browser has been to retrieve the various files that make up a Web page and organize them for user display. The most common formats for such files have been HTML and various binary image formats. XML was originally intended to be SGML on the Web, and its advent has brought with it all sorts of new XML-based formats that Web browsers have had to properly parse and display. The most basic task for an XML-aware browser is for it to be able to prioritize which format is the most important, and Firefox is no slouch in this department.
Mozilla (and thus Firefox) has been able to parse plain XML (including namespaces) in nonvalidating mode for years. By default, it simply displays a simplified view of the XML, telling the user:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
You can embed portable xml:stylesheet processing instructions in the XML to instruct Firefox to load a CSS stylesheet or XSLT transform (both are discussed in a moment) and automatically display the result to the user instead of the original XML. In this case, the browsers's "view source" feature displays the original XML. One drawback of Mozilla is that it parses large XML documents completely before passing data to the rendering engine, which means that such documents can be slow to load. Mozilla developers have discussed adding incremental XML loading support for several years, but as of 1.5 such capability is not in place. Firefox does not support DTD validation or any of the other validation technologies such as W3C XML Schema (WXS) or RELAX NG. It does support enough of XLink (simple links only) to allow you to express the same sorts of links in XML that you might in HTML. Firefox also supports XML Base, a specification that allows you to set the base URI for resolving relative URIs in XLinks. Links can lead to fragments of documents using the FIXPtr variation on W3C's XPointer or a subset of an older draft of the XPointer specification.
Mozilla Firefox 1.0 supports XHTML 1.0 Strict, Transitional, and Frameset, as well as XHTML 1.1 which is based on modularization of XHTML 1.0 Strict. XHTML 2.0 is still in the working draft stage. Some developers wonder how well XHTML 2.0 will be adopted because it's such a significant change from HTML and XHTML 1.x. I recommend that Web developers targeting Firefox (such as for embedded applications) serve XHTML 1.1. Unfortunately, this may not yet be practical for developers targeting the general Web. I don't intend to discuss XHTML much more in this series, but I do have a full tutorial about XHTML 1.1 on the developerWorks site. (See Resources.)
My colleague, Kurt Cagle, shares his observations about XHTML support:
There are some subtle differences in the layout model of XHTML
within Gecko compared to HTML, including the fact that CSS applied to
the body only covers the region within the document margins -- to do
a full page background, you have to assign the CSS to the
<html> element itself. [Also], Firefox XHTML supports compound document subparts, making it useful to integrate HTML and SVG content, for example.
Cascading Stylesheets are the prevalent means of rendering XML in a Web browser. Of course, they're also heavily used for HTML style as well, and the technology has always received strong support in Firefox (as in most browsers). CSS 2.0 is a complete recommendation of the W3C, and Firefox 1.0 supports most of the spec. A working draft of CSS 2.1 offers a relatively minor set of revisions to 2.0. CSS 2.0 and 2.1 are collectively called CSS2. Firefox 1.5 improves the CSS2 support and also adds more support for CSS3, which is currently still in working draft stage at the W3C. CSS3 is seeing early adoption because it addresses many pressing needs of Web developers, including better support for XML constructs. Later in the series, I discuss CSS, but I also recommend my series of tutorials (available on developerWorks) about using CSS with XML (see Resources). These resources also include practical demonstration of some of the limitations of Firefox's CSS2 support, most of which is fixed in Firefox 1.5.
Scalable Vector Graphics (SVG)
SVG is the W3C specification providing an XML-based image format. SVG images are portable, resolution-independent, and surprisingly compact -- despite being represented in XML (the result of a few XML design compromises). The feature set includes nested transformations, clipping paths, alpha masks, raster filter effects, template objects, and (of course) extensibility. SVG also supports animation through a module of Synchronized Multimedia Integration Language (SMIL), zooming and panning views, a wide variety of graphic primitives, grouping, scripting, hyperlinks, structured metadata, and easy embedding in other XML documents. SVG works in other XML and Web-related technologies such as CSS and Document Object Model (DOM). Mozilla has had optional and sketchy SVG support for a long while now, but no one put in the effort to get it polished and built-in by default until Firefox 1.5 arrived with out-of-the-box, native SVG support (specifically a subset of SVG 1.1 Full). Some of the features missing in 1.5 are declarative SMIL animation (animation is only possible through scripting), filters, text paths, masks, patterns, and SVG defined fonts. Firefox transparently displays resources served with the MIME-type image/svg+xml as SVG, with no special plug-ins required; this includes SVG images embedded in object elements.
MathML is the W3C's XML vocabulary for representing mathematical information. It allows you to express mathematics either with conventions that focus on the abstract mathematical meaning (content markup) or with conventions focused on how it should be displayed (presentation markup). The specification is currently at version 2.0 and Firefox supports this version, either stand-alone or embedded within XHTML. Be warned that users may need to add some fonts to their systems to view MathML documents.
canvas is an element that serves as a scriptable, bitmap drawing surface. The uses are almost endless: games, flashy business presentation graphics, specialized forms controls, simulations, and complex data visualization -- just to name a few possibilities. You define the fixed size of the canvas in the element itself, and then typically you do the actual drawing from a script that uses the canvas API to create visual objects on the canvas. canvas was first developed by Apple for their Safari browser as a foundation for complex graphics facilities such as SVG support. Mozilla picked up the idea, and canvas is now a specification of the WhatWG consortium of browser vendors. Mozilla's canvas currently supports only two-dimensional graphics, but 3D might be on the horizon if OpenGL facilities are made available for the Mozilla platform.
Web browsers have long offered dynamic features so that developers could offer more than simple, static pages. With the trend toward complex Web applications, such features have become even more complex and many of them build on XML in some way. JavaScript (or ECMAScript in its international standard form) is a powerful, dynamic language that forms the basis of most dynamic features in Web browsers.
E4X is a standard that adds native XML datatypes to the ECMAScript language and provides operators for common XML operations. To quote the E4X specification page:
E4X adds native XML datatypes to the ECMAScript language, extends the semantics of familiar ECMAScript operators for manipulating XML objects, and adds a small set of new operators for common XML operations, such as searching and filtering. It also adds support for XML literals, namespaces, qualified names, and other mechanisms to facilitate XML processing.
E4X is probably used most often as a way to parse XML into ECMAScript objects that can be very easily manipulated. This does create some sticky issues because its direct use of XML syntax means it can cause a bit of confusion when embedded in other tag-based formats. In fact, in Firefox 1.5, E4X was disabled by default on HTML pages because it interfered with the traditional way of hiding scripts from noncompatible browsers. However, Web page authors can enable it within any script element by using an attribute of the form type="text/javascript; e4x=1".
Mozilla has supported XSLT for nearly five years and in recent years, that support has been fairly reliable, including the ability to invoke XSLT transforms from ECMAScript. Firefox doesn't include any major changes to the workings of XSLT in Mozilla. It would be nice to at least have support for EXSLT extensions, but this is not on the roadmap -- although it has been a topic of discussion and might be a future possibility.
XForms is a specification of Web forms for XML data processing that can be used with a wide variety of platforms through various media. XForms looks to separate a form's purpose from its presentation; that is, what the form does from how it looks. An XML vocabulary can be used to develop form UIs for manipulating XML content. XForms serves as the forms module for XHTML 2.0, but is a stand-alone W3C recommendation. It's more complex than the familiar HTML forms elements, but it can be used to produce much more sophisticated and portable forms. There was some resistance to XForms support in Mozilla because of its complexity, but in August 2004, IBM and Novell offered resources, and the Mozilla Foundation launched a project to implement XForms in Mozilla. The fruit of this labor is available in Firefox as an extension. Firefox also adds support for XML Events, a W3C specification, related to XForms, for listening for events related to the manipulation of XML objects, and for handling such events. As an example, an XML event would be raised when a user changes the text in an XForms-based text entry field.
eXtensible Tag Framework (XTF)
XTF is a Mozilla-specific technology that allows extension authors to create new XML namespaces in Mozilla, using code that they write in ECMAScript or C++ (technically, they can write in any language with support for the Mozilla component system, XPCOM). In fact, XTF is what the Mozilla XForms Project uses to add support for elements in the XForms namespace. XTF promises to be a powerful way to add all sorts of XML technologies to Mozilla without having to wait for support in the core.
Firefox allows you to access XML Web services from ECMAScript. There are components for SOAP 1.1, WSDL 1.1, and XML-RPC. In this way, you can incorporate features that are available through messages from remote service providers.
Firefox: The complete XML-based browser workbench
For some people, the crown jewel of Mozilla's XML capabilities is XML User Interface Language (XUL), a markup language for describing cross-platform user interfaces. XUL is designed for the Mozilla platform but intended for more general use. The best way to think about XUL is to imagine all the various bits and pieces that appear in a Web browser: a main rendering area, menus, icons and buttons, a URL bar, title bars, status bars, sidebars, dialog boxes, and so forth. XUL allows you to create, arrange, and activate all these components. In fact, the full Mozilla Web browser was written as an XUL application. An XUL application is specified in XML where each component is defined. Firefox 1.5 brings some important enhancements to XUL, including dynamic overlays and translucent backgrounds, which increases your flexibility in combining and presenting XUL components. XUL works closely with another XML-based declaration language, Extensible Binding Language (XBL), which allows you to specify special behavior for components expressed in XUL. Mozilla also uses Resource Description Framework (RDF) to manage semi-structured data used in XUL. RDF is a metadata system with an XML serialization for the Web, a model for describing collections of formalized statements about a Web resource.
You can see how broad and deep Firefox's XML support is. In this article, you viewed a high-altitude map of these features. In forthcoming articles, you'll get more detail about much of this territory, with snippets of working code for Firefox. This is a particularly exciting time for XML developers since XML is driving the next generation of Web technology, and Firefox users stand poised to take advantage of these developments.
Thanks to Kurt Cagle, for providing assistance with this article.
Learn
- If you want to keep an eye on the development of Firefox beyond 1.5, the best source is the Firefox roadmap page.
- Many of the XML technologies mentioned in this article are covered in "A survey of XML standards: Part 4," by Uche Ogbuji (developerWorks, March 2004), which provides a detailed cross reference of the most important XML standards.
- Read about IBM's adoption of Firefox and the more general initiative for increasing Firefox adoption at Spread Firefox.
- Learn about SVG from the tutorial "Introduction to Scalable Vector Graphics," by Nicholas Chase (developerWorks, March 2004), which provides many examples. Find out more about SVG in Mozilla (and thus Firefox) in the Mozilla SVG FAQ. If you really want the in-depth details, check out the Mozilla SVG Status page.
- Learn about MathML from "A Gentle Introduction to MathML," by Robert Miner and Jeff Schaeffer. If interested, go on to "MathML: Presenting and Capturing Mathematics for the Web (PDF)," by Michael Kohlhase for greater depth. Learn about Mozilla's implementation on the project page, but be aware that this page is out of date.
- See the announcement of the Mozilla/XForms project.
- Check out the XTF project page to learn about this new capability that allows you to create an extension to handle whatever XML you like.
- Read more about canvas at the Mozilla Developer Center: Drawing Graphics with Canvas.
- Learn more about XUL, XBL, and how RDF is used in Mozilla.
- Find more XML resources on the developerWorks XML zone. If you're looking for more about Web-related technologies, check out the Web architecture zone.
- Find out how you can become an IBM Certified Developer in XML and related technologies.
- Refer to the W3C HTML Home Page for information about all versions of XHTML. Uche Ogbuji's developerWorks tutorial "XHTML, step by step" (September 2005) is another great place to get started with the technology.
- Take a closer look at Cascading Stylesheets. Read Uche Ogbuji's three-part tutorial series "Use Cascading Stylesheets to display XML":
- Part 1 (November 2004) shows you how to use CSS to display XML in browsers.
- Part 2 (February 2005) builds on the basics in Part 1 to cover more intermediate and advanced topics.
- Part 3 (June 2005) covers techniques for using XSLT to process XML in association with CSS.
Get products and technologies
- Get Firefox, the Mozilla-based Web browser that offers standards compliance, performance, security, and solid XML features.

Uche Ogbuji is a consultant and co-founder of Fourthought Inc., a software vendor and consultancy specializing in XML solutions for enterprise knowledge management. Fourthought develops 4Suite, an open source platform for XML, RDF, and knowledge-management applications. Mr. Ogbuji is also a lead developer of the Versa RDF query language. He is a computer engineer and writer born in Nigeria, living and working in Boulder, Colorado, USA. You can find more about Mr. Ogbuji at his Weblog Copia or contact him at uche@ogbuji.net.