try { javax.xml.parsers.SAXParserFactory factory= javax.xml.parsers.SAXParserFactory.newInstance(); factory.setNamespaceAware( true ); javax.xml.parsers.SAXParser jaxpParser= factory.newSAXParser(); reader=jaxpParser.getXMLReader();  } catch( javax.xml.parsers.ParserConfigurationException ex ) { throw new org.xml.sax.SAXException( ex ); } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) { throw new org.xml.sax.SAXException( ex1.toString() ); } catch( NoSuchMethodError ex2 ) { }
  public Templates newTemplates(Source source)     throws TransformerConfigurationException  {    TemplatesHandler builder = newTemplatesHandler();        if(source instanceof DOMSource)    {      DOMSource dsource = (DOMSource)source;      Node node = dsource.getNode();      String baseID = dsource.getSystemId();      builder.setSystemId(baseID);      return processFromNode(node, baseID);    }        try    {      InputSource isource = SAXSource.sourceToInputSource(source);      XMLReader reader = null;      if (source instanceof SAXSource)        reader = ((SAXSource)source).getXMLReader();            if (null == reader)        reader = XMLReaderFactory.createXMLReader();      // If you set the namespaces to true, we'll end up getting double       // xmlns attributes.  Needs to be fixed.  -sb      // reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);      try      {        reader.setFeature("http://apache.org/xml/features/validation/dynamic",                          true);      }      catch (org.xml.sax.SAXException ex)      {        // feature not recognized      }      reader.setContentHandler(builder);      reader.parse(isource);    }    catch(IOException ioe)    {      throw new TransformerConfigurationException(ioe.getMessage(), ioe);    }    catch(org.xml.sax.SAXException se)    {      throw new TransformerConfigurationException(se.getMessage(), se);    }    return builder.getTemplates();  }