src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java

Print this page




 789     public XMLDocumentHandler getDocumentHandler(){
 790         return fDocumentHandler;
 791     }
 792 
 793     //
 794     // XMLEntityHandler methods
 795     //
 796 
 797     /**
 798      * This method notifies of the start of an entity. The DTD has the
 799      * pseudo-name of "[dtd]" parameter entity names start with '%'; and
 800      * general entities are just specified by their name.
 801      *
 802      * @param name     The name of the entity.
 803      * @param identifier The resource identifier.
 804      * @param encoding The auto-detected IANA encoding name of the entity
 805      *                 stream. This value will be null in those situations
 806      *                 where the entity encoding is not auto-detected (e.g.
 807      *                 internal entities or a document entity that is
 808      *                 parsed from a java.io.Reader).

 809      *
 810      * @throws XNIException Thrown by handler to signal an error.
 811      */
 812     public void startEntity(String name,
 813             XMLResourceIdentifier identifier,
 814             String encoding, Augmentations augs) throws XNIException {
 815 
 816         // keep track of this entity before fEntityDepth is increased
 817         if (fEntityDepth == fEntityStack.length) {
 818             int[] entityarray = new int[fEntityStack.length * 2];
 819             System.arraycopy(fEntityStack, 0, entityarray, 0, fEntityStack.length);
 820             fEntityStack = entityarray;
 821         }
 822         fEntityStack[fEntityDepth] = fMarkupDepth;
 823 
 824         super.startEntity(name, identifier, encoding, augs);
 825 
 826         // WFC:  entity declared in external subset in standalone doc
 827         if(fStandalone && fEntityStore.isEntityDeclInExternalSubset(name)) {
 828             reportFatalError("MSG_REFERENCE_TO_EXTERNALLY_DECLARED_ENTITY_WHEN_STANDALONE",
 829                     new Object[]{name});
 830         }
 831 
 832         /** we are not calling the handlers yet.. */
 833         // call handler
 834         if (fDocumentHandler != null && !fScanningAttribute) {
 835             if (!name.equals("[xml]")) {
 836                 fDocumentHandler.startGeneralEntity(name, identifier, encoding, null);
 837             }
 838         }
 839 
 840     } // startEntity(String,XMLResourceIdentifier,String)
 841 
 842     /**
 843      * This method notifies the end of an entity. The DTD has the pseudo-name
 844      * of "[dtd]" parameter entity names start with '%'; and general entities
 845      * are just specified by their name.
 846      *
 847      * @param name The name of the entity.

 848      *
 849      * @throws XNIException Thrown by handler to signal an error.
 850      */
 851     public void endEntity(String name, Augmentations augs) throws IOException, XNIException {
 852 
 853         /**
 854          * // flush possible pending output buffer - see scanContent
 855          * if (fInScanContent && fStringBuffer.length != 0
 856          * && fDocumentHandler != null) {
 857          * fDocumentHandler.characters(fStringBuffer, null);
 858          * fStringBuffer.length = 0; // make sure we know it's been flushed
 859          * }
 860          */
 861         super.endEntity(name, augs);
 862 
 863         // make sure markup is properly balanced
 864         if (fMarkupDepth != fEntityStack[fEntityDepth]) {
 865             reportFatalError("MarkupEntityMismatch", null);
 866         }
 867 
 868         /**/
 869         // call handler
 870         if (fDocumentHandler != null && !fScanningAttribute) {
 871             if (!name.equals("[xml]")) {
 872                 fDocumentHandler.endGeneralEntity(name, null);
 873             }
 874         }
 875 
 876 
 877     } // endEntity(String)
 878 
 879     //
 880     // Protected methods
 881     //
 882 
 883     // Driver factory methods
 884 
 885     /** Creates a content Driver. */
 886     protected Driver createContentDriver() {
 887         return new FragmentContentDriver();
 888     } // createContentDriver():Driver
 889 
 890     // scanning methods
 891 
 892     /**




 789     public XMLDocumentHandler getDocumentHandler(){
 790         return fDocumentHandler;
 791     }
 792 
 793     //
 794     // XMLEntityHandler methods
 795     //
 796 
 797     /**
 798      * This method notifies of the start of an entity. The DTD has the
 799      * pseudo-name of "[dtd]" parameter entity names start with '%'; and
 800      * general entities are just specified by their name.
 801      *
 802      * @param name     The name of the entity.
 803      * @param identifier The resource identifier.
 804      * @param encoding The auto-detected IANA encoding name of the entity
 805      *                 stream. This value will be null in those situations
 806      *                 where the entity encoding is not auto-detected (e.g.
 807      *                 internal entities or a document entity that is
 808      *                 parsed from a java.io.Reader).
 809      * @param augs     Additional information that may include infoset augmentations
 810      *
 811      * @throws XNIException Thrown by handler to signal an error.
 812      */
 813     public void startEntity(String name,
 814             XMLResourceIdentifier identifier,
 815             String encoding, Augmentations augs) throws XNIException {
 816 
 817         // keep track of this entity before fEntityDepth is increased
 818         if (fEntityDepth == fEntityStack.length) {
 819             int[] entityarray = new int[fEntityStack.length * 2];
 820             System.arraycopy(fEntityStack, 0, entityarray, 0, fEntityStack.length);
 821             fEntityStack = entityarray;
 822         }
 823         fEntityStack[fEntityDepth] = fMarkupDepth;
 824 
 825         super.startEntity(name, identifier, encoding, augs);
 826 
 827         // WFC:  entity declared in external subset in standalone doc
 828         if(fStandalone && fEntityStore.isEntityDeclInExternalSubset(name)) {
 829             reportFatalError("MSG_REFERENCE_TO_EXTERNALLY_DECLARED_ENTITY_WHEN_STANDALONE",
 830                     new Object[]{name});
 831         }
 832 
 833         /** we are not calling the handlers yet.. */
 834         // call handler
 835         if (fDocumentHandler != null && !fScanningAttribute) {
 836             if (!name.equals("[xml]")) {
 837                 fDocumentHandler.startGeneralEntity(name, identifier, encoding, augs);
 838             }
 839         }
 840 
 841     } // startEntity(String,XMLResourceIdentifier,String)
 842 
 843     /**
 844      * This method notifies the end of an entity. The DTD has the pseudo-name
 845      * of "[dtd]" parameter entity names start with '%'; and general entities
 846      * are just specified by their name.
 847      *
 848      * @param name The name of the entity.
 849      * @param augs Additional information that may include infoset augmentations
 850      *
 851      * @throws XNIException Thrown by handler to signal an error.
 852      */
 853     public void endEntity(String name, Augmentations augs) throws IOException, XNIException {
 854 
 855         /**
 856          * // flush possible pending output buffer - see scanContent
 857          * if (fInScanContent && fStringBuffer.length != 0
 858          * && fDocumentHandler != null) {
 859          * fDocumentHandler.characters(fStringBuffer, null);
 860          * fStringBuffer.length = 0; // make sure we know it's been flushed
 861          * }
 862          */
 863         super.endEntity(name, augs);
 864 
 865         // make sure markup is properly balanced
 866         if (fMarkupDepth != fEntityStack[fEntityDepth]) {
 867             reportFatalError("MarkupEntityMismatch", null);
 868         }
 869 
 870         /**/
 871         // call handler
 872         if (fDocumentHandler != null && !fScanningAttribute) {
 873             if (!name.equals("[xml]")) {
 874                 fDocumentHandler.endGeneralEntity(name, augs);
 875             }
 876         }
 877 
 878 
 879     } // endEntity(String)
 880 
 881     //
 882     // Protected methods
 883     //
 884 
 885     // Driver factory methods
 886 
 887     /** Creates a content Driver. */
 888     protected Driver createContentDriver() {
 889         return new FragmentContentDriver();
 890     } // createContentDriver():Driver
 891 
 892     // scanning methods
 893 
 894     /**