Develop > Application Configuration > Manage XML configuration files > Example: Travel Manager application and XML configuration file

Example: Travel manager application and XML configuration file

This section describes an example web application that uses a simple XML file to control its configuration and shows how to create an application configuration to manage that file.

Travel Manager is a web application designed to help people manage their travel by performing such tasks as booking hotels, rental cars, tracking expenses, and so on. Travel Manager uses the MySQL Relational Database Management System (RDMS) as the repository for user data and some of the application’s configuration data.

Since the Travel Manager is designed to be deployed over many different networks, each with a different database server, it is important to provide flexibility in the information used to connect to the MySQL server. The application is designed to retrieve connection information from an XML configuration file, mysql.xml.

With application configurations, you can set the configuration file values necessary for accessing the local MySQL database. For example, the user name and password used to open a connection to the database may be different for each installation of the Travel Manager application. Modifications to these values can be made to the configuration file without requiring a recompilation of the Travel Manager application code.

Only four values in the file mysql.xml are required for the Travel Manager to be able to connect to the local MySQL database, each of which is represented as an element in the application’s XML file:

  • Host: Host name of the server on which the MySQL RDMS has been installed.
  • Name: Name of the database on the host server.
  • User: User name credentials used to open a connection to the database.
  • Password: Password necessary to open a connection to the database.

Contents of the Travel Manager mysql.xml file

The following is an example of the Travel Manager mysql.xml configuration file:

<?xml version="1.0" ?> 
<db-config>
  <db-host>localhost</db-host> 
  <db-name>wrightevents</db-name> 
  <db-user>root</db-user> 
  <db-password>hp-pass</db-password> 
</db-config>

Contents of the Travel Manager mysql.xml DTD-based XML file

The following is an example of the Travel Manager mysql.xml configuration file that references a DTD:

<?xml version="1.0"?>
<!DOCTYPE db-config PUBLIC "-//Williams Events//Travel Manager//EN" "mysql2.dtd">
<db-config>
	<db-host>localhost</db-host>
	<db-name>wrightevents</db-name>
	<db-user>root</db-user>
	<db-password>hp-pass</db-password>
</db-config>