nl.tudelft.simulation.xml
Class AbstractXMLParser

java.lang.Object
  extended by nl.tudelft.simulation.xml.AbstractXMLParser

public abstract class AbstractXMLParser
extends Object


(c) copyright 2002-2005-2004 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser General Public License (LGPL) , no warranty.

Version:
Jun 27, 2004
Author:
Alexander Verbraeck

Constructor Summary
AbstractXMLParser(URL url, URL schema, String schemaNamespace, boolean validateSchema)
          Parses an XML file and validates it against a schema XSD.
 
Method Summary
protected  org.jdom.Element parse()
          This method carries out the task of parsing an XML file and validates it against a schema XSD.
protected abstract  void parse(org.jdom.Element xmlRootElement)
          The actual parsing method to implement, based on the availability of the entire JDOM tree, starting from the root element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractXMLParser

public AbstractXMLParser(URL url,
                         URL schema,
                         String schemaNamespace,
                         boolean validateSchema)
Parses an XML file and validates it against a schema XSD. Explicitly call parse() from the extended class, after other initialization tasks have been carried out. The parse() method will, after schema validation and xml-file validation, call the parse(Element) method that has been declared in the extended class.

Parameters:
url - the URL of the XML file to read.
schema - the URL of the XSD schema file to validate against.
schemaNamespace - the namespace of the schema
validateSchema - whether to validate the schema file.
Method Detail

parse

protected org.jdom.Element parse()
                          throws Exception
This method carries out the task of parsing an XML file and validates it against a schema XSD. dsol-xml now contains the 2001 definitions of the schema files: XMLSchema.xsd, XMLSchema.dtd, xml.xsd, and datatypes.dtd to validate against. When no network connection is available, these definitions can help for validation when validation is true.

Returns:
the JDOM root element of the XML file
Throws:
Exception - on failure

parse

protected abstract void parse(org.jdom.Element xmlRootElement)
                       throws Exception
The actual parsing method to implement, based on the availability of the entire JDOM tree, starting from the root element.

Parameters:
xmlRootElement - the root element
Throws:
Exception - on failure


Copyright © 2002-2010 Delft University of Technology, the Netherlands. All Rights Reserved.