public static class ERXML.Doc extends ERXML.Item
Doc represents the top level XML Document object, and is typically the first object you will make when building.
XML.Doc doc = XML.doc(); XML.E person = doc.root("person");
Constructor and Description |
---|
Doc()
Constructs a new Document.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_add(ERXML.Item child)
Adds a new child to this document.
|
<T extends ERXML.Item> |
add(T child)
Adds a new child to this document.
|
protected void |
checkNullRoot()
Checks if there is already a root element and throws if there is.
|
List<ERXML.Item> |
children()
Returns the children of this document.
|
ERXML.Doc |
comment(String comment)
Creates and returns a new comment for this document.
|
ERXML.Declaration |
declaration()
Returns the declaration for this document, or null if there isn't one.
|
void |
remove(ERXML.Item child)
Removes the given child from this document.
|
ERXML.E |
root()
Returns the root element (or null if there isn't one).
|
ERXML.E |
root(String name)
Creates a new root element with the given name and returns it.
|
ERXML.E |
root(String name,
String value)
Creates a new root element with the given name and initial text contents and returns
it.
|
void |
setDeclaration(ERXML.Declaration declaration)
Sets the declaration for this document.
|
void |
setRoot(ERXML.E root)
Sets the root element of this document.
|
void |
visit(ERXML.Visitor visitor)
Visits this item and any of its children (if the visitor allows).
|
Document |
w3c() |
void |
write(PrintWriter writer,
int indent)
Writes this item to the given writer with a certain indentation.
|
doc, parent, setParent, toString, writeEscapedString, writeIndent
protected void checkNullRoot()
public ERXML.Declaration declaration()
public void setDeclaration(ERXML.Declaration declaration)
declaration
- the declaration for this documentpublic ERXML.E root(String name)
name
- the name of the new root elementpublic ERXML.E root(String name, String value)
name
- the name of the new root elementvalue
- the initial text value of this elementpublic ERXML.E root()
public void setRoot(ERXML.E root)
root
- the new root elementpublic ERXML.Doc comment(String comment)
comment
- a new comment for this documentpublic void remove(ERXML.Item child)
child
- the child to removeprotected void _add(ERXML.Item child)
child
- the child to addpublic <T extends ERXML.Item> T add(T child)
T
- the type of the itemchild
- the child to addpublic List<ERXML.Item> children()
public void write(PrintWriter writer, int indent)
ERXML.Item
write
in class ERXML.Item
writer
- the writer to write toindent
- the current indentationpublic void visit(ERXML.Visitor visitor)
ERXML.Item
visit
in class ERXML.Item
visitor
- the visitor to visit withpublic Document w3c()
Copyright © 2002 – 2020 Project Wonder.