2 * @(#)DOMDocumentImpl.java 1.11 2000/08/16
6 package net.sourceforge.phpdt.tidy.w3c;
8 import org.w3c.dom.DOMException;
14 * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
15 * See Tidy.java for the copyright notice.
16 * Derived from <a href="http://www.w3.org/People/Raggett/tidy">
17 * HTML Tidy Release 4 Aug 2000</a>
19 * @author Dave Raggett <dsr@w3.org>
20 * @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
21 * @version 1.4, 1999/09/04 DOM Support
22 * @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
23 * @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
24 * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
25 * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
26 * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
27 * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
28 * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
31 public class DOMDocumentImpl extends DOMNodeImpl implements org.w3c.dom.Document {
33 private TagTable tt; // a DOM Document has its own TagTable.
35 protected DOMDocumentImpl(Node adaptee)
41 public void setTagTable(TagTable tt)
46 /* --------------------- DOM ---------------------------- */
49 * @see org.w3c.dom.Node#getNodeName
51 public String getNodeName()
57 * @see org.w3c.dom.Node#getNodeType
59 public short getNodeType()
61 return org.w3c.dom.Node.DOCUMENT_NODE;
65 * @see org.w3c.dom.Document#getDoctype
67 public org.w3c.dom.DocumentType getDoctype()
69 Node node = adaptee.content;
70 while (node != null) {
71 if (node.type == Node.DocTypeTag) break;
75 return (org.w3c.dom.DocumentType)node.getAdapter();
81 * @see org.w3c.dom.Document#getImplementation
83 public org.w3c.dom.DOMImplementation getImplementation()
90 * @see org.w3c.dom.Document#getDocumentElement
92 public org.w3c.dom.Element getDocumentElement()
94 Node node = adaptee.content;
95 while (node != null) {
96 if (node.type == Node.StartTag ||
97 node.type == Node.StartEndTag) break;
101 return (org.w3c.dom.Element)node.getAdapter();
107 * @see org.w3c.dom.Document#createElement
109 public org.w3c.dom.Element createElement(String tagName)
112 Node node = new Node(Node.StartEndTag, null, 0, 0, tagName, tt);
114 if (node.tag == null) // Fix Bug 121206
115 node.tag = tt.xmlTags;
116 return (org.w3c.dom.Element)node.getAdapter();
123 * @see org.w3c.dom.Document#createDocumentFragment
125 public org.w3c.dom.DocumentFragment createDocumentFragment()
132 * @see org.w3c.dom.Document#createTextNode
134 public org.w3c.dom.Text createTextNode(String data)
136 byte[] textarray = Lexer.getBytes(data);
137 Node node = new Node(Node.TextNode, textarray, 0, textarray.length);
139 return (org.w3c.dom.Text)node.getAdapter();
145 * @see org.w3c.dom.Document#createComment
147 public org.w3c.dom.Comment createComment(String data)
149 byte[] textarray = Lexer.getBytes(data);
150 Node node = new Node(Node.CommentTag, textarray, 0, textarray.length);
152 return (org.w3c.dom.Comment)node.getAdapter();
158 * @see org.w3c.dom.Document#createCDATASection
160 public org.w3c.dom.CDATASection createCDATASection(String data)
168 * @see org.w3c.dom.Document#createProcessingInstruction
170 public org.w3c.dom.ProcessingInstruction createProcessingInstruction(String target,
174 throw new DOMExceptionImpl(DOMException.NOT_SUPPORTED_ERR,
179 * @see org.w3c.dom.Document#createAttribute
181 public org.w3c.dom.Attr createAttribute(String name)
184 AttVal av = new AttVal(null, null, (int)'"', name, null);
187 AttributeTable.getDefaultAttributeTable().findAttribute(av);
188 return (org.w3c.dom.Attr)av.getAdapter();
195 * @see org.w3c.dom.Document#createEntityReference
197 public org.w3c.dom.EntityReference createEntityReference(String name)
205 * @see org.w3c.dom.Document#getElementsByTagName
207 public org.w3c.dom.NodeList getElementsByTagName(String tagname)
209 return new DOMNodeListByTagNameImpl(this.adaptee, tagname);
213 * DOM2 - not implemented.
214 * @exception org.w3c.dom.DOMException
216 public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep)
217 throws org.w3c.dom.DOMException
223 * DOM2 - not implemented.
224 * @exception org.w3c.dom.DOMException
226 public org.w3c.dom.Attr createAttributeNS(String namespaceURI,
227 String qualifiedName)
228 throws org.w3c.dom.DOMException
234 * DOM2 - not implemented.
235 * @exception org.w3c.dom.DOMException
237 public org.w3c.dom.Element createElementNS(String namespaceURI,
238 String qualifiedName)
239 throws org.w3c.dom.DOMException
245 * DOM2 - not implemented.
247 public org.w3c.dom.NodeList getElementsByTagNameNS(String namespaceURI,
254 * DOM2 - not implemented.
256 public org.w3c.dom.Element getElementById(String elementId)