diva.util.xml
Class XmlDocument

java.lang.Object
  extended by diva.util.xml.XmlDocument

public class XmlDocument
extends Object

An XMLDocument is an in-memory representation of an XML document. It contains an XML element as its root, and other information relevent to the document as a whole, such as its URL, its DTD, and so on. The document can be parsed from or written out to its URL or File, or to some other arbitrary Writer. Documents do not parse themselves, but are passed to an XmlReader.

See the package summary for a brief description of how to use this class.

Version:
$Revision: 1.11 $
Author:
Steve Neuendorffer, John Reekie

Constructor Summary
XmlDocument()
          Create an XML document with no idea of where it exists.
XmlDocument(File file)
          Create an XML document located in the given file.
XmlDocument(URL url)
          Create an XML document with the given URL.
XmlDocument(URL url, String dtdPublicID)
          Create an XML document with the given URL and the DTD system ID.
 
Method Summary
 String getDTD()
          Get the DTD of this document.
 String getDTDPublicID()
          Get the public ID of the DTD of this document.
 String getDTDSystemID()
          Get the system ID of the DTD of this document.
 File getFile()
          Get the file corresponding to this document.
 XmlElement getRoot()
          Get the root element of this document.
 URL getURL()
          Get the URL of this document.
 void setDocType(String dt)
          Set the type of this document.
 void setDTD(String dtd)
          Set the DTD of this document.
 void setDTDPublicID(String id)
          Set the DTD of this document by its public ID.
 void setDTDSystemID(String id)
          Set the DTD of this document by its public ID.
 void setFile(File file)
          Set the file that this document corresponds to.
 void setRoot(XmlElement root)
          Set the root element of this document.
 void setURL(URL url)
          Set the URL of this document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlDocument

public XmlDocument()
Create an XML document with no idea of where it exists.


XmlDocument

public XmlDocument(URL url)
Create an XML document with the given URL.


XmlDocument

public XmlDocument(File file)
Create an XML document located in the given file.


XmlDocument

public XmlDocument(URL url,
                   String dtdPublicID)
Create an XML document with the given URL and the DTD system ID.

Method Detail

getDTD

public String getDTD()
Get the DTD of this document. If a DTD has most recently been explicitly set with setDTD(), return that. If the document has most recently been parsed, then return the DTD that was used to parse the document. If neither of these has ever been done, return null.


getDTDPublicID

public String getDTDPublicID()
Get the public ID of the DTD of this document. This field can be set explicitly by the setDTDPublicID() method or by parsing the document. Null if it does not have one.


getDTDSystemID

public String getDTDSystemID()
Get the system ID of the DTD of this document. This field can be set explicitly by the setDTDSystemID() method or by parsing the document. Null if it does not have one.


getURL

public URL getURL()
Get the URL of this document. This may be null.


getFile

public File getFile()
Get the file corresponding to this document. This may be null.


getRoot

public XmlElement getRoot()
Get the root element of this document. Null if the document has never been parsed or had its root element explicitly set.


setDTD

public void setDTD(String dtd)
Set the DTD of this document. The DTD is a string that will be printed when the document is printed. If set to null, the DTD will be set to the DTD system and/or public external identifiers.


setDocType

public void setDocType(String dt)
Set the type of this document.


setDTDPublicID

public void setDTDPublicID(String id)
Set the DTD of this document by its public ID.


setDTDSystemID

public void setDTDSystemID(String id)
Set the DTD of this document by its public ID.


setRoot

public void setRoot(XmlElement root)
Set the root element of this document. This method replaces any existing XML content in the document.


setFile

public void setFile(File file)
Set the file that this document corresponds to. When this document is printed or parsed, this is where this document will be printed to or parsed from. If the document also has a non-null URL, then the file location will be ignored.


setURL

public void setURL(URL url)
Set the URL of this document. When this document is printed or parsed, this is where this document will be printed to or parsed from. If the document also has a file object, then it will be ignored once the URL has been set non-null.



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.