nl.tudelft.simulation.xml

## Class AbstractXMLParser

- java.lang.Object
- - nl.tudelft.simulation.xml.AbstractXMLParser

    public abstract class AbstractXMLParser
    extends Object

(c) 2002-2018-2004 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl .

Copyright (c) 2002-2018 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://simulation.tudelft.nl/dsol/3.0/license.html.

Author:
  Alexander Verbraeck

### Constructor Summary

Constructors
Constructor and Description
`AbstractXMLParser(URL url, URL schema, String schemaNamespace, boolean validateSchema)` Parses an XML file and validates it against a schema XSD.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected Element` `parse()` This method carries out the task of parsing an XML file and validates it against a schema XSD.
`protected abstract void` `parse(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` - URL; the URL of the XML file to read.
  `schema` - URL; the URL of the XSD schema file to validate against.
  `schemaNamespace` - String; the namespace of the schema
  `validateSchema` - boolean; whether to validate the schema file.

### Method Detail

#### parse

    protected 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(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` - Element; the root element
Throws:
  `Exception` - on failure