| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectnu.xom.Node
nu.xom.DocType
Represents an XML document type declaration such as
<!DOCTYPE book SYSTEM "docbookx.dtd">
.
Note that this is not the same thing as a document
type definition (DTD). XOM does not currently model
the DTD. The document type declaration contains or points to
the DTD, but it is not the DTD.
A DocType
object does not have any child
nodes. It can be a child of a Document
.
Each DocType
object has four String
properties, some of which may be null:
The first three properties are read-write. The internal DTD subset is read-only. XOM fills it in when a document is read by a parser. However, it cannot be changed, because XOM cannot currently check that an internal DTD subset is well-formed. This restriction may be relaxed in a future version.
Constructor Summary | |
DocType(DocType doctype)
Creates a new DocType that's a copy of its
argument. | |
DocType(String rootElementName)
Creates a new document type declaration with no public or system ID. | |
DocType(String rootElementName,
String systemID)
Creates a new document type declaration with a system ID but no public ID. | |
DocType(String rootElementName,
String publicID,
String systemID)
Creates a new document type declaration with a public ID and a system ID. |
Method Summary | |
Node | copy()
Returns a copy of this DocType
which has the same system ID, public ID, root element name,
and internal DTD subset, but does not belong to a document. |
Node | getChild(int position)
Throws IndexOutOfBoundsException because
document type declarations do not have children. |
int | getChildCount()
Returns 0 because document type declarations do not have children. |
String | getInternalDTDSubset()
Returns the complete internal DTD subset. |
String | getPublicID()
Returns the public ID of the external DTD subset. |
String | getRootElementName()
Returns the name the document type declaration specifies for the root element. |
String | getSystemID()
Returns the system ID of the external DTD subset. |
String | getValue()
Returns the empty string. |
void | setPublicID(String id)
Sets the public ID for the external DTD subset. |
void | setRootElementName(String name)
Sets the name the document type declaration specifies for the root element. |
void | setSystemID(String id)
Sets the system ID for the external DTD subset. |
String | toString()
Returns a string form of the DocType suitable for debugging
and diagnosis. |
String | toXML()
Returns a string containing the actual XML form of the document type declaration represented by this object. |
Methods inherited from class nu.xom.Node |
detach, equals, getBaseURI, getDocument, getParent, hashCode |
Methods inherited from class Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DocType(String rootElementName,
String publicID,
String systemID)
Creates a new document type declaration with a public ID
and a system ID. It has the general form
<!DOCTYPE rootElementName PUBLIC
"publicID" "systemID">
.
rootElementName
- the name specified for the root elementpublicID
- the public ID of the external DTD subsetsystemID
- the URL of the external DTD subset
IllegalNameException
- if rootElementName
is not a legal XML 1.0 name
IllegalDataException
- if publicID
is not a
legal XML 1.0 public identifier
MalformedURIException
- if the system ID is not a
syntactically correct URI, or if it contains a fragment
identifier
public DocType(String rootElementName,
String systemID)
Creates a new document type declaration with a system ID
but no public ID. It has the general form
<!DOCTYPE rootElementName SYSTEM "systemID">
.
rootElementName
- the name specified for the root elementsystemID
- the URL of the external DTD subset
IllegalNameException
- if the rootElementName is not
a legal XML 1.0 name
MalformedURIException
- if the system ID is not a
syntactically correct URI, or if it contains a fragment
identifier
public DocType(String rootElementName)
Creates a new document type declaration with
no public or system ID. It has the general form
<!DOCTYPE rootElementName>
.
rootElementName
- the name specified for the root element
IllegalNameException
- if the rootElementName is not
a legal XML 1.0 name
public DocType(DocType doctype)
Creates a new DocType
that's a copy of its
argument. The copy has the same data but no parent document.
doctype
- the DocType
to copyMethod Detail |
public final String getRootElementName()
Returns the name the document type declaration specifies for the root element. In an invalid document, this may not be the same as the actual root element name.
public void setRootElementName(String name)
Sets the name the document type declaration specifies for the root element. In an invalid document, this may not be the same as the actual root element name.
name
- the root element name given by
the document type declaration
IllegalNameException
- if the root element name is not
a legal XML 1.0 name
public final String getInternalDTDSubset()
Returns the complete internal DTD subset. White space may not be preserved completely accurately, but all declarations should be in place.
public final String getPublicID()
Returns the public ID of the external DTD subset. This is null if there is no external DTD subset or if it does not have a public identifier.
public void setPublicID(String id)
Sets the public ID for the external DTD subset. This can only be set after a system ID has been set, because XML requires that all document type declarations with public IDs have system IDs. Passing null removes the public ID.
id
- the public identifier of the external DTD subset
IllegalDataException
- if the public ID does not satisfy
the rules for public IDs in XML 1.0
WellformednessException
- if no system ID has been set
public final String getSystemID()
Returns the system ID of the external DTD subset. This is a URL. It is null if there is no external DTD subset.
public void setSystemID(String id)
Sets the system ID for the external DTD subset.
This must be a a relative or absolute URI with no fragment
identifier. Passing null removes the system ID, but only if
the public ID has been removed first. Otherwise,
passing null causes a WellformednessException
.
id
- the URL of the external DTD subset
MalformedURIException
- if the system ID is not a
syntactically correct URI, or if it contains a fragment
identifier
WellformednessException
- if the public ID is non-null
and you attempt to remove the system ID
public final String getValue()
Returns the empty string. XPath 1.0 does not define a value for document type declarations.
getValue
in class Node
public final Node getChild(int position)
Throws IndexOutOfBoundsException
because
document type declarations do not have children.
getChild
in class Node
position
- the index of the child node to return
IndexOutOfBoundsException
- because document type declarations
do not have children
public final int getChildCount()
Returns 0 because document type declarations do not have children.
getChildCount
in class Node
public final String toString()
Returns a string form of the
DocType
suitable for debugging
and diagnosis. It deliberately does not return
an actual XML document type declaration.
public Node copy()
Returns a copy of this DocType
which has the same system ID, public ID, root element name,
and internal DTD subset, but does not belong to a document.
Thus, it can be inserted into a different document.
copy
in class Node
DocType
that is not part of a document
public final String toXML()
Returns a string containing the actual XML
form of the document type declaration represented
by this object. For example,
<!DOCTYPE book SYSTEM "docbookx.dtd">
.
toXML
in class Node
String
containing
an XML document type declaration
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |