public class Declaration extends Descriptor
<?xml
and ?>
. No other
Markup-node may use "xml" as its name.
The properties of a Declaration are stored as XML attributes; otherwise a Declaration has no other contents. The only legal attribute names are: "version", "encoding" and "standalone". Both Declaration and Instruction nodes have the notion of a target, which is the name of a program used to process the instruction. However, a Declaration always has the target "xml" denoting the XML processor.
Modifier and Type | Field and Description |
---|---|
private static java.util.Set<java.lang.String> |
legalNames
Secret set of legal attribute names for a Declaration.
|
attributeList
Constructor and Description |
---|
Declaration()
Creates a default XML declaration, setting the version attribute to
1.0 and the character encoding attribute to UTF-8.
|
Declaration(java.lang.String target)
Creates an XML declaration with the given target.
|
Modifier and Type | Method and Description |
---|---|
Declaration |
addAttribute(Attribute node)
Adds a uniquely named Attribute to this Declaration.
|
Declaration |
clone()
Clones this Declaration node.
|
java.lang.String |
getEncoding()
Returns the character encoding declared by this Declaration.
|
java.lang.String |
getTarget()
Returns the target of this XML Declaration.
|
int |
getType()
Returns the type of this Declaration.
|
java.lang.String |
getVersion()
Returns the XML version declared by this Declaration.
|
boolean |
isStandalone()
Reports whether the XML Document owning this Declaration stands alone.
|
Declaration |
setEncoding(java.lang.String encoding)
Sets the character encoding to be declared by this Declaration.
|
Declaration |
setValue(java.lang.String identifier,
java.lang.String value)
Sets the value of a named Attribute of this Declaration.
|
Declaration |
setVersion(java.lang.String version)
Sets the XML version to be declared by this Declaration.
|
getAttribute, getAttribute, getAttributes, getAttributes, getValue, hasAttributes, removeAttribute, removeAttribute
getIdentifier, getName, getNamespace, getPrefix
addContent, addContent, descendants, descendants, detach, getComment, getContent, getContent, getContent, getContents, getContents, getDocument, getParent, getText, hasContents, iterator, iterator, removeContent, removeContent, removeContents, setParent, toString
private static final java.util.Set<java.lang.String> legalNames
public Declaration()
public Declaration(java.lang.String target)
target
- must have the value "xml".public Declaration clone()
clone
in class Descriptor
public int getType()
public Declaration addAttribute(Attribute node)
addAttribute
in class Descriptor
node
- the Attribute to set.public Declaration setValue(java.lang.String identifier, java.lang.String value)
setValue
in class Descriptor
identifier
- the Attribute's long identifier, or short name.value
- the Attribute value.public java.lang.String getTarget()
public java.lang.String getVersion()
public Declaration setVersion(java.lang.String version)
version
- the new XML version.public java.lang.String getEncoding()
public Declaration setEncoding(java.lang.String encoding)
encoding
- the character encoding.public boolean isStandalone()