Next / Previous / Contents / TCC Help System / NM Tech homepage

10. The DOMImplementation object

In module Ft.Xml.Domlette, there is a variable named implementation that contains a DOMImplementation object. This object contains two methods used to create an entirely new document as a DOM tree.

To get this object, use this form of import:

import Ft.Xml.Domlette as domlette

Then you can get the DOMImplementation object from “domlette.implementation”.

These methods both return a new Document object.

10.1. DOMImplementation.createDocument()

Given a DOMImplementation object I, this is a convenient method that creates a new Document instance and its root Element child:

I.createDocument(nsURI, qName, docType)

where the arguments are:

nsURI

The namespace URI of the root element, if any. See Section 2.6, “Namespace URI”. Use None if the document is in the default (blank) namespace.

qName

The qualified name of the root element to be created. See Section 2.7, “qName: Qualified name”.

This element will be available in the .documentElement attribute of the returned Document object.

If you are generating a document that uses namespace prefixes, it is your responsibility to be consistent about which namespace prefix corresponds to which namespace URI.

docType

In the official DOM specification, this argument is supposed to be a DocumentType object containing the document's public and/or system identifier. However, at present, 4Suite does not support this feature. For now, always pass None to this argument.

If you want your document to have a <!DOCTYPE ...> declaration, see the .publicId and .systemId attributes in Section 6, “The Document class”.

The drawback to this method is that you can't specify the document's base URI (see Section 2.5, “Base URI”). If your document will have relative references in it, see Section 10.2, “DOMImplementation.createRootNode().