DOM implementation

The DOMImplementation interface defines a single method, called hasFeature, which is used to determine the extent of DOM support that the application/parser has. This method returns a boolean value, with 'true' indicating support for the given feature:

boolean hasFeature( String feature, String version);

It can be called a number of times, each time testing for support for a particular feature, or 'module'. The name of the module is passed as the first parameter. In DOM Level 1, this method can be called to test for support for 'Core' DOM features, and for additional 'XML' or 'HTML' features.

It is also necessary to check which version of the DOM is supported in each case, and the DOM version is therefore passed as the second parameter. For the version described in this chapter, DOM Level 1, the string '1.0' is used. For DOM Level 2 (see Chapter 21), the string '2.0' is used. DOM Level 2 has more modules, and also more powerful capabilities in some of the existing modules ('Core' support in Level 2 is more sophisticated than 'Core' support in Level 1).

The following example tests for DOM Level 1 support for XML additional features (CDATA sections, document types, notations, entity references and processing instructions):

if ( theParser.hasFeature( "XML", "1.0" )
{
  // DOM Level 1 (1.0) support for XML is available
  ...
}

The following table shows all the interfaces, and the modules they are found in. Note that a number of Core interfaces are optional, in the sense that they are not needed if working with HTML instead of XML. To ensure that these are present, the test for XML support must be carried out:

Exception or Interface Core XML HTML
DomException Yes   
DocumentFragment Yes   
Document Yes   
Node Yes   
NodeList Yes   
NamedNodeMap Yes   
CharacterData Yes   
Attr Yes   
Element Yes   
Text Yes   
Comment Yes   
CDATASection Optional Yes  
DocumentType Optional Yes  
Notation Optional Yes  
Entity Optional Yes  
EntityReference Optional Yes  
ProcessingInstruction Optional Yes  
HTMLDomImplementation   Yes
HTMLCollection   Yes
HTMLDocument   Yes
HTMLElement   Yes
HTMLAnchorElement   Yes
HTMLAppletElement   Yes
HTMLAreaElement   Yes
HTMLBaseElement   Yes
HTMLBaseFontElement   Yes
HTMLBodyElement   Yes
HTMLBRElement   Yes
HTMLButtonElement   Yes
HTMLDirectoryElement   Yes
HTMLDivElement   Yes
HTMLDListElement   Yes
HTMLFieldElement   Yes
HTMLFontElement   Yes
HTMLFormElement   Yes
HTMLFrameElement   Yes
HTMLFrameSetElement   Yes
HTMLHeadElement   Yes
HTMLHeadingElement   Yes
HTMLHRElement   Yes
HTMLHtmlElement   Yes
HTMLIFrameElement   Yes
HTMLImageElement   Yes
HTMLInputElement   Yes
HTMLIsIndexElement   Yes
HTMLLabelElement   Yes
HTMLLegendElement   Yes
HTMLLIElement   Yes
HTMLLinkElement   Yes
HTMLMapElement   Yes
HTMLMenuElement   Yes
HTMLMetaElement   Yes
HTMLModElement   Yes
HTMLObjectElement   Yes
HTMLOListElement   Yes
HTMLOptGroupElement   Yes
HTMLOptionElement   Yes
HTMLParagraphElement   Yes
HTMLParamElement   Yes
HTMLPreElement   Yes
HTMLQuoteElement   Yes
HTMLScriptElement   Yes
HTMLSelectElement   Yes
HTMLStyleElement   Yes
HTMLTableCaptionElement   Yes
HTMLTableCellElement   Yes
HTMLTableCollElement   Yes
HTMLTableElement   Yes
HTMLTableRowElement   Yes
HTMLTableSectionElement   Yes
HTMLTextAreaElement   Yes
HTMLTitleElement   Yes
HTMLUListElement   Yes

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.145.114