1.0 Introduction
2.0 Getting started
2.1 System requirements
2.2 Downloading and installing XML-DBMS
3.0 Using version 2.0
3.1 Configuring XML-DBMS
3.2 Converting 1.x maps to 2.0 maps
3.3 Using the MapManager tool
3.3.1 Using the MapManager tool from the command line
3.3.2 Using the MapManager tool API
3.3.3 Samples
3.4 Using the Transfer tool
3.4.1 Using the Transfer tool from the command line
3.4.2 Using the Transfer tool API
3.4.3 Samples
3.5 Writing your own application
3.6 Interfaces
3.7 Known bugs
3.8 Missing components
4.0 Licensing and support
4.1 Licensing
4.2 Support
4.3 How can I help?
4.4 Contributors
XML-DBMS is a set of Java packages for transferring data between XML documents and relational databases. This is the documentation for XML-DBMS version 2.0. If you are not familiar with XML-DBMS, see the version 1.01 readme file. Although the mapping language in version 2.0 is different from the mapping language in version 1.x, the basic ideas are the same.
Version 2.0 adds a number of new features, including:
To run XML-DBMS, you need the following software:
To download XML-DBMS version 2.0, see:
To install XML-DBMS version 2.0 from a .zip file:
Unzip the downloaded file with a tool such as jar or WinZip.
Add xmldbms20.jar to your CLASSPATH. For example:
c:\java\xmldbms20\xmldbms20.jar;c:\java\jdk1.2.1\bin;c:\java\xerces-1_4_4\xerces.jar;.\
You can use XML-DBMS in one of two ways:
If you write your own application, please note that version 2.0 is NOT backwards-compatible with version 1.x.
Regardless of how you use XML-DBMS, you will need to configure it to use your database, XML documents, XML parser, etc. This consists of the following steps:
Write or generate a 2.0 map file, or convert a 1.x map file to 2.0. For more information, see Using the MapManager tool, Converting 1.x maps to 2.0 maps, and xmldbms2.dtd.
If you will use the Transfer tool to transfer data from XML to the database or to delete data, write one or more action documents. You also need action documents if you are calling DOMToDBMS or DBMSDelete directly and want to perform more than a single action on the data in your document -- for example, you want to mix inserts and insert-or-updates. For more information, see actions.dtd.
If you will transfer data from the database to XML or delete data, write one or more filter documents. For more information, see filters.dtd.
Write/compile implementations of interfaces as needed. For more information, see Interfaces.
XML-DBMS version 2.0 ships with an XSLT style sheet that converts 1.x map files to 2.0 map files. This is named V1MapToV2Map.xslt and can be found in the directory you installed XML-DBMS in. Thanks to Dan Wolfe for writing this.
WARNING: The conversion is only partial -- you need to edit the resulting XSLT file -- but should help in converting large numbers of map files. Changes to the XSLT file that make the conversion more complete are welcome.
The MapManager tool in the org.xmlmiddleware.xmldbms.tools package provides a simple command line interface for generating maps and related documents, such as DTDs and CREATE TABLE statements. It also provides a simple, high-level API for people writing map editing tools. It is designed so all configuration information (which parser and JDBC driver to use, database URL, etc.) can be stored in properties files.
As a general rule, you will start with a DTD and generate a map file and a set of CREATE TABLE statements, or you will start with a database schema and generate a map file and a DTD. Regardless of where you start, you will probably need to edit the resulting map file and DTD / database schema by hand. There are two reasons for this. First, the generation tools cannot possibly predict some things, such as the data types to use when generating a map from a DTD. Second, your database structure will rarely exactly match your XML document structure. Although XML-DBMS can perform some simple transformations, you may need to map the database to a document with a different structure than yours (but which XML-DBMS can handle) and then use XSLT to transform this document to/from your own document when you actually transfer data.
The command line interface is the easiest way to use MapManager. With this, you pass information to MapManager as a series of property/value pairs. For example, the following command generates a map file and a database schema from a DTD:
java org.xmlmiddleware.xmldbms.tools.MapManager File1=xerces.props File2=db.props Input=DTD DTDFile=orders.dtd Output1=Map MapFile=orders.map Output2=SQL SQLFile=orders.sql
The Input property specifies the source of the map; legal values are Map (a map file), DTD, and Database. The Output property specifies what generate from the map; legal values are Map (generate a map file), DTD (generate a DTD file), and SQL (generate a file with CREATE TABLE statements). If you want more than one output, use numbered output properties (Output1, Output2, etc.) The XxxxFile properties specify what files to read from / write to.
The File1 and File2 properties indicate that the property values are the names of property files. These are particularly useful for properties that don't change often, such as parser and database properties.
NOTE: People who are not using XML-DBMS can still use the MapManager tool to generate DTDs from database schema and vice versa. To do this, just specify an Input value of DTD and an Output value of SQL, or an Input value of Database and an Output value of DTD, along with any other necessary properties.
For complete details about MapManager's command line syntax and what other properties are available, see the JavaDocs for MapManager.
You can also use MapManager programmatically. This is generally useful only if you are writing a map editing tool, such as a GUI-based map editor. MapManager provides a very simple API that consists of the following methods:
For complete details, see the the JavaDocs for MapManager.
The MapManager comes with a small set of samples, which you can find in the samples subdirectory:
orders.dtd -- DTD for a sales order document
There is also a DOS batch file (manage.bat) that runs the MapManager tool. It assumes that the parser properties are in parser.props, the database properties are in db.props, and the map manager properties (what you actually want to do) are in a file passed in on the command line. To use this, just type the following:
manage <property-file>
For example:
manage map.props
is equivalent to:
java org.xmlmiddleware.xmldbms.tools.MapManager File1=parser.props File2=db.props File3=map.props
The samples directory includes the following sample property files:
parser.props -- Parser properties for the Xerces parser db.props -- Database properties to use the Sun JDBC-ODBC Bridge map.props -- File to read a DTD and create a map file and an SQL file
The Transfer tool in the org.xmlmiddleware.xmldbms.tools package provides a simple command line interface to XML-DBMS, as well as a simple, high-level API. It is designed so all configuration information (which parser and JDBC driver to use, database URL, etc.) can be stored in properties files.
The command line interface is the easiest way to use Transfer. With this, you pass information to Transfer as a series of property/value pairs. For example, the following command stores the contents of the orders.xml document in the database:
java org.xmlmiddleware.xmldbms.tools.Transfer File1=xerces.props File2=db.props Method=StoreDocument MapFile=orders.map XMLFile=orders.xml ActionFile=orders.act
The Method property specifies the method to call (StoreDocument) and the MapFile, XMLFile, and ActionFile properties specify the names of the map, XML, and action files to use. The File1 and File2 properties indicate that the property values are the names of property files. These are particularly useful for properties that don't change often, such as parser and database properties.
For complete details about Transfer's command line syntax and what other properties are available, see the JavaDocs for Transfer.
You can also use Transfer programmatically. It provides a very simple API for XML-DBMS that consists of the following methods:
Transfer is optimized to reuse things like database connections and compiled map objects on subsequent calls, so it is a reasonably efficient way to use XML-DBMS with little effort. Again, for complete details, see the the JavaDocs for Transfer.
XML-DBMS comes with a small set of samples, which you can find in the samples subdirectory. Most of these are sample XML, map, action, and filter files:
orders.xml -- XML document showing a sales order orders.sql -- CREATE TABLE statements for the tables to which orders.xml is mapped orders.map -- Map file mapping orders.xml to four tables in the database orders1.act -- Action file for to insert orders.xml orders2.act -- Action file to update the item quantity in orders.xml delete.act -- Action file to delete orders and items but not customers or parts orders.ftr -- Filter file that uses only a root table filter ordersconst.ftr -- Filter file that uses constant values in WHERE clauses ordersparams.ftr -- Filter file that uses named parameters in WHERE clauses ordersrs.ftr -- Filter file that uses result sets
There is also a DOS batch file (transfer.bat) that runs the Transfer tool. It assumes that the parser properties are in parser.props, the database properties are in db.props, and the method properties (what you actually want to do) are in a file passed in on the command line. To use this, just type the following:
transfer <property-file>
For example:
transfer store.props
is equivalent to:
java org.xmlmiddleware.xmldbms.tools.Transfer File1=parser.props File2=db.props File3=store.props
The samples directory includes the following sample property files:
parser.props -- Parser properties for the Xerces parser db.props -- Database properties to use the Sun JDBC-ODBC Bridge delete.props -- Method properties to delete an order according to delete.act and orders.ftr retrieve.props -- Method properties to retrieve an order according to orders.ftr store.props -- Method properties to store an order according to orders1.act
For the most control over XML-DBMS, you can write your own application. Here are the basic steps:
Write code to set up your databases:
Write code to transfer data from an XML document to the database (if needed):
For examples of code that does this, see the following methods in the Transfer tool:
Note that the code in Transfer is probably more complex than most of your code will be. This is because Transfer needs to retrieve information from properties and check that it has gotten the correct information.
XML-DBMS abstracts a number of types of functionality through interfaces. Depending on your environment, you may need to write and/or compile implementations for these interfaces and add these to your CLASSPATH or the xmldbms20.jar file. The following interfaces are used:
javax.sql.DataSource. Provides JDBC Connections. Normally, you will use a DataSource shipped with your JDBC driver, a third-party DataSource, or one of the DataSources shipped with XML-DBMS.
org.xmlmiddleware.conversions.formatters.StringFormatter. Used for string formatting. You need to implement this only if the capabilities of the string formatters shipped with XML-DBMS are insufficient. XML-DBMS has built-in date and number formatters.
org.xmlmiddleware.xmlutils.ParserUtils. Abstracts parser functionality. You will need to implement this for any parser except Xerces.
org.xmlmiddleware.xmldbms.datahandlers.DataHandler. Executes SQL statements. In most cases, you can use GenericHandler or one of the database-specific implementations shipped with XML-DBMS.
org.xmlmiddleware.xmldbms.keygenerators.KeyGenerator. Generates keys. If you want to generate keys yourself, you must implement this. If you want to use the high-low scheme from XML-DBMS v1.01, start with the v1.1 version of this.
The following table shows what implementations are included in XML-DBMS version 2.0, and whether compiled versions of these are in xmldbms20.jar.
Interface | Implementations | .class in jar? |
---|---|---|
javax.sql.DataSource | org.xmlmiddleware.db.ArrayDataSource org.xmlmiddleware.db.JDBC1DataSource org.xmlmiddleware.db.JDBC2DataSource org.xmlmiddleware.db.StatementPoolDataSource |
Yes Yes Yes Yes |
org.xmlmiddleware.conversions.formatters.StringFormatter | org.xmlmiddleware.conversions.formatters.external.Base64Formatter org.xmlmiddleware.conversions.formatters.BooleanFormatter org.xmlmiddleware.conversions.formatters.CharFormatter org.xmlmiddleware.conversions.formatters.DateFormatter org.xmlmiddleware.conversions.formatters.NoFormatter org.xmlmiddleware.conversions.formatters.NumberFormatter |
Yes Yes Yes Yes Yes |
org.xmlmiddleware.xmlutils.ParserUtils | org.xmlmiddleware.xmlutils.external.ParserUtilsXerces | Yes |
org.xmlmiddleware.xmldbms.datahandlers.DataHandler | org.xmlmiddleware.xmldbms.datahandlers.GenericHandler org.xmlmiddleware.xmldbms.datahandlers.external.MySQLHandler org.xmlmiddleware.xmldbms.datahandlers.external.PostgresHandler org.xmlmiddleware.xmldbms.datahandlers.external.PostgresJDBXHandler |
Yes No No No |
org.xmlmiddleware.xmldbms.keygenerators.KeyGenerator | -- (KeyGeneratorHighLow to be added later) | -- |
Here is a list of known bugs in XML-DBMS version 2.0:
The following components have not been added to XML-DBMS version 2.0. If you are interested in implementing these features, please let me know.
XML-DBMS, along with its source code, is in the public domain. It is freely available for use in both commercial and non-commercial settings. It is not copyrighted and has absolutely no warranty. The following limitations apply:
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the author(s) be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
If you have questions about how to use XML-DBMS, the first thing you should do is read the documentation and look at the sample programs. If you want to check for known bugs, you have two options. First, check the XML-DBMS bug database on SourceForge. Second, look at the archives of the XML-DBMS mailing list, which lists many known bugs and frequently asked questions.
If you still have a question, you can send email to the mailing list at xml-dbms@yahoogroups.com. Although you must be a member of the mailing list to post messages, anyone can read the messages in the archives. You can join the mailing list and read the archives at:
http://groups.yahoo.com/group/xml-dbms
XML-DBMS is an ongoing Open Source project and depends on users for feedback, bug reports, and new code. The best way to help out is to join the mailing list and actively participate in discussions, find and fix bugs, suggest new features, and submit changes you have made for inclusion in future releases. For the latest news, check the XML-DBMS home page at:
http://www.rpbourret.com/xmldbms/index.htm
or the XML-DBMS project page on SourceForge:
https://sourceforge.net/projects/xmldbms/
Thanks to the many people who have contributed to XML-DBMS in the form of bug reports and suggested features. And special thanks to the following people, who have contributed significant amounts of code and design work:
Adam Flinton
Nick Semenov
Sean Walter
Tobias Schilgen
Himanshu Gupta