📄 xmldtdprocessor.java
字号:
} } else if (type == XMLSymbols.fENTITIESSymbol || type == XMLSymbols.fIDREFSSymbol) { if (!isValidName(nmtoken)) { ok = false; break; } } if (!tokenizer.hasMoreTokens()) { break; } } } } else { if (type == XMLSymbols.fENTITYSymbol || type == XMLSymbols.fIDSymbol || type == XMLSymbols.fIDREFSymbol || type == XMLSymbols.fNOTATIONSymbol) { if (!isValidName(value)) { ok = false; } } else if (type == XMLSymbols.fNMTOKENSymbol || type == XMLSymbols.fENUMERATIONSymbol) { if (!isValidNmtoken(value)) { ok = false; } } if (type == XMLSymbols.fNOTATIONSymbol || type == XMLSymbols.fENUMERATIONSymbol) { ok = false; for (int i=0; i<enumeration.length; i++) { if (defaultValue.equals(enumeration[i])) { ok = true; } } } } if (!ok) { fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_ATT_DEFAULT_INVALID", new Object[]{attributeName, value}, XMLErrorReporter.SEVERITY_ERROR); } } } // call handlers if(fDTDGrammar != null) fDTDGrammar.attributeDecl(elementName, attributeName, type, enumeration, defaultType, defaultValue, nonNormalizedDefaultValue, augs); if (fDTDHandler != null) { fDTDHandler.attributeDecl(elementName, attributeName, type, enumeration, defaultType, defaultValue, nonNormalizedDefaultValue, augs); } } // attributeDecl(String,String,String,String[],String,XMLString, XMLString, Augmentations) /** * The end of an attribute list. * * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void endAttlist(Augmentations augs) throws XNIException { // call handlers if(fDTDGrammar != null) fDTDGrammar.endAttlist(augs); if (fDTDHandler != null) { fDTDHandler.endAttlist(augs); } } // endAttlist() /** * An internal entity declaration. * * @param name The name of the entity. Parameter entity names start with * '%', whereas the name of a general entity is just the * entity name. * @param text The value of the entity. * @param nonNormalizedText The non-normalized value of the entity. This * value contains the same sequence of characters that was in * the internal entity declaration, without any entity * references expanded. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void internalEntityDecl(String name, XMLString text, XMLString nonNormalizedText, Augmentations augs) throws XNIException { DTDGrammar grammar = (fDTDGrammar != null? fDTDGrammar: fGrammarBucket.getActiveGrammar()); int index = grammar.getEntityDeclIndex(name) ; //If the same entity is declared more than once, the first declaration //encountered is binding, SAX requires only effective(first) declaration //to be reported to the application //REVISIT: Does it make sense to pass duplicate Entity information across //the pipeline -- nb? //its a new entity and hasn't been declared. if(index == -1){ //store internal entity declaration in grammar if(fDTDGrammar != null) fDTDGrammar.internalEntityDecl(name, text, nonNormalizedText, augs); // call handlers if (fDTDHandler != null) { fDTDHandler.internalEntityDecl(name, text, nonNormalizedText, augs); } } } // internalEntityDecl(String,XMLString,XMLString) /** * An external entity declaration. * * @param name The name of the entity. Parameter entity names start * with '%', whereas the name of a general entity is just * the entity name. * @param identifier An object containing all location information * pertinent to this external entity. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void externalEntityDecl(String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException { DTDGrammar grammar = (fDTDGrammar != null? fDTDGrammar: fGrammarBucket.getActiveGrammar()); int index = grammar.getEntityDeclIndex(name) ; //If the same entity is declared more than once, the first declaration //encountered is binding, SAX requires only effective(first) declaration //to be reported to the application //REVISIT: Does it make sense to pass duplicate entity information across //the pipeline -- nb? //its a new entity and hasn't been declared. if(index == -1){ //store external entity declaration in grammar if(fDTDGrammar != null) fDTDGrammar.externalEntityDecl(name, identifier, augs); // call handlers if (fDTDHandler != null) { fDTDHandler.externalEntityDecl(name, identifier, augs); } } } // externalEntityDecl(String,XMLResourceIdentifier, Augmentations) /** * An unparsed entity declaration. * * @param name The name of the entity. * @param identifier An object containing all location information * pertinent to this entity. * @param notation The name of the notation. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void unparsedEntityDecl(String name, XMLResourceIdentifier identifier, String notation, Augmentations augs) throws XNIException { // VC: Notation declared, in the production of NDataDecl if (fValidation) { fNDataDeclNotations.put(name, notation); } // call handlers if(fDTDGrammar != null) fDTDGrammar.unparsedEntityDecl(name, identifier, notation, augs); if (fDTDHandler != null) { fDTDHandler.unparsedEntityDecl(name, identifier, notation, augs); } } // unparsedEntityDecl(String,XMLResourceIdentifier,String,Augmentations) /** * A notation declaration * * @param name The name of the notation. * @param identifier An object containing all location information * pertinent to this notation. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void notationDecl(String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException { // VC: Unique Notation Name if (fValidation) { DTDGrammar grammar = (fDTDGrammar != null ? fDTDGrammar : fGrammarBucket.getActiveGrammar()); if (grammar.getNotationDeclIndex(name) != -1) { fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "UniqueNotationName", new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR); } } // call handlers if(fDTDGrammar != null) fDTDGrammar.notationDecl(name, identifier, augs); if (fDTDHandler != null) { fDTDHandler.notationDecl(name, identifier, augs); } } // notationDecl(String,XMLResourceIdentifier, Augmentations) /** * The start of a conditional section. * * @param type The type of the conditional section. This value will * either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. * * @see #CONDITIONAL_INCLUDE * @see #CONDITIONAL_IGNORE */ public void startConditional(short type, Augmentations augs) throws XNIException { // set state fInDTDIgnore = type == XMLDTDHandler.CONDITIONAL_IGNORE; // call handlers if(fDTDGrammar != null) fDTDGrammar.startConditional(type, augs); if (fDTDHandler != null) { fDTDHandler.startConditional(type, augs); } } // startConditional(short) /** * The end of a conditional section. * * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void endConditional(Augmentations augs) throws XNIException { // set state fInDTDIgnore = false; // call handlers if(fDTDGrammar != null) fDTDGrammar.endConditional(augs); if (fDTDHandler != null) { fDTDHandler.endConditional(augs); } } // endConditional() /** * The end of the DTD. * * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void endDTD(Augmentations augs) throws XNIException { // save grammar if(fDTDGrammar != null) { fDTDGrammar.endDTD(augs); if(fGrammarPool != null) fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_DTD, new Grammar[] {fDTDGrammar}); } // check VC: Notation declared, in the production of NDataDecl if (fValidation) { DTDGrammar grammar = (fDTDGrammar != null? fDTDGrammar: fGrammarBucket.getActiveGrammar()); // VC : Notation Declared. for external entity declaration [Production 76]. Enumeration entities = fNDataDeclNotations.keys(); while (entities.hasMoreElements()) { String entity = (String) entities.nextElement(); String notation = (String) fNDataDeclNotations.get(entity); if (grammar.getNotationDeclIndex(notation) == -1) { fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_NOTATION_NOT_DECLARED_FOR_UNPARSED_ENTITYDECL", new Object[]{entity, notation}, XMLErrorReporter.SEVERITY_ERROR); } } // VC: Notation Attributes: // all notation names in the (attribute) declaration must be declared. Enumeration notationVals = fNotationEnumVals.keys(); while (notationVals.hasMoreElements()) { String notation = (String) notationVals.nextElement(); String attributeName = (String) fNotationEnumVals.get(notation); if (grammar.getNotationDeclIndex(notation) == -1) { fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_NOTATION_NOT_DECLARED_FOR_NOTATIONTYPE_ATTRIBUTE", new Object[]{attributeName, notation}, XMLErrorReporter.SEVERITY_ERROR); } } // VC: No Notation on Empty Element // An attribute of type NOTATION must not be declared on an element declared EMPTY. Enumeration elementsWithNotations = fTableOfNOTATIONAttributeNames.keys(); while (elementsWithNotations.hasMoreElements()) { String elementName = (String) elementsWithNotations.nextElement(); int elementIndex = grammar.getElementDeclIndex(elementName); if (grammar.getContentSpecType(elementIndex) == XMLElementDecl.TYPE_EMPTY) { String attributeName = (String) fTableOfNOTATIONAttributeNames.get(elementName); fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -