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.
- Generates a table for each complex element type. The table is named the same
as the element type. It has a single primary key column with the name of the element
type plus "PK", a column for each singly-valued attribute, and a column for each
singly-occurring simple child. If the element type appears in the content model
of any other element types, it contains a foreign key column for the parent element
type.
- Generates a table for each multi-valued attribute (types IDREFS, NMTOKENS, and
ENTITIES). The table is named the same as the attribute. It has a single primary
key column with the name of the attribute plus "PK", a single foreign key column
with the name of the parent element type plus "FK", a data column with the
name of the attribute, and an optional order column.
- Generates a table for each multiply-occuring simple child. The table is named
the same as the child element type. Its columns parallel those in an attribute table.
- Generates a table for PCDATA in mixed content. The table is named the same as
the parent element type plus "PCDATA". Its columns parallel those in an attribute
table.
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
-
DTD_EXTERNAL
- The document is a DTD.
-
DTD_XMLDOCUMENT
- The document is an XML document which contains and/or references a DTD.
-
ORDER_COLUMNS
- Generate order columns.
-
ORDER_FIXED
- Generate fixed order values.
-
ORDER_NONE
- Do not generate order information (default).
-
MapFactory_DTD()
- Construct a new MapFactory_DTD.
-
createMap(DTD)
- Create a map from a DTD object.
-
createMap(InputSource, int, Hashtable)
- Create a map from an InputSource representing an external DTD subset or
an XML document containing a DTD.
-
setConnection(Connection)
- Set the database connection.
-
setDatabaseNames(String, String, String)
- Set the catalog and schema names to use in the map.
-
setOrderType(int)
- Set how/if order is to be generated.
DTD_EXTERNAL
public static final int DTD_EXTERNAL
- The document is a DTD.
DTD_XMLDOCUMENT
public static final int DTD_XMLDOCUMENT
- The document is an XML document which contains and/or references a DTD.
ORDER_NONE
public static final int ORDER_NONE
- Do not generate order information (default).
ORDER_FIXED
public static final int ORDER_FIXED
- Generate fixed order values.
ORDER_COLUMNS
public static final int ORDER_COLUMNS
- Generate order columns.
MapFactory_DTD
public MapFactory_DTD()
- Construct a new MapFactory_DTD.
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
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.
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.
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.
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