xmlschemavalidator.java

来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 1,551 行 · 第 1/5 页

JAVA
1,551
字号
                /**         * This method notifies the start of a general entity.         * <p>         * <strong>Note:</strong> This method is not called for entity references         * appearing as part of attribute values.         *         * @param name     The name of the general entity.         * @param identifier The resource identifier.         * @param encoding The auto-detected IANA encoding name of the entity         *                 stream. This value will be null in those situations         *                 where the entity encoding is not auto-detected (e.g.         *                 internal entities or a document entity that is         *                 parsed from a java.io.Reader).         * @param augs     Additional information that may include infoset augmentations         *         * @exception XNIException Thrown by handler to signal an error.         */        public void startGeneralEntity(        String name,        XMLResourceIdentifier identifier,        String encoding,        Augmentations augs)        throws XNIException {                        // REVISIT: what should happen if normalize_data_ is on??            fEntityRef = true;            // call handlers            if (fDocumentHandler != null) {                fDocumentHandler.startGeneralEntity(name, identifier, encoding, augs);            }                    } // startEntity(String,String,String,String,String)                /**         * Notifies of the presence of a TextDecl line in an entity. If present,         * this method will be called immediately following the startEntity call.         * <p>         * <strong>Note:</strong> This method will never be called for the         * document entity; it is only called for external general entities         * referenced in document content.         * <p>         * <strong>Note:</strong> This method is not called for entity references         * appearing as part of attribute values.         *         * @param version  The XML version, or null if not specified.         * @param encoding The IANA encoding name of the entity.         * @param augs     Additional information that may include infoset augmentations         *         * @throws XNIException Thrown by handler to signal an error.         */        public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {                        // call handlers            if (fDocumentHandler != null) {                fDocumentHandler.textDecl(version, encoding, augs);            }                    } // textDecl(String,String)                /**         * A comment.         *         * @param text The text in the comment.         * @param augs     Additional information that may include infoset augmentations         *         * @throws XNIException Thrown by application to signal an error.         */        public void comment(XMLString text, Augmentations augs) throws XNIException {                        // record the fact that there is a comment child.            fSawChildren = true;                        // call handlers            if (fDocumentHandler != null) {                fDocumentHandler.comment(text, augs);            }                    } // comment(XMLString)                /**         * A processing instruction. Processing instructions consist of a         * target name and, optionally, text data. The data is only meaningful         * to the application.         * <p>         * Typically, a processing instruction's data will contain a series         * of pseudo-attributes. These pseudo-attributes follow the form of         * element attributes but are <strong>not</strong> parsed or presented         * to the application as anything other than text. The application is         * responsible for parsing the data.         *         * @param target The target.         * @param data   The data or null if none specified.         * @param augs     Additional information that may include infoset augmentations         *         * @throws XNIException Thrown by handler to signal an error.         */        public void processingInstruction(String target, XMLString data, Augmentations augs)        throws XNIException {                        // record the fact that there is a PI child.            fSawChildren = true;                        // call handlers            if (fDocumentHandler != null) {                fDocumentHandler.processingInstruction(target, data, augs);            }                    } // processingInstruction(String,XMLString)                /**         * This method notifies the end of a general entity.         * <p>         * <strong>Note:</strong> This method is not called for entity references         * appearing as part of attribute values.         *         * @param name   The name of the entity.         * @param augs   Additional information that may include infoset augmentations         *         * @exception XNIException         *                   Thrown by handler to signal an error.         */        public void endGeneralEntity(String name, Augmentations augs) throws XNIException {                        // call handlers            fEntityRef = false;            if (fDocumentHandler != null) {                fDocumentHandler.endGeneralEntity(name, augs);            }                    } // endEntity(String)                // constants                static final int INITIAL_STACK_SIZE = 8;        static final int INC_STACK_SIZE     = 8;                //        // Data        //                // Schema Normalization                private static final boolean DEBUG_NORMALIZATION = false;        // temporary empty string buffer.        private final XMLString fEmptyXMLStr = new XMLString(null, 0, -1);        // temporary character buffer, and empty string buffer.        private static final int BUFFER_SIZE = 20;        private final XMLString fNormalizedStr = new XMLString();        private boolean fFirstChunk = true;        // got first chunk in characters() (SAX)        private boolean fTrailing = false;  // Previous chunk had a trailing space        private short fWhiteSpace = -1;  //whiteSpace: preserve/replace/collapse        private boolean fUnionType = false;                /** Schema grammar resolver. */        final XSGrammarBucket fGrammarBucket;        final SubstitutionGroupHandler fSubGroupHandler;                // Schema grammar loader        final XMLSchemaLoader fSchemaLoader;                /** the DV usd to convert xsi:type to a QName */        // REVISIT: in new simple type design, make things in DVs static,        //          so that we can QNameDV.getCompiledForm()        final XSSimpleType fQNameDV =        (XSSimpleType) SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_QNAME);                final CMNodeFactory nodeFactory = new CMNodeFactory();        /** used to build content models */        // REVISIT: create decl pool, and pass it to each traversers        final CMBuilder fCMBuilder = new CMBuilder(nodeFactory);                // state                /** String representation of the validation root. */        // REVISIT: what do we store here? QName, XPATH, some ID? use rawname now.        String fValidationRoot;                /** Skip validation: anything below this level should be skipped */        int fSkipValidationDepth;                /** anything above this level has validation_attempted != full */        int fNFullValidationDepth;                /** anything above this level has validation_attempted != none */        int fNNoneValidationDepth;                /** Element depth: -2: validator not in pipeline; >= -1 current depth. */        int fElementDepth;                /** Seen sub elements. */        boolean fSubElement;                /** Seen sub elements stack. */        boolean[] fSubElementStack = new boolean[INITIAL_STACK_SIZE];                /** Current element declaration. */        XSElementDecl fCurrentElemDecl;                /** Element decl stack. */        XSElementDecl[] fElemDeclStack = new XSElementDecl[INITIAL_STACK_SIZE];                /** nil value of the current element */        boolean fNil;                /** nil value stack */        boolean[] fNilStack = new boolean[INITIAL_STACK_SIZE];                /** notation value of the current element */        XSNotationDecl fNotation;                /** notation stack */        XSNotationDecl[] fNotationStack = new XSNotationDecl[INITIAL_STACK_SIZE];                /** Current type. */        XSTypeDefinition fCurrentType;                /** type stack. */        XSTypeDefinition[] fTypeStack = new XSTypeDefinition[INITIAL_STACK_SIZE];                /** Current content model. */        XSCMValidator fCurrentCM;                /** Content model stack. */        XSCMValidator[] fCMStack = new XSCMValidator[INITIAL_STACK_SIZE];                /** the current state of the current content model */        int[] fCurrCMState;                /** stack to hold content model states */        int[][] fCMStateStack = new int[INITIAL_STACK_SIZE][];                /** whether the curret element is strictly assessed */        boolean fStrictAssess = true;                /** strict assess stack */        boolean[] fStrictAssessStack = new boolean[INITIAL_STACK_SIZE];                /** Temporary string buffers. */        final StringBuffer fBuffer = new StringBuffer();                /** Whether need to append characters to fBuffer */        boolean fAppendBuffer = true;                /** Did we see any character data? */        boolean fSawText = false;                /** stack to record if we saw character data */        boolean[] fSawTextStack = new boolean[INITIAL_STACK_SIZE];                /** Did we see non-whitespace character data? */        boolean fSawCharacters = false;                /** Stack to record if we saw character data outside of element content*/        boolean[] fStringContent = new boolean[INITIAL_STACK_SIZE];                /** Did we see children that are neither characters nor elements? */        boolean fSawChildren = false;                /** Stack to record if we other children that character or elements */        boolean[] fSawChildrenStack = new boolean[INITIAL_STACK_SIZE];                /** temprory qname */        final QName fTempQName = new QName();                /** temprory validated info */        ValidatedInfo fValidatedInfo = new ValidatedInfo();                // used to validate default/fixed values against xsi:type        // only need to check facets, so we set extraChecking to false (in reset)        private ValidationState fState4XsiType = new ValidationState();                // used to apply default/fixed values        // only need to check id/idref/entity, so we set checkFacets to false        private ValidationState fState4ApplyDefault = new ValidationState();                // identity constraint information                /**         * Stack of active XPath matchers for identity constraints. All         * active XPath matchers are notified of startElement         * and endElement callbacks in order to perform their matches.         * <p>         * For each element with identity constraints, the selector of         * each identity constraint is activated. When the selector matches         * its XPath, then all the fields of the identity constraint are         * activated.         * <p>         * <strong>Note:</strong> Once the activation scope is left, the         * XPath matchers are automatically removed from the stack of         * active matchers and no longer receive callbacks.         */        protected XPathMatcherStack fMatcherStack = new XPathMatcherStack();                /** Cache of value stores for identity constraint fields. */        protected ValueStoreCache fValueStoreCache = new ValueStoreCache();                //        // Constructors        //                /** Default constructor. */        public XMLSchemaValidator() {            fGrammarBucket = new XSGrammarBucket();            fSubGroupHandler = new SubstitutionGroupHandler(fGrammarBucket);            // initialize the schema loader            fSchemaLoader =            new XMLSchemaLoader(            fXSIErrorReporter.fErrorReporter,            fGrammarBucket,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?