public function main()
    {
        $this->validate();

        $targetDatabase = $this->getTargetDatabase();

        $platform = $this->getGeneratorConfig()->getConfiguredPlatform();

        // Load the Data XML -> DB Name properties
        $map = new Properties();
        try {
            $map->load($this->getDataDbMap());
        } catch (IOException $ioe) {
            throw new BuildException("Cannot open and process the datadbmap!", $ioe);
        }

        // Parse each file in the data -> db map
        foreach ($map->keys() as $dataXMLFilename) {

            $dataXMLFile = new PhingFile($this->srcDir, $dataXMLFilename);

            // if file exists then proceed
            if ($dataXMLFile->exists()) {

                $dbname = $map->get($dataXMLFilename);

                $db = $this->getDatabase($dbname);

                if (!$db) {
                    throw new BuildException("Cannot find instantiated Database for name '$dbname' from datadbmap file.");
                }

                $db->setPlatform($platform);

                $outFile = $this->getMappedFile($dataXMLFilename);
                $sqlWriter = new FileWriter($outFile);

                $this->log("Creating SQL from XML data dump file: " . $dataXMLFile->getAbsolutePath());

                try {
                    $dataXmlParser = new XmlToDataSQL($db, $this->getGeneratorConfig(), $this->dbEncoding);
                    $dataXmlParser->transform($dataXMLFile, $sqlWriter);
                } catch (Exception $e) {
                    throw new BuildException("Exception parsing data XML: " . $e->getMessage());
                }

                // Place the generated SQL file(s)
                $p = new Properties();
                if ($this->getSqlDbMap()->exists()) {
                    $p->load($this->getSqlDbMap());
                }

                $p->setProperty($outFile->getName(), $db->getName());
                $p->store($this->getSqlDbMap(), "Sqlfile -> Database map");
            } else {
                $this->log("File '" . $dataXMLFile->getAbsolutePath() . "' in datadbmap does not exist, so skipping it.", Project::MSG_WARN);
            }
        } // foreach data xml file

    }