org.jdom

Class DocType

Implemented Interfaces:
Cloneable, Serializable

public class DocType
extends Content

An XML DOCTYPE declaration. Method allow the user to get and set the root element name, public id, and system id.
See Also:
Serialized Form

Field Summary

protected String
elementName
The element being constrained
protected String
internalSubset
The internal subset of the DOCTYPE
protected String
publicID
The public ID of the DOCTYPE
protected String
systemID
The system ID of the DOCTYPE

Fields inherited from class org.jdom.Content

parent

Constructor Summary

DocType()
Default, no-args constructor for implementations to use if needed.
DocType(String elementName)
This will create the DocType with the specified element name
DocType(String elementName, String systemID)
This will create the DocType with the specified element name and reference to an external DTD.
DocType(String elementName, String publicID, String systemID)
This will create the DocType with the specified element name and a reference to an external DTD.

Method Summary

String
getElementName()
This will retrieve the element name being constrained.
String
getInternalSubset()
This returns the data for the internal subset.
String
getPublicID()
This will retrieve the public ID of an externally referenced DTD, or an empty String if none is referenced.
String
getSystemID()
This will retrieve the system ID of an externally referenced DTD, or an empty String if none is referenced.
String
getValue()
Returns the empty string since doctypes don't have an XPath 1.0 string value.
DocType
setElementName(String elementName)
This will set the root element name declared by this DOCTYPE declaration.
void
setInternalSubset(String newData)
This sets the data for the internal subset.
DocType
setPublicID(String publicID)
This will set the public ID of an externally referenced DTD.
DocType
setSystemID(String systemID)
This will set the system ID of an externally referenced DTD.
String
toString()
This returns a String representation of the DocType, suitable for debugging.

Methods inherited from class org.jdom.Content

clone, detach, equals, getDocument, getParent, getParentElement, getValue, hashCode, setParent

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

elementName

protected String elementName
The element being constrained

internalSubset

protected String internalSubset
The internal subset of the DOCTYPE

publicID

protected String publicID
The public ID of the DOCTYPE

systemID

protected String systemID
The system ID of the DOCTYPE

Constructor Details

DocType

protected DocType()
Default, no-args constructor for implementations to use if needed.

DocType

public DocType(String elementName)
This will create the DocType with the specified element name
Parameters:
elementName - String name of element being constrained.
Throws:
IllegalNameException - if the given root element name is not a legal XML element name.
Usages and Demos :

View More Examples of DocType(String elementName)
   1: 
   2:         Document errorDoc = new Document(root, new DocType(rootname));
   3: 
   4:         while (ex != null) {
   5:             Element exception = new Element("exception");

View Full Code Here
   1:         if ((systemID != null) || (publicID != null)) {
   2:             DocType docType = new DocType(root.getName(), publicID, systemID);
   3:             doc.setDocType(docType);
   4:         }
   5:         

View Full Code Here

DocType

public DocType(String elementName,
               String systemID)
This will create the DocType with the specified element name and reference to an external DTD.
Parameters:
elementName - String name of element being constrained.
systemID - String system ID of referenced DTD
Throws:
IllegalDataException - if the given system ID is not a legal system literal.
IllegalNameException - if the given root element name is not a legal XML element name.
Usages and Demos :

View More Examples of DocType(String elementName,String systemID)
   1:         Element root = new Element("library");
   2:         DocType dt = new DocType("library", "library.dtd");
   3:         Document doc = new Document(root, dt);
   4: 
   5:         Iterator publisherIter = library.getPublishers().iterator();

View Full Code Here

DocType

public DocType(String elementName,
               String publicID,
               String systemID)
This will create the DocType with the specified element name and a reference to an external DTD.
Parameters:
elementName - String name of element being constrained.
publicID - String public ID of referenced DTD
systemID - String system ID of referenced DTD
Throws:
IllegalDataException - if the given system ID is not a legal system literal or the public ID is not a legal public ID.
IllegalNameException - if the given root element name is not a legal XML element name.

Method Details

getElementName

public String getElementName()
This will retrieve the element name being constrained.
Returns:
String - element name for DOCTYPE

getInternalSubset

public String getInternalSubset()
This returns the data for the internal subset.
Returns:
String - the internal subset

getPublicID

public String getPublicID()
This will retrieve the public ID of an externally referenced DTD, or an empty String if none is referenced.
Returns:
String - public ID of referenced DTD.
Usages and Demos :

View More Examples of getPublicID()
   1: import org.jdom.Document;
   2: import org.jdom.DocType;
   3: import org.jdom.Element;
   4:         ...
   5:  
   6:         DocType docType = doc.getDocType();
   7:         if (docType != null) {
   8:         ...
   9:             return new UnmarshalledObject(obj, 
  10:                                           docType.getPublicID(),
  11:                                           docType.getSystemID());

View Full Code Here

getSystemID

public String getSystemID()
This will retrieve the system ID of an externally referenced DTD, or an empty String if none is referenced.
Returns:
String - system ID of referenced DTD.
Usages and Demos :

View More Examples of getSystemID()
   1: import org.jdom.Document;
   2: import org.jdom.DocType;
   3: import org.jdom.Element;
   4:         ...
   5:  
   6:         DocType docType = doc.getDocType();
   7:         if (docType != null) {
   8:         ...
   9:                                           docType.getPublicID(),
  10:                                           docType.getSystemID());
  11:         } else {

View Full Code Here

getValue

public String getValue()
Returns the empty string since doctypes don't have an XPath 1.0 string value.
Overrides:
getValue in interface Content
Returns:
the empty string

setElementName

public DocType setElementName(String elementName)
This will set the root element name declared by this DOCTYPE declaration.
Parameters:
elementName - String name of root element being constrained.
Returns:
DocType DocType this DocType object
Throws:
IllegalNameException - if the given root element name is not a legal XML element name.

setInternalSubset

public void setInternalSubset(String newData)
This sets the data for the internal subset.
Parameters:
newData - data for the internal subset, as a String.

setPublicID

public DocType setPublicID(String publicID)
This will set the public ID of an externally referenced DTD.
Parameters:
publicID - id to set
Returns:
DocType DocType this DocType object
Throws:
IllegalDataException - if the given public ID is not a legal public ID.

setSystemID

public DocType setSystemID(String systemID)
This will set the system ID of an externally referenced DTD.
Parameters:
systemID - id to set
Returns:
systemID String system ID of referenced DTD.
Throws:
IllegalDataException - if the given system ID is not a legal system literal.

toString

public String toString()
This returns a String representation of the DocType, suitable for debugging.
Overrides:
toString in interface Object
Returns:
String - information about the DocType