schemadomparser.java
来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 414 行 · 第 1/2 页
JAVA
414 行
// report an error fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN, "s4s-elt-character", new Object[]{txt}, XMLErrorReporter.SEVERITY_ERROR); break; } } // don't call super.characters() when it's not within one of the 2 // annotation elements: the traversers ignore them anyway. We can // save time/memory creating the text nodes. } // when it's within either of the 2 elements, characters are allowed // and we need to store them. else { schemaDOM.characters(text); } } /** * The start of an element. * * @param element The name of the element. * @param attributes The element attributes. * @param augs Additional information that may include infoset augmentations * * @exception XNIException * Thrown by handler to signal an error. */ public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException { fDepth++; // while it is true that non-whitespace character data // may only occur in appInfo or documentation // elements, it's certainly legal for comments and PI's to // occur as children of annotation; we need // to account for these here. if (fAnnotationDepth == -1) { if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart == SchemaSymbols.ELT_ANNOTATION) { fAnnotationDepth = fDepth; schemaDOM.startAnnotation(element, attributes, fNamespaceContext); } } else if(fDepth == fAnnotationDepth+1) { fInnerAnnotationDepth = fDepth; schemaDOM.startAnnotationElement(element, attributes); } else { schemaDOM.startAnnotationElement(element, attributes); // avoid falling through; don't call startElement in this case return; } schemaDOM.startElement(element, attributes, fLocator.getLineNumber(), fLocator.getColumnNumber()); } /** * An empty element. * * @param element The name of the element. * @param attributes The element attributes. * @param augs Additional information that may include infoset augmentations * * @exception XNIException * Thrown by handler to signal an error. */ public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException { // the order of events that occurs here is: // schemaDOM.startAnnotation/startAnnotationElement (if applicable) // schemaDOM.emptyElement (basically the same as startElement then endElement) // schemaDOM.endAnnotationElement (if applicable) // the order of events that would occur if this was <element></element>: // schemaDOM.startAnnotation/startAnnotationElement (if applicable) // schemaDOM.startElement // schemaDOM.endAnnotationElement (if applicable) // schemaDOM.endElementElement // Thus, we can see that the order of events isn't the same. However, it doesn't // seem to matter. -- PJM if (fAnnotationDepth == -1) { // this is messed up, but a case to consider: if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart == SchemaSymbols.ELT_ANNOTATION) { schemaDOM.startAnnotation(element, attributes, fNamespaceContext); } } else { schemaDOM.startAnnotationElement(element, attributes); } schemaDOM.emptyElement(element, attributes, fLocator.getLineNumber(), fLocator.getColumnNumber()); if (fAnnotationDepth == -1) { // this is messed up, but a case to consider: if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart == SchemaSymbols.ELT_ANNOTATION) { schemaDOM.endAnnotationElement(element, true); } } else { schemaDOM.endAnnotationElement(element, false); } } /** * The end of an element. * * @param element The name of the element. * @param augs Additional information that may include infoset augmentations * * @exception XNIException * Thrown by handler to signal an error. */ public void endElement(QName element, Augmentations augs) throws XNIException { // when we reach the endElement of xs:appinfo or xs:documentation, // change fInnerAnnotationDepth to -1 if(fAnnotationDepth > -1) { if (fInnerAnnotationDepth == fDepth) { fInnerAnnotationDepth = -1; schemaDOM.endAnnotationElement(element, false); schemaDOM.endElement(); } else if (fAnnotationDepth == fDepth) { fAnnotationDepth = -1; schemaDOM.endAnnotationElement(element, true); schemaDOM.endElement(); } else { // inside a child of annotation schemaDOM.endAnnotationElement(element, false); } } else { // not in an annotation at all schemaDOM.endElement(); } fDepth--; } /** * Ignorable whitespace. For this method to be called, the document * source must have some way of determining that the text containing * only whitespace characters should be considered ignorable. For * example, the validator can determine if a length of whitespace * characters in the document are ignorable based on the element * content model. * * @param text The ignorable whitespace. * @param augs Additional information that may include infoset augmentations * * @exception XNIException * Thrown by handler to signal an error. */ public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException { // unlikely to be called, but you never know... if (fAnnotationDepth != -1 ) { schemaDOM.characters(text); } } /** * The start of a CDATA section. * * @param augs Additional information that may include infoset augmentations * * @exception XNIException * Thrown by handler to signal an error. */ public void startCDATA(Augmentations augs) throws XNIException { // only deal with CDATA boundaries within an annotation. if (fAnnotationDepth != -1) { schemaDOM.startAnnotationCDATA(); } } /** * The end of a CDATA section. * * @param augs Additional information that may include infoset augmentations * * @exception XNIException * Thrown by handler to signal an error. */ public void endCDATA(Augmentations augs) throws XNIException { // only deal with CDATA boundaries within an annotation. if (fAnnotationDepth != -1) { schemaDOM.endAnnotationCDATA(); } } // // other methods // /** * Returns the DOM document object. */ public Document getDocument() { return schemaDOM; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?