@Override public void startDocument(XMLLocator locator,String encoding,NamespaceContext namespaceContext,Augmentations augs) throws XNIException {
  fLocator=locator;
  if (!fDeferNodeExpansion) {
    if (fDocumentClassName.equals(DEFAULT_DOCUMENT_CLASS_NAME)) {
      fDocument=new DocumentImpl();
      fDocumentImpl=(CoreDocumentImpl)fDocument;
      fDocumentImpl.setStrictErrorChecking(false);
      fDocumentImpl.setInputEncoding(encoding);
      fDocumentImpl.setDocumentURI(locator.getExpandedSystemId());
    }
 else     if (fDocumentClassName.equals(PSVI_DOCUMENT_CLASS_NAME)) {
      fDocument=new PSVIDocumentImpl();
      fDocumentImpl=(CoreDocumentImpl)fDocument;
      fStorePSVI=true;
      fDocumentImpl.setStrictErrorChecking(false);
      fDocumentImpl.setInputEncoding(encoding);
      fDocumentImpl.setDocumentURI(locator.getExpandedSystemId());
    }
 else {
      try {
        ClassLoader cl=ObjectFactory.findClassLoader();
        Class documentClass=ObjectFactory.findProviderClass(fDocumentClassName,cl,true);
        fDocument=(Document)documentClass.newInstance();
        Class defaultDocClass=ObjectFactory.findProviderClass(CORE_DOCUMENT_CLASS_NAME,cl,true);
        if (defaultDocClass.isAssignableFrom(documentClass)) {
          fDocumentImpl=(CoreDocumentImpl)fDocument;
          Class psviDocClass=ObjectFactory.findProviderClass(PSVI_DOCUMENT_CLASS_NAME,cl,true);
          if (psviDocClass.isAssignableFrom(documentClass)) {
            fStorePSVI=true;
          }
          fDocumentImpl.setStrictErrorChecking(false);
          fDocumentImpl.setInputEncoding(encoding);
          if (locator != null) {
            fDocumentImpl.setDocumentURI(locator.getExpandedSystemId());
          }
        }
      }
 catch (      ClassNotFoundException e) {
      }
catch (      Exception e) {
        throw new RuntimeException(DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,"CannotCreateDocumentClass",new Object[]{fDocumentClassName}));
      }
    }
    fCurrentNode=fDocument;
  }
 else {
    fDeferredDocumentImpl=new DeferredDocumentImpl(fNamespaceAware);
    fDocument=fDeferredDocumentImpl;
    fDocumentIndex=fDeferredDocumentImpl.createDeferredDocument();
    fDeferredDocumentImpl.setInputEncoding(encoding);
    fDeferredDocumentImpl.setDocumentURI(locator.getExpandedSystemId());
    fCurrentNodeIndex=fDocumentIndex;
  }
}

@ Override public void startDocument ( XMLLocator locator , String encoding , NamespaceContext namespaceContext , Augmentations augs ) throws XNIException { fLocator = locator ; if ( ! fDeferNodeExpansion ) { if ( fDocumentClassName . equals ( DEFAULT_DOCUMENT_CLASS_NAME ) ) { fDocument = new DocumentImpl ( ) ; fDocumentImpl = ( CoreDocumentImpl ) fDocument ; fDocumentImpl . setStrictErrorChecking ( false ) ; fDocumentImpl . setInputEncoding ( encoding ) ; fDocumentImpl . setDocumentURI ( locator . getExpandedSystemId ( ) ) ; } else if ( fDocumentClassName . equals ( PSVI_DOCUMENT_CLASS_NAME ) ) { fDocument = new PSVIDocumentImpl ( ) ; fDocumentImpl = ( CoreDocumentImpl ) fDocument ; fStorePSVI = true ; fDocumentImpl . setStrictErrorChecking ( false ) ; fDocumentImpl . setInputEncoding ( encoding ) ; fDocumentImpl . setDocumentURI ( locator . getExpandedSystemId ( ) ) ; } else { try { ClassLoader cl = ObjectFactory . findClassLoader ( ) ; Class documentClass = ObjectFactory . findProviderClass ( fDocumentClassName , cl , true ) ; fDocument = ( Document ) documentClass . newInstance ( ) ; Class defaultDocClass = ObjectFactory . findProviderClass ( CORE_DOCUMENT_CLASS_NAME , cl , true ) ; if ( defaultDocClass . isAssignableFrom ( documentClass ) ) { fDocumentImpl = ( CoreDocumentImpl ) fDocument ; Class psviDocClass = ObjectFactory . findProviderClass ( PSVI_DOCUMENT_CLASS_NAME , cl , true ) ; if ( psviDocClass . isAssignableFrom ( documentClass ) ) { fStorePSVI = true ; } fDocumentImpl . setStrictErrorChecking ( false ) ; fDocumentImpl . setInputEncoding ( encoding ) ; if ( locator != null ) { fDocumentImpl . setDocumentURI ( locator . getExpandedSystemId ( ) ) ; } } } catch ( ClassNotFoundException e ) { } catch ( Exception e ) { throw new RuntimeException ( DOMMessageFormatter . formatMessage ( DOMMessageFormatter . DOM_DOMAIN , "CannotCreateDocumentClass" , new Object [ ] { fDocumentClassName } ) ) ; } } fCurrentNode = fDocument ; } else { fDeferredDocumentImpl = new DeferredDocumentImpl ( fNamespaceAware ) ; fDocument = fDeferredDocumentImpl ; fDocumentIndex = fDeferredDocumentImpl . createDeferredDocument ( ) ; fDeferredDocumentImpl . setInputEncoding ( encoding ) ; fDeferredDocumentImpl . setDocumentURI ( locator . getExpandedSystemId ( ) ) ; fCurrentNodeIndex = fDocumentIndex ; } }
the start of the document .
