XML and Databases

Ronald Bourret

Consulting, writing, and research in XML and databases

XML Guild

Member

XML-DBMS: Known bugs

Values are placed in the wrong elements / attributes when retrieving data from a result set in version 2.0.

The version of Transfer in the alpha 3 release (incorrectly) does not call org.xmlmiddleware.xmldbms.maps.utils.MetadataInitializer, which is used to match result set columns to mapping information. To fix this, you need to make the changes to org.xmlmiddleware.xmldbms.tools.Transfer listed below.

  • Add the following import:

       import org.xmlmiddleware.xmldbms.maps.utils.*;
    
  • Modify the method private Document retrieveDocumentInternal(Properties configProps, String mapFilename, Properties selects, String filterFilename, Hashtable params) so that it calls initTableMetadata:

       private Document retrieveDocumentInternal(Properties configProps,
                String mapFilename, Properties selects, String filterFilename,
                Hashtable params)
          throws XMLMiddlewareException, SQLException
       {
          ...
          resultSets = createResultSets(selects);
          transferInfo = createTransferInfo(map);
          filterSet = createFilterSet(map, filterFilename,
                                      (validate.indexOf(XMLDBMSProps.FILTERTOKEN) != -1));
    
          // New line of code:
          initTableMetadata(map, resultSets, filterSet);
    
          // Configure the DBMSToDOM object
          ...
       }
    
  • Add the following method:

       private void initTableMetadata(XMLDBMSMap map, Hashtable resultSets, FilterSet filterSet)
          throws XMLMiddlewareException
       {
          MetadataInitializer initializer;
          Vector filters;
          Object o;
          ResultSetFilter rsFilter;
          String rsName;
          ResultSet rs;
          Table table;
    
          // Get a new MetadataInitializer.
    
          initializer = new MetadataInitializer(map);
    
          // Get the Vector of RootFilters and ResultSetFilters. Loop through the
          // filters and, for each ResultSetFilter that is found, use the result set
          // metadata to initialize the corresponding table metadata. Note that
          // ResultSetFilters associate result set names with table names.
    
          filters = filterSet.getFilters();
          for (int i = 0; i < filters.size(); i++)
          {
             // Get the next object and process it if it is a ResultSetFilter.
    
             o = filters.elementAt(i);
             if (o instanceof ResultSetFilter)
             {
                rsFilter = (ResultSetFilter)o;
    
                // Get the name of the result set specified in the filter and
                // get the corresponding ResultSet object.
    
                rsName = rsFilter.getResultSetName();
                rs = (ResultSet)resultSets.get(rsName);
                if (rs == null)
                   throw new XMLMiddlewareException("Filter document specifies a " +
                      "result set with the name " + rsName + ". No result set with " +
                      "this name was specified in the properties passed to Transfer.");
    
                // Get the name of the table specified in the filter; this is the
                // name of the table in the map that maps the result set. Get the
                // corresponding Table object.
    
                table = map.getTable(rsFilter.getDatabaseName(),
                rsFilter.getCatalogName(),
                rsFilter.getSchemaName(),
                rsFilter.getTableName());
                if (table == null)
                   throw new XMLMiddlewareException("Table specified in " +
                      "filter document but not found in map: " +
                      Table.getUniversalName(rsFilter.getDatabaseName(),
                         rsFilter.getCatalogName(), rsFilter.getSchemaName(),
                         rsFilter.getTableName()));
    
                // Initialize the metadata for the columns in the table from
                // the result set metadata.
    
                initializer.initializeMetadata(table, rs);
             }
          }
       }
    

Copyright (c) 2009, Ronald Bourret