Using DataBeanOpaque to get DTD name prior to choosing binding classes

FileInputStream fiStream =    new FileInputStream(xmlFileName);

DataBeanOpaque recipeVersionUnknown =    new DataBeanOpaque(fiStream, false);

String dtdName = recipeVersionUnknown.    getDocTypeSystemID();

if (dtdName.equals("recipe.dtd"))

{

     // Do something with version 1 recipes.

      com.cooksmart.v1.Recipe = new     com.cooksmart.v1.Recipe(recipeVersionUnknown,     true);

.

.

}

else

{

     if (dtdName.equals("recipe_v2.dtd"))

  {

      // Do something with version 2 recipes.

      com.cooksmart.v2.Recipe = new    com.cooksmart.v2.Recipe(recipeVersionUnknown,    true);

.

.

  }

}