All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----de.tudarmstadt.ito.xmldbms.mapfactories.MapFactory_DTD
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"
public static final int SCHEMA_DCD
public static final int SCHEMA_DDML
public static final int SCHEMA_SOX
public static final int SCHEMA_W3C
public static final int SCHEMA_XMLDATA
public static final int DTD_EXTERNAL
public static final int DTD_XMLDOCUMENT
public MapFactory_DTD()
public Map createMapFromDTD(InputSource src,
int type,
boolean storeOrder,
Hashtable namespaceURIs) throws InvalidMapException, DTDException, EOFException, MalformedURLException, IOException
public Map createMapFromSchema(InputSource src,
int type,
boolean storeOrder,
Parser parser) throws InvalidMapException, SAXException, IOException
Currently, only DDML files are supported.
public Map createMap(DTD dtd,
boolean storeOrder) throws InvalidMapException
All Packages Class Hierarchy This Package Previous Next Index