You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by co...@locus.apache.org on 2000/09/27 21:49:35 UTC

cvs commit: xml-xalan/src/org/apache/xalan/xslt Process.java XSLTEngineImpl.java

costin      00/09/27 12:49:33

  Modified:    src/org/apache/xalan/xslt Process.java XSLTEngineImpl.java
  Log:
  My first commit...
  
  Added code to detect if xerces is present in classpath. If it isn't,
  JaxpLiaison will be used.
  
  Revision  Changes    Path
  1.25      +28 -1     xml-xalan/src/org/apache/xalan/xslt/Process.java
  
  Index: Process.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/Process.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Process.java	2000/09/07 22:21:10	1.24
  +++ Process.java	2000/09/27 19:49:31	1.25
  @@ -174,7 +174,7 @@
       else
       {
         XMLParserLiaison xmlProcessorLiaison;
  -      String parserLiaisonClassName = Constants.LIAISON_CLASS;
  +      String parserLiaisonClassName = getDefaultLiaison();
         try
         {
           boolean usingDefault = true;
  @@ -1054,4 +1054,31 @@
       // System.out.println("url: "+url.toString());
       return url;
     }
  +
  +
  +  /** Avoid multiple detections, cache detection result.
  +     -1 == no detection took place,
  +      0  == no xerces , use jaxp
  +      1  = xerces exists in classpath
  +   */
  +  private static int xercesDetected=-1;
  +
  +  static String getDefaultLiaison() {
  +    if( xercesDetected==-1) {
  +      try {
  +	// If this throws an exception we'll use JaxpLiaison
  +	// This detects if xerces is present in classpath
  +	Class.forName("org.apache.xerces.dom.NodeImpl" );
  +	Class.forName("org.apache.xalan.xpath.xdom.XercesLiaison" );
  +	xercesDetected=1;
  +      } catch(Exception ex ) {
  +	xercesDetected=0;
  +      }
  +    }
  +    if( xercesDetected == 1)
  +      return Constants.LIAISON_CLASS;
  +    else 
  +      return "org.apache.xalan.xpath.xml.JaxpLiaison";
  +  }
  +
   }
  
  
  
  1.72      +1 -2      xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java
  
  Index: XSLTEngineImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- XSLTEngineImpl.java	2000/09/12 01:13:44	1.71
  +++ XSLTEngineImpl.java	2000/09/27 19:49:32	1.72
  @@ -359,8 +359,7 @@
     protected XSLTEngineImpl()
       throws org.xml.sax.SAXException
     {
  -    // Patch from Costin Manolache
  -    parserLiaisonClassName = Constants.LIAISON_CLASS;
  +    parserLiaisonClassName=Process.getDefaultLiaison();
       m_parserLiaison = createLiaison();
       m_parserLiaison.setEnvSupport(this);
     }