Home | History | Annotate | Download | only in domts
      1 /*
      2  * Copyright (c) 2002 World Wide Web Consortium,
      3  * (Massachusetts Institute of Technology, Institut National de
      4  * Recherche en Informatique et en Automatique, Keio University). All
      5  * Rights Reserved. This program is distributed under the W3C's Software
      6  * Intellectual Property License. This program is distributed in the
      7  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
      8  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
      9  * PURPOSE.
     10  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
     11  */
     12 
     13 package org.w3c.domts;
     14 
     15 import org.w3c.dom.DOMException;
     16 import org.w3c.dom.DOMImplementation;
     17 import org.w3c.dom.Document;
     18 import org.w3c.dom.DocumentType;
     19 
     20 /**
     21  *   JTidy does not implement DOMImplementation
     22  *    we do it here to keep the test exclusion logic
     23  *    from falling apart.
     24  */
     25 public class JTidyDOMImplementation
     26     implements DOMImplementation {
     27 
     28   /**
     29    * Test if the DOM implementation implements a specific feature.
     30    * @param feature The name of the feature to test (case-insensitive). The
     31    *   values used by DOM features are defined throughout the DOM Level 2
     32    *   specifications and listed in the  section. The name must be an XML
     33    *   name. To avoid possible conflicts, as a convention, names referring
     34    *   to features defined outside the DOM specification should be made
     35    *   unique.
     36    * @param version This is the version number of the feature to test. In
     37    *   Level 2, the string can be either "2.0" or "1.0". If the version is
     38    *   not specified, supporting any version of the feature causes the
     39    *   method to return <code>true</code>.
     40    * @return <code>true</code> if the feature is implemented in the
     41    *   specified version, <code>false</code> otherwise.
     42    */
     43   public boolean hasFeature(String feature,
     44                             String version) {
     45     if (feature.equals("Core")) {
     46       return version == null || version.equals("1.0") || version.equals("2.0");
     47     }
     48     return false;
     49   }
     50 
     51   /**
     52    * Creates an empty <code>DocumentType</code> node. Entity declarations
     53    * and notations are not made available. Entity reference expansions and
     54    * default attribute additions do not occur. It is expected that a
     55    * future version of the DOM will provide a way for populating a
     56    * <code>DocumentType</code>.
     57    * @param qualifiedName The qualified name of the document type to be
     58    *   created.
     59    * @param publicId The external subset public identifier.
     60    * @param systemId The external subset system identifier.
     61    * @return A new <code>DocumentType</code> node with
     62    *   <code>Node.ownerDocument</code> set to <code>null</code>.
     63    * @exception DOMException
     64    *   INVALID_CHARACTER_ERR: Raised if the specified qualified name
     65    *   contains an illegal character.
     66    *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
     67    *   malformed.
     68    *   <br>NOT_SUPPORTED_ERR: May be raised by DOM implementations which do
     69    *   not support the <code>"XML"</code> feature, if they choose not to
     70    *   support this method. Other features introduced in the future, by
     71    *   the DOM WG or in extensions defined by other groups, may also
     72    *   demand support for this method; please consult the definition of
     73    *   the feature to see if it requires this method.
     74    * @since DOM Level 2
     75    */
     76   public DocumentType createDocumentType(String qualifiedName,
     77                                          String publicId,
     78                                          String systemId) throws DOMException {
     79     throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not Implemented");
     80   }
     81 
     82   /**
     83    * Creates a DOM Document object of the specified type with its document
     84    * element.
     85    * @param namespaceURI The namespace URI of the document element to
     86    *   create.
     87    * @param qualifiedName The qualified name of the document element to be
     88    *   created.
     89    * @param doctype The type of document to be created or <code>null</code>.
     90    *   When <code>doctype</code> is not <code>null</code>, its
     91    *   <code>Node.ownerDocument</code> attribute is set to the document
     92    *   being created.
     93    * @return A new <code>Document</code> object.
     94    * @exception DOMException
     95    *   INVALID_CHARACTER_ERR: Raised if the specified qualified name
     96    *   contains an illegal character.
     97    *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
     98    *   malformed, if the <code>qualifiedName</code> has a prefix and the
     99    *   <code>namespaceURI</code> is <code>null</code>, or if the
    100    *   <code>qualifiedName</code> has a prefix that is "xml" and the
    101    *   <code>namespaceURI</code> is different from "
    102    *   http://www.w3.org/XML/1998/namespace" , or if the DOM
    103    *   implementation does not support the <code>"XML"</code> feature but
    104    *   a non-null namespace URI was provided, since namespaces were
    105    *   defined by XML.
    106    *   <br>WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has already
    107    *   been used with a different document or was created from a different
    108    *   implementation.
    109    *   <br>NOT_SUPPORTED_ERR: May be raised by DOM implementations which do
    110    *   not support the "XML" feature, if they choose not to support this
    111    *   method. Other features introduced in the future, by the DOM WG or
    112    *   in extensions defined by other groups, may also demand support for
    113    *   this method; please consult the definition of the feature to see if
    114    *   it requires this method.
    115    * @since DOM Level 2
    116    */
    117   public Document createDocument(String namespaceURI,
    118                                  String qualifiedName,
    119                                  DocumentType doctype) throws DOMException {
    120     throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not Implemented");
    121   }
    122 
    123   public DOMImplementation getInterface(String feature) {
    124     return this;
    125   }
    126 
    127   public Object getFeature(String feature, String version) {
    128     return null;
    129   }
    130 
    131 }
    132