| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.dom; |
| 9 | |
| 10 | import org.w3c.dom.DOMException; |
| 11 | import org.w3c.dom.DOMImplementation; |
| 12 | import org.w3c.dom.Document; |
| 13 | import org.w3c.dom.DocumentType; |
| 14 | |
| 15 | /** |
| 16 | * A simple implementation of the DOMImplementation interface, for use when accessing |
| 17 | * Saxon tree structure using the DOM API. |
| 18 | */ |
| 19 | |
| 20 | class DOMImplementationImpl implements DOMImplementation { |
| 21 | |
| 22 | /** |
| 23 | * Test if the DOM implementation implements a specific feature. |
| 24 | * |
| 25 | * @param feature The name of the feature to test (case-insensitive). |
| 26 | * @param version This is the version number of the feature to test. |
| 27 | * @return <code>true</code> if the feature is implemented in the |
| 28 | * specified version, <code>false</code> otherwise. This implementation |
| 29 | * returns true if the feature is "XML" or "Core" and the version is null, |
| 30 | * "", "3.0", "2.0", or "1.0". |
| 31 | */ |
| 32 | |
| 33 | public boolean hasFeature(String feature, String version) { |
| 34 | return (feature.equalsIgnoreCase("XML") || feature.equalsIgnoreCase("Core")) && |
| 35 | (version == null || version.isEmpty() || |
| 36 | version.equals("3.0") || version.equals("2.0") || version.equals("1.0")); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * This method returns a specialized object which implements the |
| 41 | * specialized APIs of the specified feature and version, as specified |
| 42 | * in . |
| 43 | * |
| 44 | * @param feature The name of the feature requested. |
| 45 | * @param version This is the version number of the feature to test. |
| 46 | * @return Always returns null in this implementation |
| 47 | * @since DOM Level 3 |
| 48 | */ |
| 49 | |
| 50 | public Object getFeature(String feature, |
| 51 | String version) { |
| 52 | return null; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | /** |
| 57 | * Creates an empty <code>DocumentType</code> node. |
| 58 | * |
| 59 | * @param qualifiedName The qualified name of the document type to be |
| 60 | * created. |
| 61 | * @param publicId The external subset public identifier. |
| 62 | * @param systemId The external subset system identifier. |
| 63 | * @return A new <code>DocumentType</code> node with |
| 64 | * <code>Node.ownerDocument</code> set to <code>null</code> . |
| 65 | * @throws org.w3c.dom.DOMException INVALID_CHARACTER_ERR: Raised if the specified qualified name |
| 66 | * contains an illegal character. |
| 67 | * <br> NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is |
| 68 | * malformed. |
| 69 | * @since DOM Level 2 |
| 70 | */ |
| 71 | |
| 72 | public DocumentType createDocumentType(String qualifiedName, |
| 73 | String publicId, |
| 74 | String systemId) |
| 75 | throws DOMException { |
| 76 | NodeOverNodeInfo.disallowUpdate(); |
| 77 | return null; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Creates an XML <code>Document</code> object of the specified type with |
| 82 | * its document element. |
| 83 | * |
| 84 | * @param namespaceURI The namespace URI of the document element to |
| 85 | * create. |
| 86 | * @param qualifiedName The qualified name of the document element to be |
| 87 | * created. |
| 88 | * @param doctype The type of document to be created or <code>null</code>. |
| 89 | * @return A new <code>Document</code> object. |
| 90 | * @throws UnsupportedOperationException always |
| 91 | * @since DOM Level 2 |
| 92 | */ |
| 93 | /*@Nullable*/ |
| 94 | public Document createDocument(String namespaceURI, |
| 95 | String qualifiedName, |
| 96 | DocumentType doctype) |
| 97 | throws UnsupportedOperationException { |
| 98 | NodeOverNodeInfo.disallowUpdate(); |
| 99 | return null; |
| 100 | } |
| 101 | |
| 102 | } |
| 103 |