code: private Object readMetadataFromXML(InputSource source, Class target)
              throws MalformedURLException, ParserConfigurationException, SAXException, IOException
      {
          // TODO: make this configurable
          boolean validate = false;
          
          // get a xml reader instance:
          SAXParserFactory factory = SAXParserFactory.newInstance();
          log.info("RepositoryPersistor using SAXParserFactory : " + factory.getClass().getName());
          if (validate)
          {
              factory.setValidating(true);
          }
          SAXParser p = factory.newSAXParser();
          XMLReader reader = p.getXMLReader();
          if (validate)
          {
              reader.setErrorHandler(new OJBErrorHandler());
          }
  
          Object result;
          if (DescriptorRepository.class.equals(target))
          {
              // create an empty repository:
              DescriptorRepository repository = new DescriptorRepository();
              // create handler for building the repository structure
              ContentHandler handler = new RepositoryXmlHandler(repository);
              // tell parser to use our handler:
              reader.setContentHandler(handler);
              reader.parse(source);
              result = repository;
          }
          else if (ConnectionRepository.class.equals(target))
          {
              // create an empty repository:
              ConnectionRepository repository = new ConnectionRepository();
              // create handler for building the repository structure
              ContentHandler handler = new ConnectionDescriptorXmlHandler(repository);
              // tell parser to use our handler:
              reader.setContentHandler(handler);
              reader.parse(source);
              //LoggerFactory.getBootLogger().info("loading XML took " + (stop - start) + " msecs");
              result = repository;
          }
          else
              throw new MetadataException("Could not build a repository instance for '" + target +
                      "', using source " + source);
          return result;
      }
docs: Read metadata by populating an instance of the target class
  using SAXParser.