Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Mozilla中的XML

Mozilla has 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.

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 <tt><bin>/res/dtd</tt> 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 CVS server: 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 netscape.public.mozilla.dom newsgroup, while style issues should be discussed on netscape.public.mozilla.style and so on. The catch-all newsgroup for XML discussion is netscape.public.mozilla.xml.

Specification or technology Status and/or further documentation
XML 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

Other Supported XML W3C Recommendations

Specification or Technology Documentation
XHTML W3C Recommendation
XML Base (for links only, not used for :visited etc. CSS properties) W3C Recommendation
XLink (simple XLinks only) W3C Recommendation
FIXptr W3C "proposal"
XPointer Framework W3C Recommendation
XPointer element() scheme W3C Recommendation
XPointer xmlns() scheme W3C Recommendation
XPointer fixptr() scheme This scheme is simply a wrapper for FIXptr
XPointer xpath1() scheme 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 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 https://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 (used only when you mouse over a link or click a link) and simple XLinks. You can make any XML element into an XLink by using the XLink namespace https://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/public/idl/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 the W3C DOM Level 3 Load & Save module. Mozilla currently implements only the load() method and the async property. Since 1.4alpha it has been possible to load documents synchronously, before that it was only asynchronous. See the load sample in the XML tests directory. (Loading the load.html file from the LXR generated page will not work because LXR will munge the test.xml file into HTML and serve it as HTML. To test this functionality, create the files on your local disk or on a webserver.)

Outside Supported XML W3C Recommendations

Specification or Technology Documentation Mozilla Project
XSLT W3C Recommendation XSLT
XPath W3C Recommendation XSLT
XMLHttpRequest Microsoft XML Extras
DOMParser and XMLSerializer Mozilla XML Extras
SOAP W3C Note Web Services
XML-RPC UserLand Software XML-RPC
RDF W3C Recommendations RDF
SVG W3C Proposed Recommendation SVG
MathML W3C Recommendation MathML
P3P W3C Recommendation P3P
WSDL W3C Note Web Services
XBL W3C Note (by Mozilla) XBL
XUL Mozilla XPToolkit

Roadmap

Next big tasks would include support for XPointer xpointer() scheme (bug 32832), full XLink support (bug 61664), XInclude, XML Catalogs (bug 98413), XForms (bug 97806), validating parser (bug 196355), XML Schemas and incremental layout of XML document (bug 18333), and a SAX API (bug 315825).

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 CVS server 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).

We have bugs open to make NIST DOM (bug 51247) and NIST XML test suites to work in Mozilla - they currently do not work.

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.

文档标签和贡献者

标签: 
 此页面的贡献者: Mgjbot, Emcc, Kakurady, Dbseti
 最后编辑者: Mgjbot,