santiagopg    2003/11/20 10:01:49

  Modified:    java/src/org/apache/xalan/xsltc/trax
                        TransformerFactoryImpl.java
  Log:
  Moved and modified Xerces' fallback code for the creation of XMLReaders. This 
fallback does not belong here and will be removed after we figure out why is 
needed.
  
  Revision  Changes    Path
  1.68      +23 -19    
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
  
  Index: TransformerFactoryImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- TransformerFactoryImpl.java       18 Nov 2003 23:25:00 -0000      1.67
  +++ TransformerFactoryImpl.java       20 Nov 2003 18:01:49 -0000      1.68
  @@ -129,16 +129,7 @@
       public final static String DEBUG = "debug";
       public final static String ENABLE_INLINING = "enable-inlining";
       public final static String INDENT_NUMBER = "indent-number";
  -    
  -    static {
  -        // If 'org.xml.sax.driver' not set, default to Xerces
  -        String saxDriver = System.getProperty("org.xml.sax.driver");
  -        if (saxDriver == null) {
  -            System.setProperty("org.xml.sax.driver", 
  -                               "org.apache.xerces.parsers.SAXParser");       
                       
  -        }        
  -    }
  -    
  +        
       /**
        * This error listener is used only for this factory and is not passed to
        * the Templates or Transformer objects that we create.
  @@ -1061,15 +1052,28 @@
        }
        XMLReader result = (XMLReader) _xmlReader.get();
        if (result == null) {
  +            try {
  +                /*
  +                 * Fix for bug 24695
  +                 * According to JAXP 1.2 specification if a SAXSource
  +                 * is created using a SAX InputSource the Transformer or
  +                 * TransformerFactory creates a reader via the 
XMLReaderFactory
  +                 * if setXMLReader is not used
  +                 */
  +                result = XMLReaderFactory.createXMLReader();
  +            }
  +            catch (Exception e) {
  +               try {
  +                    // If unable to create an instance, let's try to use 
Xerces
  +                    Class clazz = 
Thread.currentThread().getContextClassLoader()
  +                        .loadClass("org.apache.xerces.parsers.SAXParser");
  +                    result = (XMLReader) clazz.newInstance();
  +                }
  +                catch (ClassNotFoundException cnfe) {
  +                    throw e;   // ignore cnfe
  +                }
  +            }
    
  -            /*
  -              * Fix for bug 24695
  -              * According to JAXP 1.2 specification if a SAXSource
  -              * is created using a SAX InputSource the Transformer or
  -              * TransformerFactory creates a reader via the XMLReaderFactory
  -              * if setXMLReader is not used
  -              */
  -            result = XMLReaderFactory.createXMLReader();
               result.setFeature("http://xml.org/sax/features/namespaces";,
                  true);
               
result.setFeature("http://xml.org/sax/features/namespace-prefixes";,
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to