jwo.vfc.hub
Class XMLProcessor

java.lang.Object
  |
  +--jwo.vfc.hub.XMLProcessor
All Implemented Interfaces:
ErrorHandler
Direct Known Subclasses:
Route3D

public class XMLProcessor
extends Object
implements ErrorHandler

Class for reading, processing and writing XML files storing spatial metadata. Includes some modified sections of the 'DOMWriter' code supplied with IBM's xml4Java package.

Version:
1.2.3, 15th July, 1999.
Author:
Jo Wood

Field Summary
protected  String errorMessage
          Last error message.
protected  boolean errors
          Records whether any errors have occurred.
 
Constructor Summary
XMLProcessor()
          Creates a default structured document.
XMLProcessor(String xmlFile)
          Creates a structured document from the given XML file.
 
Method Summary
 void createDefault()
          Creates a default document object model.
 void error(SAXParseException e)
          Handles error messages generated by the xml parser.
 void fatalError(SAXParseException e)
          Handles error messages generated by the xml parser.
 Document getDOM()
          Reports the Document Object Model (DOM) currently stored in this class.
 String getErrorMessage()
          Reports any error messages associated with XML creation or DOM parsing.
 boolean hasErrors()
          Reports whether any errors have occurred in creating the DOM.
 boolean readXML(String fileName)
          Reads a given XML file and stores the structured information.
 boolean validateDOM()
          Validates the entire DOM.
 void warning(SAXParseException e)
          Handles warning messages generated by the xml parser.
 String writeXML()
          Converts the structured information stored within this class into XML text.
 boolean writeXML(String fileName)
          Converts the structured information stored within this class into an XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errors

protected boolean errors
Records whether any errors have occurred.


errorMessage

protected String errorMessage
Last error message.

Constructor Detail

XMLProcessor

public XMLProcessor()
Creates a default structured document.


XMLProcessor

public XMLProcessor(String xmlFile)
Creates a structured document from the given XML file.

Parameters:
xmlFile - XML file to read and process.
Method Detail

createDefault

public void createDefault()
Creates a default document object model. This is essentially empty except with a DTD, a comment and an empty fieldtrip node.


getDOM

public Document getDOM()
Reports the Document Object Model (DOM) currently stored in this class.

Returns:
DOM stored in this class.

readXML

public boolean readXML(String fileName)
Reads a given XML file and stores the structured information.

Parameters:
fileName - Name of XML file to read.
Returns:
true if successful XML file read.

writeXML

public boolean writeXML(String fileName)
Converts the structured information stored within this class into an XML file.

Parameters:
fileName - Name of file to contain the XML.
Returns:
true if successful XML generation.

writeXML

public String writeXML()
Converts the structured information stored within this class into XML text.

Returns:
Text containing XML or empty string if problem.

validateDOM

public boolean validateDOM()
Validates the entire DOM. Useful if elements have been added to a previously parsed XML file.

Returns:
true if a valid DOM, otherwise false.

hasErrors

public boolean hasErrors()
Reports whether any errors have occurred in creating the DOM.

Returns:
true if any errors have occurred.

getErrorMessage

public String getErrorMessage()
Reports any error messages associated with XML creation or DOM parsing.

Returns:
Error message or empty string if no errors.

warning

public void warning(SAXParseException e)
Handles warning messages generated by the xml parser.

Specified by:
warning in interface ErrorHandler
Parameters:
e - Parser warning.

error

public void error(SAXParseException e)
Handles error messages generated by the xml parser.

Specified by:
error in interface ErrorHandler
Parameters:
e - Parser error.

fatalError

public void fatalError(SAXParseException e)
Handles error messages generated by the xml parser.

Specified by:
fatalError in interface ErrorHandler
Parameters:
e - Parser error.