Modifier and Type | Field and Description |
---|---|
static String |
XML_NAMESPACE_URI
XML Namespace URI.
|
static String |
XMLNS_NAMESPACE_URI
Namespace used exclusively for defining namespaces.
|
Constructor and Description |
---|
Document()
Builds with an instance of
DefaultMarkupModel . |
Document(MarkupModel model)
Same as Document(model, null).
|
Document(MarkupModel model,
String encoding)
Same as Document(model, encoding, null).
|
Document(MarkupModel model,
String encoding,
String mimeType)
Creates a document instance with a given markup model, encoding and MIME type.
|
Modifier and Type | Method and Description |
---|---|
CData |
cdata(String content)
Adds and returns a new CDATA node.
|
Document |
comment(String text)
Adds the comment and returns this document for further construction.
|
void |
dtd(String name,
String publicId,
String systemId)
Sets the DTD for the document, overriding any prior DTD.
|
Element |
find(String path)
Finds an element based on a path of element names.
|
Document |
getDocument() |
Element |
getElementById(String id)
Tries to find an element in this document whose id is specified.
|
MarkupModel |
getMarkupModel() |
String |
getMimeType()
Returns the MIME type of this document.
|
protected Map<String,String> |
getNamespaceURIToPrefix() |
Element |
getRootElement() |
boolean |
hasDTD()
Returns true if the document has an explicit DTD (set via
dtd(String, String, String) ). |
Element |
newRootElement(String name)
Creates the root element for this document, replacing any previous root element.
|
Element |
newRootElement(String namespace,
String name)
Creates a new root element within a namespace.
|
Document |
raw(String text)
Adds the raw text and returns this document for further construction.
|
Text |
text(String text)
Adds and returns a new text node (the text node is returned so that
Text.write(String) or [@link
Text.writef(String, Object[]) may be invoked. |
void |
toMarkup(Document document,
PrintWriter writer,
Map<String,String> namespaceURIToPrefix)
Implemented by each subclass, with the document passed in for efficiency.
|
getContainer, moveAfter, moveBefore, moveToBottom, moveToTop, remove, toMarkup, toString, wrap
public static final String XML_NAMESPACE_URI
public static final String XMLNS_NAMESPACE_URI
public Document(MarkupModel model)
model
- a MarkupModel
.public Document(MarkupModel model, String encoding)
model
- a MarkupModel
.public Document(MarkupModel model, String encoding, String mimeType)
model
- a MarkupModel
.encoding
- the encoding.mimeType
- the MIME type.public Document()
DefaultMarkupModel
.public Document getDocument()
getDocument
in class Node
public Element find(String path)
path
- slash separated series of element namesElement.find(String)
public MarkupModel getMarkupModel()
public Element newRootElement(String name)
public Element newRootElement(String namespace, String name)
namespace
- URI of namespace containing the elementname
- name of element with namespacepublic void toMarkup(Document document, PrintWriter writer, Map<String,String> namespaceURIToPrefix)
Node
public Element getRootElement()
public Element getElementById(String id)
id
- the value of the id attribute of the element being looked forpublic void dtd(String name, String publicId, String systemId)
name
- non-blank name of document type (i.e., "html")publicId
- optionalsystemId
- optionalpublic boolean hasDTD()
dtd(String, String, String)
).protected Map<String,String> getNamespaceURIToPrefix()
getNamespaceURIToPrefix
in class Node
public Document comment(String text)
public Document raw(String text)
public Text text(String text)
Text.write(String)
or [@link
Text.writef(String, Object[])
may be invoked.text
- initial text for the nodepublic CData cdata(String content)
content
- the content to be rendered by the nodepublic String getMimeType()
5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.