XML in Mozilla

Mozilla has a relatively good support for XML. Several World Wide Web Consortium (W3C) Recommendations and drafts from the XML family of specifications are supported, as well as other related technologies.

This page is outdated. Please help updating it with current information.

Supported Core XML W3C Recommendations

The core XML support includes parsing XML without validation (we use the Expat parser), displaying XML with CSS, manipulating XML documents with scripts via DOM, associating stylesheets with XML documents, and namespaces in XML. The core support is very good with few bugs.

DTDs and Other External Entities

Mozilla does not load external entities from the web.

Mozilla can load external entities whose system identifier uses the chrome protocol. This feature is used mainly to localize Mozilla to different languages (the UI strings are stored in external DTD files). Another exception is an entity whose system identifier is a relative path, and the XML declaration states that the document is not standalone (default), in which case Mozilla will try to look for the entity under <bin>/res/dtd directory.

Mozilla may also make an exception with XHTML documents, see below.

Mozilla will read internal (DTD) subsets, and in special circumstances external DTDs as explained above and will use this information to recognize ID type attributes, default attribute values, and general entities.

Other Notes

A lot of the Document Object Model (DOM, W3C Recommendations and drafts) applies to XML. Likewise, the Cascading Style Sheets (CSS, W3C Recommendations and drafts) style language can be used to style XML documents.

The code for most the core XML can be found in the following directories on the Mozilla mercurial repository: content/xml/, parser/expat/ and parser/htmlparser/.

The newsgroup to discuss XML in Mozilla depends a bit on the nature of the question. For example, DOM related questions should probably be discussed in the mozilla.dev.tech.dom newsgroup, while style issues should be discussed on mozilla.dev.tech.css and so on. The catch-all newsgroup for XML discussion is mozilla.dev.tech.xml.

Specification or technology Status and/or further documentation
XML 1.0 W3C Recommendation
Namespaces in XML W3C Recommendation
Associating Stylesheets with XML Documents W3C Recommendation
Styling XML Documents with CSS  
Manipulating XML documents with scripts through DOM  
Serializing XML DOM trees to Javascript Object trees (JXON)  

Other Supported XML W3C Recommendations

Specification or Technology Documentation
XHTML W3C Recommendation
XML Base W3C Recommendation
XLink (simple XLinks only) Obsolete since Gecko 2.0 W3C Recommendation
FIXptr Obsolete since Gecko 1.9.1 W3C "proposal"
XPointer Framework Obsolete since Gecko 1.9.1 W3C Recommendation
XPointer element() scheme Obsolete since Gecko 1.9.1 W3C Recommendation
XPointer xmlns() scheme Obsolete since Gecko 1.9.1 W3C Recommendation
XPointer fixptr() scheme Obsolete since Gecko 1.9.1 This scheme is simply a wrapper for FIXptr
XPointer xpath1() scheme Obsolete since Gecko 1.9.1 Internet-Draft
document.load(), document.async Part of DOM Level 3 Load & Save module, a W3C Working Draft

XHTML

We have reasonable XHTML support, most things should work. We treat XHTML documents differently depending on the mime type (or file suffix if files are loaded from local discs). Files that go through the HTML code path are not checked for well-formedness. You will also notice not all XHTML features are supported when you exercise the HTML code path.

MIME Type File Suffix Code Path
text/xml
application/xml
application/xhtml+xml
xml
xht
xhtml
XML
text/html html
htm
HTML

The entire document need not be XHTML. You can use XHTML elements inside an arbitrary XML document by using the XHTML namespace. See the Testing and QA section for samples. The correct XHTML namespace is http://www.w3.org/1999/xhtml

Please note that the XHTML entities, like &auml;, work only in conforming XHTML documents that have a valid XHTML Formal Public Identifier (or in other words, a DOCTYPE section with a PUBLIC identifier). XHTML entities will not work in arbitrary XML documents, not even if the XHTML namespace is used. The public identifiers that are recognized are:

-//W3C//DTD XHTML 1.0 Transitional//EN
-//W3C//DTD XHTML 1.1//EN
-//W3C//DTD XHTML 1.0 Strict//EN
-//W3C//DTD XHTML 1.0 Frameset//EN
-//W3C//DTD XHTML Basic 1.0//EN
-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN
-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN
-//W3C//DTD SVG 20001102//EN
-//WAPFORUM//DTD XHTML Mobile 1.0//EN

XML Linking and Pointing

XML Linking support includes XML Base and simple XLinks. You can make any XML element into an XLink by using the XLink namespace http://www.w3.org/1999/xlink. You can also use the linking elements from the XHTML namespace. See the Testing and QA section for samples.

For pointing into resources in XML documents Mozilla also supports FIXptr, a simplified, non-compatible version of XPointer. In addition to using FIXptr in links, it is possible to use it from scripts. See the proprietary dom/interfaces/core/nsIDOMXMLDocument.idl interface. There is test case for FIXptr links and a scripting example.

Since 1.4alpha, Mozilla also supports XPointer Framework, XPointer element() scheme, XPointer xmlns() scheme, XPointer fixptr() scheme and XPointer xpath1() scheme. The XPointer processor is extensible and it is easy to implement support for other schemes - have a look at the API. The xpath1() scheme was implemented using this extensible mechanism. There is also a proprietary API from scripts to the XPointer processor. There is a testcase for XPointers that you can also study.

Lastly, there is a pref you might want to try (especially useful with FIXptr) that will select the link target when you traverse it. There is no UI for setting this pref yet, so you will need to manually edit the preferences file. Add this line:

pref("layout.selectanchor", true);

DOM Load and Save Methods

document.load() is a part of an old version of the W3C DOM Level 3 Load & Save module. Mozilla currently implements only the load() method and the document.async property.

Outside Supported XML W3C Recommendations

Specification or Technology Documentation Mozilla Project
XSLT W3C Recommendation XSLT
XPath W3C Recommendation XSLT
XMLHttpRequest W3C Recommendation XML Extras
Request API (no longer supported) Mozilla Add-on SDK
DOMParser and XMLSerializer Mozilla XML Extras
SAX SAX  
SOAP (no longer supported) W3C Note Web Services
XML-RPC (no longer supported) UserLand Software XML-RPC
RDF W3C Recommendations RDF
SVG W3C Recommendation  
SVG animation (SMIL) W3C Recommendation  
MathML W3C Recommendation MathML
P3P (no longer supported) W3C Recommendation P3P
WSDL (no longer supported) W3C Note Web Services
XBL Mozilla's XBL reference  
XUL Mozilla's XUL reference  

Roadmap

Next big tasks would include support for XPointer xpointer() scheme (bug 32832), XInclude (bug 201754), XML Catalogs (bug 98413), XForms (bug 97806; work being done on implementing this as an extension), validating parser (bug 196355) and XML Schemas.

To fully implement XLink, we need something called a link manager. See some initial design documents.

Testing and QA

We have a lot of testcases linked to from the browser standards compliance QA page.

Most of the core XML test documents on the mercurial repository are located in content/xml/tests. We also have a couple online: the books demo and the IRS table of contents demo. Both of them demonstrate XML, Associating stylesheets with XML, displaying XML with CSS, Namespaces in XML, XHTML, simple XLinks, and manipulation of XML with scripts via DOM.

There is an XML component in Bugzilla.

We also have the "xhtml" keyword for XHTML bugs (these tend to be scattered across components).

How can I help?

If you can code, look for helpwanted keyword in XML bugs. We don't use that always, so if you want to avoid doing duplicate work you could start working on bugs that have Future milestone, or otherwise have a milestone that is set way into the future.

You can always test our XML support. We'd really like to get tests that can be run automatically (this would require knowledge of web development; document.load() and/or XML Extras might be needed), but probably most of the bugs we get have just been found by normal people trying to do something that works in some other browser and does not work in Mozilla.

See also

Document Tags and Contributors

 Last updated by: ethertank,