} catch( javax.xml.parsers.FactoryConfigurationError ex1 ) { throw new org.xml.sax.SAXException( ex1.toString() ); } catch( NoSuchMethodError ex2 ) {
} catch( javax.xml.parsers.FactoryConfigurationError ex1 ) { throw new org.xml.sax.SAXException( ex1.toString() ); } catch( NoSuchMethodError ex2 ) { }
  public Node parseToNode(Source source) throws TransformerException  {    if(source instanceof DOMSource)      return ((DOMSource)source).getNode();        InputSource xmlSource = SAXSource.sourceToInputSource(source);    if(null == xmlSource)    {      throw new TransformerException("Can't transform a Source of type "+        source.getClass().getName()+"!");    }    // Duplicate code from above... but slightly different.      // TODO: Work on this...    if (null != xmlSource.getSystemId())      m_urlOfSource = xmlSource.getSystemId();    Node doc = null;    try    {      // Get an already set XMLReader, or create one.      XMLReader reader = null;      if(source instanceof SAXSource)        reader = ((SAXSource)source).getXMLReader();      // Use JAXP1.1 ( if possible )      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 ) {      }      if (null == reader)      {        reader = XMLReaderFactory.createXMLReader();      }      try      {        reader.setFeature("http://xml.org/sax/features/namespace-prefixes",                          true);        reader.setFeature(                          "http://apache.org/xml/features/validation/dynamic", true);      }      catch (org.xml.sax.SAXException se)      {        // What can we do?        // TODO: User diagnostics.      }      // TODO: Handle Xerces DOM parser.      // Get the input content handler, which will handle the       // parse events and create the source tree.      ContentHandler inputHandler = getInputContentHandler();      Class inputHandlerClass = ((Object) inputHandler).getClass();      inputHandler = (ContentHandler) inputHandlerClass.newInstance();      reader.setContentHandler(inputHandler);      if(inputHandler instanceof org.xml.sax.DTDHandler)        reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);      try      {        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)          reader.setProperty("http://xml.org/sax/properties/lexical-handler",                             inputHandler);        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)          reader.setProperty("http://xml.org/sax/properties/declaration-handler",                             inputHandler);      }      catch(SAXNotRecognizedException snre){}      try      {        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)          reader.setProperty("http://xml.org/sax/handlers/LexicalHandler",                             inputHandler);        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)          reader.setProperty("http://xml.org/sax/handlers/DeclHandler",                             inputHandler);      }      catch(org.xml.sax.SAXNotRecognizedException snre)      {      }      getXPathContext().setPrimaryReader(reader);      // ...and of course I need a standard way to get a node...      if (inputHandler instanceof org.apache.xalan.stree.SourceTreeHandler)      {        // Kick off the parse.  When the ContentHandler gets         // the startDocument event, it will call transformNode( node ).        reader.parse(xmlSource);        doc =             ((org.apache.xalan.stree.SourceTreeHandler) inputHandler).getRoot();      }    }    catch (java.lang.IllegalAccessException iae)    {      throw new TransformerException(iae);    }    catch (InstantiationException ie)    {      throw new TransformerException(ie);    }    catch(org.xml.sax.SAXException se)    {      throw new TransformerException(se);    }    catch (IOException ioe)    {      throw new TransformerException(ioe);    }    return doc;  }