mrglavas    2004/02/16 16:01:50

  Modified:    java/src/org/apache/xerces/parsers AbstractDOMParser.java
  Log:
  Some improvements. If the document class name is our PSVI

  implementation don't go through ObjectFactory. Load it with

  the current classloader like we do for DocumentImpl. Also,

  made some minor performance fixes. If we're loading some

  other Document implementation only lookup the classloader

  once instead of three times.
  
  Revision  Changes    Path
  1.107     +21 -5     
xml-xerces/java/src/org/apache/xerces/parsers/AbstractDOMParser.java
  
  Index: AbstractDOMParser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/AbstractDOMParser.java,v
  retrieving revision 1.106
  retrieving revision 1.107
  diff -u -r1.106 -r1.107
  --- AbstractDOMParser.java    16 Feb 2004 05:43:11 -0000      1.106
  +++ AbstractDOMParser.java    17 Feb 2004 00:01:50 -0000      1.107
  @@ -75,6 +75,7 @@
   import org.apache.xerces.dom.NodeImpl;
   import org.apache.xerces.dom.NotationImpl;
   import org.apache.xerces.dom.PSVIAttrNSImpl;
  +import org.apache.xerces.dom.PSVIDocumentImpl;
   import org.apache.xerces.dom.PSVIElementNSImpl;
   import org.apache.xerces.dom.TextImpl;
   import org.apache.xerces.dom3.DOMError;
  @@ -368,7 +369,8 @@
               documentClassName = DEFAULT_DOCUMENT_CLASS_NAME;
           }
           
  -        if (!documentClassName.equals(DEFAULT_DOCUMENT_CLASS_NAME)) {
  +        if (!documentClassName.equals(DEFAULT_DOCUMENT_CLASS_NAME) &&
  +            !documentClassName.equals(PSVI_DOCUMENT_CLASS_NAME)) {
               // verify that this class exists and is of the right type
               try {
                   Class _class = ObjectFactory.findProviderClass (documentClassName,
  @@ -782,22 +784,36 @@
                   // set documentURI
                   fDocumentImpl.setDocumentURI (locator.getExpandedSystemId ());
               }
  +            else if (fDocumentClassName.equals (PSVI_DOCUMENT_CLASS_NAME)) {
  +                fDocument = new PSVIDocumentImpl();
  +                fDocumentImpl = (CoreDocumentImpl)fDocument;
  +                fStorePSVI = true;
  +                // REVISIT: when DOM Level 3 is REC rely on Document.support
  +                //          instead of specific class
  +                // set DOM error checking off
  +                fDocumentImpl.setStrictErrorChecking (false);
  +                // set actual encoding
  +                fDocumentImpl.setInputEncoding (encoding);
  +                // set documentURI
  +                fDocumentImpl.setDocumentURI (locator.getExpandedSystemId ());
  +            }
               else {
                   // use specified document class
                   try {
  +                    ClassLoader cl = ObjectFactory.findClassLoader();
                       Class documentClass = ObjectFactory.findProviderClass 
(fDocumentClassName,
  -                    ObjectFactory.findClassLoader (), true);
  +                        cl, true);
                       fDocument = (Document)documentClass.newInstance ();
                       
                       // if subclass of our own class that's cool too
                       Class defaultDocClass =
                       ObjectFactory.findProviderClass (CORE_DOCUMENT_CLASS_NAME,
  -                    ObjectFactory.findClassLoader (), true);
  +                        cl, true);
                       if (defaultDocClass.isAssignableFrom (documentClass)) {
                           fDocumentImpl = (CoreDocumentImpl)fDocument;
                           
                           Class psviDocClass = ObjectFactory.findProviderClass 
(PSVI_DOCUMENT_CLASS_NAME,
  -                        ObjectFactory.findClassLoader (), true);
  +                            cl, true);
                           if (psviDocClass.isAssignableFrom (documentClass)) {
                               fStorePSVI = true;
                           }
  
  
  

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

Reply via email to