4,10 → 4,10 |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.48 $ |
* @version $Revision: 1.49 $ |
* |
* Last modification: $Date: 2003/07/22 13:59:06 $ |
* $Id: Validator.java,v 1.48 2003/07/22 13:59:06 smcsporr Exp $ |
* Last modification: $Date: 2003/07/22 18:59:42 $ |
* $Id: Validator.java,v 1.49 2003/07/22 18:59:42 smcsporr Exp $ |
*/ |
|
package src.parser; |
43,38 → 43,61 |
import src.gui.StatusInterface; |
|
/** |
* An instance of the <b><code>Validator</code></b> class is a validating |
* parser that can be used to parse and validate DOM document implementations. |
* It uses the Xerces SAX 2.0 parser implementation. |
* An instance of the <b><code>Validator</code></b> class is a validating parser. |
* It can be used to parse and validate DOM document implementations against |
* a Document Type Definition (DTD) or an XML schema. |
* |
* As second function, it can be used to parse an XML schema grammar to retrieve |
* the possible top level elements, that are candidates of being the root |
* element of an instance document of that schema. |
* |
* A <code>Validator</code> instance uses an instance of the <code>ValidationErrorHandler</code> class |
* to catch and handle SAX warning and error events. These events are used to |
* decide, whether a document is valid or not. |
* |
* @author S. McSporran |
* |
* @version $Revision: 1.48 $ Last modification: $Date: 2003/07/22 13:59:06 $ |
* @version $Revision: 1.49 $ Last modification: $Date: 2003/07/22 18:59:42 $ |
*/ |
public class Validator { |
|
/* The name of the Xerces parser implementation. */ |
/** The name of the Xerces parser implementation. */ |
private final String defaultParser = "org.apache.xerces.parsers.SAXParser"; |
|
/* A reference to a log panel implementation. */ |
/** |
* A reference to a log panel implementation. |
* Required to send status messages to the log panel. |
*/ |
private LogInterface logInterfaceReference; |
|
/* A reference to a status panel implementation. */ |
/** |
* A reference to a status panel implementation. |
* Required to display status icons and error locations in the status panel. |
*/ |
private StatusInterface statInterfaceReference; |
|
/* A variable for a SAX 2.0 parser instance. */ |
/** An instance variable for a SAX 2.0 parser instance. */ |
private XMLReader activeParser; |
|
/* The error handler to which the parser sends error events.*/ |
/** The error handler to which the parser sends error events.*/ |
private ValidationErrorHandler eHandler; |
|
/** |
* A transformer is required to transform a DOM document representation into |
* a character stream. |
*/ |
private Transformer myTransformer; |
private TransformerFactory transFactory; |
|
/** |
* The class constructor creates and configures an instance of a SAX parser, registers |
* the log and status panel and the parser's error handler. |
* the log and status panel to enable their use and the parser's error handler. |
* |
* By default, the constructor tries to instantiate a parser using the Xerces |
* implementation, but it will also look for the system's default implementation, |
* if Xerces isn't available. Please note that Xerces is required to ensure full |
* functionality. |
* |
* @param logI: A reference to a log panel implementation. |
* @param statI: A reference to a status panel implementation. |
* |
126,7 → 149,6 |
/* Activate the needed parser features. */ |
activateNamespaceProcessing(); |
activateValidation(); |
//activateDynamicValidation(); |
activateSchemaSupport(); |
} |
|
338,10 → 360,11 |
} |
} |
|
/* |
/** |
* This method validates a DOM document object. |
* |
* @param doc: The document to be validated. |
* |
* @return <code>true</code>, if the document fits to it's specified grammar, |
* <code>false</code> otherwise. |
* |
415,7 → 438,7 |
return eHandler.isValid(); |
} |
|
/* |
/** |
* This method validates an <code>InputStream</code>. |
* |
* @param inStream: The stream to be validated. |
452,7 → 475,9 |
return eHandler.isValid(); |
} |
|
/* Sends a message to the log panel. */ |
/** |
* Sends a message of a specified type to the log panel. |
*/ |
private void log(int i,String message) { |
logInterfaceReference.log(i,message); |
} |
468,7 → 493,8 |
} |
|
/** |
* This method sets an internal reference to the log panel. |
* This method sets an internal reference to the log panel that is used to |
* output logging messages to inform the user about program events. |
* |
* @param log: A log panel implementation compliant to src.gui.LogInterface. |
* |