All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class de.tudarmstadt.ito.xmldbms.mapfactories.MapFactory_DTD

java.lang.Object
   |
   +----de.tudarmstadt.ito.xmldbms.mapfactories.MapFactory_DTD

public class MapFactory_DTD
extends Object
Create a Map from a DTD object.

MapFactory_DTD constructs tables and columns in which the element types and attributes described in the DTD object can be stored, then creates a Map that maps the element types and attributes to these tables and columns. The resulting Map cannot be used immediately with DBMSToDOM or DOMToDBMS because no connection has been set on it. Furthermore, it is possible that the tables referred to by the map don't yet exist. However, it can be serialized as a mapping document or used to generate CREATE TABLE statements.

For example, the following code creates a map from the DTD document.dtd, creates the tables, sets the connection, and then transfers data to the database:

    // Instantiate a new map factory and create a map.
    factory = new MapFactory_DTD();
    map = factory.createMapFromDTD(src, MapFactory_DTD.DTD_EXTERNAL, true, null);
// Create the tables used by the map. Note that this function calls // Map.getCreateTableStrings(), then executes each string in a // JDBC Statement. createTables(map);
// Set the database connection, then transfer the data to the database. map.setConnection(conn); domToDBMS = new DOMToDBMS(map); domToDBMS.storeDocument(doc);

MapFactory_DTD constructs tables and columns roughly as follows. Note that these tables and columns are not actually created in the database; to do this, the application must retrieve CREATE TABLE strings from the resulting Map and execute these in JDBC statements. The reason for this is that applications will commonly want to change the table structure predicted by MapFactory_DTD before actually creating tables or simply use this factory as a tool for creating Maps, which can be serialized with the Map.serialize() method.

WARNING! This code does not check for name collisions. A number of name collisions are possible. The possible table and column names are listed below. If these clash with each other, the result is missing tables and/or columns. If these clash with existing table names, the result is the inability to correctly transfer data to the database. You should also remember that table and column names in many databases are case insensitive, so collisions due to case folding are possible.

    Table name: element type name
    Column names:
       element type name + "PK"
       element type name + "PCDATA"
       element type name + "PCDATA" + "Order"
       parent element type name + "FK"
       child element type name + "FK"
       child element type name + "Order"
       attribute name
    Table name: attribute name
    Column names:
       element type name + "FK"
       attribute name
       attribute name + "Order"
    Table name: element type name + "PCDATA"
    Column names:
       element type name + "FK"
       element type name + "PCDATA"
       element type name + "PCDATA" + "Order"
 

Version:
1.01
Author:
Ronald Bourret, Technical University of Darmstadt

Variable Index

 o DTD_EXTERNAL
DTD is an external subset.
 o DTD_XMLDOCUMENT
The DTD is in an XML document, as an internal subset, reference to an external subset, or both.
 o SCHEMA_DCD
Schema document uses DCD (not supported).
 o SCHEMA_DDML
Schema document uses DDML.
 o SCHEMA_SOX
Schema document uses SOX (not supported).
 o SCHEMA_W3C
Schema document uses W3C XML Schemas (not supported).
 o SCHEMA_XMLDATA
Schema document uses XML-Data (not supported).

Constructor Index

 o MapFactory_DTD()
Construct a new MapFactory_DTD.

Method Index

 o createMap(DTD, boolean)
Create a map from a DTD object.
 o createMapFromDTD(InputSource, int, boolean, Hashtable)
Create a map from an InputSource representing an external DTD subset or an XML document containing a DTD.
 o createMapFromSchema(InputSource, int, boolean, Parser)
Create a map from an InputSource representing a schema.

Variables

 o SCHEMA_DCD
 public static final int SCHEMA_DCD
Schema document uses DCD (not supported).

 o SCHEMA_DDML
 public static final int SCHEMA_DDML
Schema document uses DDML.

 o SCHEMA_SOX
 public static final int SCHEMA_SOX
Schema document uses SOX (not supported).

 o SCHEMA_W3C
 public static final int SCHEMA_W3C
Schema document uses W3C XML Schemas (not supported).

 o SCHEMA_XMLDATA
 public static final int SCHEMA_XMLDATA
Schema document uses XML-Data (not supported).

 o DTD_EXTERNAL
 public static final int DTD_EXTERNAL
DTD is an external subset.

 o DTD_XMLDOCUMENT
 public static final int DTD_XMLDOCUMENT
The DTD is in an XML document, as an internal subset, reference to an external subset, or both.

Constructors

 o MapFactory_DTD
 public MapFactory_DTD()
Construct a new MapFactory_DTD.

Methods

 o createMapFromDTD
 public Map createMapFromDTD(InputSource src,
                             int type,
                             boolean storeOrder,
                             Hashtable namespaceURIs) throws InvalidMapException, DTDException, EOFException, MalformedURLException, IOException
Create a map from an InputSource representing an external DTD subset or an XML document containing a DTD.

Parameters:
filename - The name of the schema file.
type - DTD_EXTERNAL or DTD_XMLDOCUMENT.
storeOrder - Whether the map should store order information in the database.
namespaceURIs - A Hashtable using prefixes as keys and namespace URIs as values. May be null.
Returns:
The Map object.
Throws: InvalidMapException
Thrown if a mapping error occurs.
Throws: DTDException
Thrown if a DTD error is found.
Throws: EOFException
Thrown if EOF is reached prematurely.
Throws: MalformedURLException
Thrown if a system ID is malformed.
Throws: IOException
Thrown if an I/O error occurs.
 o createMapFromSchema
 public Map createMapFromSchema(InputSource src,
                                int type,
                                boolean storeOrder,
                                Parser parser) throws InvalidMapException, SAXException, IOException
Create a map from an InputSource representing a schema.

Currently, only DDML files are supported.

Parameters:
filename - The name of the schema file.
type - The schema type: SCHEMA_DCD, SCHEMA_DDML, SCHEMA_SOX, SCHEMA_XMLDATA, SCHEMA_W3C.
storeOrder - Whether the map should store order information in the database.
parser - A SAX Parser to parse the InputSource.
Returns:
The Map object.
Throws: InvalidMapException
Thrown if a mapping error occurs.
Throws: SAXException
Thrown if a SAX error occurs.
Throws: IOException
Thrown if an I/O error occurs.
 o createMap
 public Map createMap(DTD dtd,
                      boolean storeOrder) throws InvalidMapException
Create a map from a DTD object.

Parameters:
dtd - A DTD object from which to create the Map.
storeOrder - Whether the map should store order information in the database.
Returns:
The Map object.
Throws: InvalidMapException
Thrown if a map error occurs.

All Packages  Class Hierarchy  This Package  Previous  Next  Index