1
2
3
4
5
6
7
8
9
10 package org.dom4j;
11
12 import java.util.Map;
13
14 import org.xml.sax.EntityResolver;
15
16 /*** <p><code>Document</code> defines an XML Document.</p>
17 *
18 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
19 * @version $Revision: 1.11 $
20 */
21 public interface Document extends Branch {
22
23 /*** Returns the root {@link Element} for this document.
24 *
25 * @return the root element for this document
26 */
27 public Element getRootElement();
28
29 /*** Sets the root element for this document
30 *
31 * @param rootElement the new root element for this document
32 */
33 public void setRootElement(Element rootElement);
34
35
36 /*** Adds a new <code>Comment</code> node with the given text to this branch.
37 *
38 * @param comment is the text for the <code>Comment</code> node.
39 * @return this <code>Document</code> instance.
40 */
41 public Document addComment(String comment);
42
43 /*** Adds a processing instruction for the given target
44 *
45 * @param target is the target of the processing instruction
46 * @param text is the textual data (key/value pairs) of the processing instruction
47 * @return this <code>Document</code> instance.
48 */
49 public Document addProcessingInstruction(String target, String text);
50
51 /*** Adds a processing instruction for the given target
52 *
53 * @param target is the target of the processing instruction
54 * @param data is a Map of the key / value pairs of the processing instruction
55 * @return this <code>Document</code> instance.
56 */
57 public Document addProcessingInstruction(String target, Map data);
58
59 /*** Adds a DOCTYPE declaration to this document
60 *
61 * @param name is the name of the root element
62 * @param publicId is the PUBLIC URI
63 * @param systemId is the SYSTEM URI
64 * @return this <code>Document</co`de> instance.
65 */
66 public Document addDocType(String name, String publicId, String systemId);
67
68 /*** @return the DocumentType property
69 */
70 public DocumentType getDocType();
71
72 /*** Sets the DocumentType property
73 */
74 public void setDocType(DocumentType docType);
75
76
77 /*** @return the EntityResolver used to find resolve URIs such as for DTDs,
78 * or XML Schema documents
79 */
80 public EntityResolver getEntityResolver();
81
82 /*** Sets the EntityResolver used to find resolve URIs such as for DTDs,
83 * or XML Schema documents
84 */
85 public void setEntityResolver(EntityResolver entityResolver);
86
87 /***
88 * Return the encoding of this document, as part of the XML declaration
89 * This is <code>null</code> when unspecified or when it is not known (such
90 * as when the Document was created in memory) or when the implementation
91 * does not support this operation.
92 * <p>
93 * The way this encoding is retrieved also depends on the way the XML
94 * source is parsed. For instance, if the SAXReader is used and if the
95 * underlying XMLReader implementation support the
96 * <code>org.xml.sax.ext.Locator2</code> interface, the result returned
97 * by this method is specified by the <code>getEncoding()</code>
98 * method of that interface.
99 *
100 * @return The encoding of this document, as stated in the XML declaration,
101 * or <code>null</code> if unknown.
102 * @since 1.5
103 */
104 public String getXMLEncoding();
105 }
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156