All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.xmlmiddleware.xmldbms.maps.factories.MapFactory_DTD

java.lang.Object
   |
   +----org.xmlmiddleware.xmldbms.maps.factories.MapFactory_DTD

public class MapFactory_DTD
extends Object
Create an XMLDBMSMap from a DTD.

MapFactory_DTD constructs an XMLDBMSMap object from a DTD. Based on the structure of the DTD, it predicts a set of tables and columns to which the element types and attributes can be mapped, then constructs an XMLDBMSMap that does this.

MapFactory_DTD does not construct the tables and columns it uses. This is the responsibility of the user. As a general rule, the caller will want to serialize the generated map (with the MapSerializer utility), modify it by hand as needed, then generate CREATE TABLE statements (with the DDLGenerator utility) that can be used to create the tables in the database.

MapFactory_DTD constructs a map roughly as follows. The term complex element type refers to an element type that has attributes and/or child elements. The term simple element type refers to an element type that has no attributes and contains only PCDATA.

The code modifies names and checks for name collisions as specified in the DBNameChecker class. All key columns have type INTEGER and all data columns have type VARCHAR(255). As a general rule, the data types for data columns need to be changed to something more useful.

Version:
2.0
Author:
Ronald Bourret

Variable Index

 o DTD_EXTERNAL
The document is a DTD.
 o DTD_XMLDOCUMENT
The document is an XML document which contains and/or references a DTD.
 o ORDER_COLUMNS
Generate order columns.
 o ORDER_FIXED
Generate fixed order values.
 o ORDER_NONE
Do not generate order information (default).

Constructor Index

 o MapFactory_DTD()
Construct a new MapFactory_DTD.

Method Index

 o createMap(DTD)
Create a map from a DTD object.
 o createMap(InputSource, int, Hashtable)
Create a map from an InputSource representing an external DTD subset or an XML document containing a DTD.
 o setConnection(Connection)
Set the database connection.
 o setDatabaseNames(String, String, String)
Set the catalog and schema names to use in the map.
 o setOrderType(int)
Set how/if order is to be generated.

Variables

 o DTD_EXTERNAL
 public static final int DTD_EXTERNAL
The document is a DTD.

 o DTD_XMLDOCUMENT
 public static final int DTD_XMLDOCUMENT
The document is an XML document which contains and/or references a DTD.

 o ORDER_NONE
 public static final int ORDER_NONE
Do not generate order information (default).

 o ORDER_FIXED
 public static final int ORDER_FIXED
Generate fixed order values.

 o ORDER_COLUMNS
 public static final int ORDER_COLUMNS
Generate order columns.

Constructors

 o MapFactory_DTD
 public MapFactory_DTD()
Construct a new MapFactory_DTD.

Methods

 o setConnection
 public void setConnection(Connection conn) throws SQLException
Set the database connection.

If set, the database connection is used to create database names that conform to the rules of the specified database. Otherwise, database names will be constructed according to a default set of rules. For details, see DBNameChecker.

Parameters:
conn - The connection. May be null.
Throws: SQLException
Thrown if an error occurs retrieving metadata from the connection.
See Also:
DBNameChecker
 o setOrderType
 public void setOrderType(int orderType)
Set how/if order is to be generated.

For more information, see the descriptions of the OrderColumn, TLOrderColumn, and FixedOrder elements of the XML-DBMS mapping language.

Parameters:
orderType - ORDER_NONE, ORDER_FIXED, or ORDER_COLUMNS.
 o setDatabaseNames
 public void setDatabaseNames(String databaseName,
                              String catalogName,
                              String schemaName)
Set the catalog and schema names to use in the map.

Parameters:
databaseName - The database name. If this is null, "DEFAULT" will be used.
catalogName - The catalog name. May be null.
schemaName - The schema name. May be null.
 o createMap
 public XMLDBMSMap createMap(InputSource src,
                             int type,
                             Hashtable namespaceURIs) throws XMLMiddlewareException, SQLException, IOException, MalformedURLException, EOFException
Create a map from an InputSource representing an external DTD subset or an XML document containing a DTD.

Parameters:
src - A SAX InputSource representing the document.
type - DTD_EXTERNAL or DTD_XMLDOCUMENT.
namespaceURIs - A Hashtable using prefixes as keys and namespace URIs as values. The prefixes correspond to those used in the DTD. May be null.
Returns:
The XMLDBMSMap object.
Throws: XMLMiddlewareException
Thrown if a DTD or map error occurs.
Throws: IOException
Thrown if an IO exception occurs parsing the DTD.
Throws: EOFException
Thrown if an EOF exception occurs parsing the DTD.
Throws: IOException
Thrown if a system ID in the DTD is malformed.
Throws: SQLException
Thrown if an error occurs checking a table name against the database.
 o createMap
 public XMLDBMSMap createMap(DTD dtd) throws XMLMiddlewareException, SQLException
Create a map from a DTD object.

Parameters:
dtd - The DTD object
Returns:
The XMLDBMSMap.
Throws: XMLMiddlewareException
Thrown if a map error occurs.
Throws: SQLException
Thrown if an error occurs checking a table name against the database.

All Packages  Class Hierarchy  This Package  Previous  Next  Index