XMLDTDProcessorpublic class XMLDTDProcessor extends Object implements org.apache.xerces.xni.parser.XMLDTDContentModelFilter, org.apache.xerces.xni.parser.XMLDTDFilter, org.apache.xerces.xni.parser.XMLComponentThe DTD processor. The processor implements a DTD
filter: receiving DTD events from the DTD scanner; validating
the content and structure; building a grammar, if applicable;
and notifying the DTDHandler of the information resulting from the
process.
This component requires the following features and properties from the
component manager that uses it:
- http://xml.org/sax/features/namespaces
- http://apache.org/xml/properties/internal/symbol-table
- http://apache.org/xml/properties/internal/error-reporter
- http://apache.org/xml/properties/internal/grammar-pool
- http://apache.org/xml/properties/internal/datatype-validator-factory
|
Fields Summary |
---|
private static final int | TOP_LEVEL_SCOPETop level scope (-1). | protected static final String | VALIDATIONFeature identifier: validation. | protected static final String | NOTIFY_CHAR_REFSFeature identifier: notify character references. | protected static final String | WARN_ON_DUPLICATE_ATTDEFFeature identifier: warn on duplicate attdef | protected static final String | WARN_ON_UNDECLARED_ELEMDEFFeature identifier: warn on undeclared element referenced in content model. | protected static final String | PARSER_SETTINGS | protected static final String | SYMBOL_TABLEProperty identifier: symbol table. | protected static final String | ERROR_REPORTERProperty identifier: error reporter. | protected static final String | GRAMMAR_POOLProperty identifier: grammar pool. | protected static final String | DTD_VALIDATORProperty identifier: validator . | private static final String[] | RECOGNIZED_FEATURESRecognized features. | private static final Boolean[] | FEATURE_DEFAULTSFeature defaults. | private static final String[] | RECOGNIZED_PROPERTIESRecognized properties. | private static final Object[] | PROPERTY_DEFAULTSProperty defaults. | protected boolean | fValidationValidation. | protected boolean | fDTDValidationValidation against only DTD | protected boolean | fWarnDuplicateAttdefwarn on duplicate attribute definition, this feature works only when validation is true | protected boolean | fWarnOnUndeclaredElemdefwarn on undeclared element referenced in content model, this feature only works when valiation is true | protected org.apache.xerces.util.SymbolTable | fSymbolTableSymbol table. | protected org.apache.xerces.impl.XMLErrorReporter | fErrorReporterError reporter. | protected DTDGrammarBucket | fGrammarBucketGrammar bucket. | protected XMLDTDValidator | fValidator | protected org.apache.xerces.xni.grammars.XMLGrammarPool | fGrammarPool | protected Locale | fLocale | protected org.apache.xerces.xni.XMLDTDHandler | fDTDHandlerDTD handler. | protected org.apache.xerces.xni.parser.XMLDTDSource | fDTDSourceDTD source. | protected org.apache.xerces.xni.XMLDTDContentModelHandler | fDTDContentModelHandlerDTD content model handler. | protected org.apache.xerces.xni.parser.XMLDTDContentModelSource | fDTDContentModelSourceDTD content model source. | protected DTDGrammar | fDTDGrammarDTD Grammar. | private boolean | fPerformValidationPerform validation. | protected boolean | fInDTDIgnoreTrue if in an ignore conditional section of the DTD. | private boolean | fMixedMixed. | private final XMLEntityDecl | fEntityDeclTemporary entity declaration. | private final Hashtable | fNDataDeclNotationsNotation declaration hash. | private String | fDTDElementDeclNameDTD element declaration name. | private final Vector | fMixedElementTypesMixed element type "hash". | private final Vector | fDTDElementDeclsElement declarations in DTD. | private Hashtable | fTableOfIDAttributeNamesID attribute names. | private Hashtable | fTableOfNOTATIONAttributeNamesNOTATION attribute names. | private Hashtable | fNotationEnumValsNOTATION enumeration values. |
Constructors Summary |
---|
public XMLDTDProcessor()Default constructor.
//
// Constructors
//
// initialize data
|
Methods Summary |
---|
public void | any(org.apache.xerces.xni.Augmentations augs)A content model of ANY.
if(fDTDGrammar != null)
fDTDGrammar.any(augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.any(augs);
}
| public void | attributeDecl(java.lang.String elementName, java.lang.String attributeName, java.lang.String type, java.lang.String[] enumeration, java.lang.String defaultType, org.apache.xerces.xni.XMLString defaultValue, org.apache.xerces.xni.XMLString nonNormalizedDefaultValue, org.apache.xerces.xni.Augmentations augs)An attribute declaration.
if (type != XMLSymbols.fCDATASymbol && defaultValue != null) {
normalizeDefaultAttrValue(defaultValue);
}
if (fValidation) {
boolean duplicateAttributeDef = false ;
//Get Grammar index to grammar array
DTDGrammar grammar = (fDTDGrammar != null? fDTDGrammar:fGrammarBucket.getActiveGrammar());
int elementIndex = grammar.getElementDeclIndex( elementName);
if (grammar.getAttributeDeclIndex(elementIndex, attributeName) != -1) {
//more than one attribute definition is provided for the same attribute of a given element type.
duplicateAttributeDef = true ;
//this feature works only when validation is true.
if(fWarnDuplicateAttdef){
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"MSG_DUPLICATE_ATTRIBUTE_DEFINITION",
new Object[]{ elementName, attributeName },
XMLErrorReporter.SEVERITY_WARNING );
}
}
//
// a) VC: One ID per Element Type, If duplicate ID attribute
// b) VC: ID attribute Default. if there is a declareared attribute
// default for ID it should be of type #IMPLIED or #REQUIRED
if (type == XMLSymbols.fIDSymbol) {
if (defaultValue != null && defaultValue.length != 0) {
if (defaultType == null ||
!(defaultType == XMLSymbols.fIMPLIEDSymbol ||
defaultType == XMLSymbols.fREQUIREDSymbol)) {
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"IDDefaultTypeInvalid",
new Object[]{ attributeName},
XMLErrorReporter.SEVERITY_ERROR);
}
}
if (!fTableOfIDAttributeNames.containsKey(elementName)) {
fTableOfIDAttributeNames.put(elementName, attributeName);
}
else {
//we should not report an error, when there is duplicate attribute definition for given element type
//according to XML 1.0 spec, When more than one definition is provided for the same attribute of a given
//element type, the first declaration is binding and later declaration are *ignored*. So processor should
//ignore the second declarations, however an application would be warned of the duplicate attribute defintion
// if http://apache.org/xml/features/validation/warn-on-duplicate-attdef feature is set to true,
// one typical case where this could be a problem, when any XML file
// provide the ID type information through internal subset so that it is available to the parser which read
//only internal subset. Now that attribute declaration(ID Type) can again be part of external parsed entity
//referenced. At that time if parser doesn't make this distinction it will throw an error for VC One ID per
//Element Type, which (second defintion) actually should be ignored. Application behavior may differ on the
//basis of error or warning thrown. - nb.
if(!duplicateAttributeDef){
String previousIDAttributeName = (String)fTableOfIDAttributeNames.get( elementName );//rule a)
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"MSG_MORE_THAN_ONE_ID_ATTRIBUTE",
new Object[]{ elementName, previousIDAttributeName, attributeName},
XMLErrorReporter.SEVERITY_ERROR);
}
}
}
//
// VC: One Notation Per Element Type, should check if there is a
// duplicate NOTATION attribute
if (type == XMLSymbols.fNOTATIONSymbol) {
// VC: Notation Attributes: all notation names in the
// (attribute) declaration must be declared.
for (int i=0; i<enumeration.length; i++) {
fNotationEnumVals.put(enumeration[i], attributeName);
}
if (fTableOfNOTATIONAttributeNames.containsKey( elementName ) == false) {
fTableOfNOTATIONAttributeNames.put( elementName, attributeName);
}
else {
//we should not report an error, when there is duplicate attribute definition for given element type
//according to XML 1.0 spec, When more than one definition is provided for the same attribute of a given
//element type, the first declaration is binding and later declaration are *ignored*. So processor should
//ignore the second declarations, however an application would be warned of the duplicate attribute defintion
// if http://apache.org/xml/features/validation/warn-on-duplicate-attdef feature is set to true, Application behavior may differ on the basis of error or
//warning thrown. - nb.
if(!duplicateAttributeDef){
String previousNOTATIONAttributeName = (String) fTableOfNOTATIONAttributeNames.get( elementName );
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"MSG_MORE_THAN_ONE_NOTATION_ATTRIBUTE",
new Object[]{ elementName, previousNOTATIONAttributeName, attributeName},
XMLErrorReporter.SEVERITY_ERROR);
}
}
}
// VC: No Duplicate Tokens
// XML 1.0 SE Errata - E2
if (type == XMLSymbols.fENUMERATIONSymbol || type == XMLSymbols.fNOTATIONSymbol) {
outer:
for (int i = 0; i < enumeration.length; ++i) {
for (int j = i + 1; j < enumeration.length; ++j) {
if (enumeration[i].equals(enumeration[j])) {
// Only report the first uniqueness violation. There could be others,
// but additional overhead would be incurred tracking unique tokens
// that have already been encountered. -- mrglavas
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
type == XMLSymbols.fENUMERATIONSymbol
? "MSG_DISTINCT_TOKENS_IN_ENUMERATION"
: "MSG_DISTINCT_NOTATION_IN_ENUMERATION",
new Object[]{ elementName, enumeration[i], attributeName },
XMLErrorReporter.SEVERITY_ERROR);
break outer;
}
}
}
}
// VC: Attribute Default Legal
boolean ok = true;
if (defaultValue != null &&
(defaultType == null ||
(defaultType != null && defaultType == XMLSymbols.fFIXEDSymbol))) {
String value = defaultValue.toString();
if (type == XMLSymbols.fNMTOKENSSymbol ||
type == XMLSymbols.fENTITIESSymbol ||
type == XMLSymbols.fIDREFSSymbol) {
StringTokenizer tokenizer = new StringTokenizer(value," ");
if (tokenizer.hasMoreTokens()) {
while (true) {
String nmtoken = tokenizer.nextToken();
if (type == XMLSymbols.fNMTOKENSSymbol) {
if (!isValidNmtoken(nmtoken)) {
ok = false;
break;
}
}
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);
}
| private void | checkDeclaredElements(DTDGrammar grammar)Checks that all elements referenced in content models have
been declared. This method calls out to the error handler
to indicate warnings.
int elementIndex = grammar.getFirstElementDeclIndex();
XMLContentSpec contentSpec = new XMLContentSpec();
while (elementIndex >= 0) {
int type = grammar.getContentSpecType(elementIndex);
if (type == XMLElementDecl.TYPE_CHILDREN || type == XMLElementDecl.TYPE_MIXED) {
checkDeclaredElements(grammar,
elementIndex,
grammar.getContentSpecIndex(elementIndex),
contentSpec);
}
elementIndex = grammar.getNextElementDeclIndex(elementIndex);
}
| private void | checkDeclaredElements(DTDGrammar grammar, int elementIndex, int contentSpecIndex, XMLContentSpec contentSpec)Does a recursive (if necessary) check on the specified element's
content spec to make sure that all children refer to declared
elements.
grammar.getContentSpec(contentSpecIndex, contentSpec);
if (contentSpec.type == XMLContentSpec.CONTENTSPECNODE_LEAF) {
String value = (String) contentSpec.value;
if (value != null && grammar.getElementDeclIndex(value) == -1) {
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"UndeclaredElementInContentSpec",
new Object[]{grammar.getElementDeclName(elementIndex).rawname, value},
XMLErrorReporter.SEVERITY_WARNING);
}
}
// It's not a leaf, so we have to recurse its left and maybe right
// nodes. Save both values before we recurse and trash the node.
else if ((contentSpec.type == XMLContentSpec.CONTENTSPECNODE_CHOICE)
|| (contentSpec.type == XMLContentSpec.CONTENTSPECNODE_SEQ)) {
final int leftNode = ((int[])contentSpec.value)[0];
final int rightNode = ((int[])contentSpec.otherValue)[0];
// Recurse on both children.
checkDeclaredElements(grammar, elementIndex, leftNode, contentSpec);
checkDeclaredElements(grammar, elementIndex, rightNode, contentSpec);
}
else if (contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE
|| contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE
|| contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE) {
final int leftNode = ((int[])contentSpec.value)[0];
checkDeclaredElements(grammar, elementIndex, leftNode, contentSpec);
}
| protected static void | checkStandaloneEntityRef(java.lang.String name, DTDGrammar grammar, XMLEntityDecl tempEntityDecl, org.apache.xerces.impl.XMLErrorReporter errorReporter)Check standalone entity reference.
Made static to make common between the validator and loader.
// check VC: Standalone Document Declartion, entities references appear in the document.
int entIndex = grammar.getEntityDeclIndex(name);
if (entIndex > -1) {
grammar.getEntityDecl(entIndex, tempEntityDecl);
if (tempEntityDecl.inExternal) {
errorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,
"MSG_REFERENCE_TO_EXTERNALLY_DECLARED_ENTITY_WHEN_STANDALONE",
new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR);
}
}
| public void | comment(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)A comment.
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.comment(text, augs);
if (fDTDHandler != null) {
fDTDHandler.comment(text, augs);
}
| public void | element(java.lang.String elementName, org.apache.xerces.xni.Augmentations augs)A referenced element in a mixed or children content model.
// check VC: No duplicate Types, in a single mixed-content declaration
if (fMixed && fValidation) {
if (fMixedElementTypes.contains(elementName)) {
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"DuplicateTypeInMixedContent",
new Object[]{fDTDElementDeclName, elementName},
XMLErrorReporter.SEVERITY_ERROR);
}
else {
fMixedElementTypes.addElement(elementName);
}
}
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.element(elementName, augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.element(elementName, augs);
}
| public void | elementDecl(java.lang.String name, java.lang.String contentModel, org.apache.xerces.xni.Augmentations augs)An element declaration.
//check VC: Unique Element Declaration
if (fValidation) {
if (fDTDElementDecls.contains(name)) {
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"MSG_ELEMENT_ALREADY_DECLARED",
new Object[]{ name},
XMLErrorReporter.SEVERITY_ERROR);
}
else {
fDTDElementDecls.addElement(name);
}
}
// call handlers
if(fDTDGrammar != null )
fDTDGrammar.elementDecl(name, contentModel, augs);
if (fDTDHandler != null) {
fDTDHandler.elementDecl(name, contentModel, augs);
}
| public void | empty(org.apache.xerces.xni.Augmentations augs)A content model of EMPTY.
if(fDTDGrammar != null)
fDTDGrammar.empty(augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.empty(augs);
}
| public void | endAttlist(org.apache.xerces.xni.Augmentations augs)The end of an attribute list.
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.endAttlist(augs);
if (fDTDHandler != null) {
fDTDHandler.endAttlist(augs);
}
| public void | endConditional(org.apache.xerces.xni.Augmentations augs)The end of a conditional section.
// set state
fInDTDIgnore = false;
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.endConditional(augs);
if (fDTDHandler != null) {
fDTDHandler.endConditional(augs);
}
| public void | endContentModel(org.apache.xerces.xni.Augmentations augs)The end of a content model.
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.endContentModel(augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.endContentModel(augs);
}
| public void | endDTD(org.apache.xerces.xni.Augmentations augs)The end of the DTD.
// save grammar
if(fDTDGrammar != null) {
fDTDGrammar.endDTD(augs);
if(fGrammarPool != null)
fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_DTD, new Grammar[] {fDTDGrammar});
}
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,
"NoNotationOnEmptyElement",
new Object[]{elementName, attributeName},
XMLErrorReporter.SEVERITY_ERROR);
}
}
// should be safe to release these references
fTableOfIDAttributeNames = null;
fTableOfNOTATIONAttributeNames = null;
// check whether each element referenced in a content model is declared
if (fWarnOnUndeclaredElemdef) {
checkDeclaredElements(grammar);
}
}
// call handlers
if (fDTDHandler != null) {
fDTDHandler.endDTD(augs);
}
| public void | endExternalSubset(org.apache.xerces.xni.Augmentations augs)The end of the DTD external subset.
if(fDTDGrammar != null)
fDTDGrammar.endExternalSubset(augs);
if(fDTDHandler != null){
fDTDHandler.endExternalSubset(augs);
}
| public void | endGroup(org.apache.xerces.xni.Augmentations augs)The end of a group for mixed or children content models.
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.endGroup(augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.endGroup(augs);
}
| public void | endParameterEntity(java.lang.String name, org.apache.xerces.xni.Augmentations augs)This method notifies the end of a parameter entity. Parameter entity
names begin with a '%' character.
// call handlers
if(fDTDGrammar != null )
fDTDGrammar.endParameterEntity(name, augs);
if (fDTDHandler != null) {
fDTDHandler.endParameterEntity(name, augs);
}
| public void | externalEntityDecl(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, org.apache.xerces.xni.Augmentations augs)An external entity declaration.
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);
}
}
| public org.apache.xerces.xni.XMLDTDContentModelHandler | getDTDContentModelHandler()Gets the DTD content model handler.
return fDTDContentModelHandler;
| public org.apache.xerces.xni.parser.XMLDTDContentModelSource | getDTDContentModelSource()
return fDTDContentModelSource;
| public org.apache.xerces.xni.XMLDTDHandler | getDTDHandler()Returns the DTD handler.
return fDTDHandler;
| public org.apache.xerces.xni.parser.XMLDTDSource | getDTDSource()
return fDTDSource;
| public java.lang.Boolean | getFeatureDefault(java.lang.String featureId)Returns the default state for a feature, or null if this
component does not want to report a default value for this
feature.
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId)) {
return FEATURE_DEFAULTS[i];
}
}
return null;
| public java.lang.Object | getPropertyDefault(java.lang.String propertyId)Returns the default state for a property, or null if this
component does not want to report a default value for this
property.
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
return PROPERTY_DEFAULTS[i];
}
}
return null;
| public java.lang.String[] | getRecognizedFeatures()Returns a list of feature identifiers that are recognized by
this component. This method may return null if no features
are recognized by this component.
return (String[])(RECOGNIZED_FEATURES.clone());
| public java.lang.String[] | getRecognizedProperties()Returns a list of property identifiers that are recognized by
this component. This method may return null if no properties
are recognized by this component.
return (String[])(RECOGNIZED_PROPERTIES.clone());
| public void | ignoredCharacters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)Characters within an IGNORE conditional section.
// ignored characters in DTD
if(fDTDGrammar != null )
fDTDGrammar.ignoredCharacters(text, augs);
if (fDTDHandler != null) {
fDTDHandler.ignoredCharacters(text, augs);
}
| public void | internalEntityDecl(java.lang.String name, org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.XMLString nonNormalizedText, org.apache.xerces.xni.Augmentations augs)An internal entity declaration.
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);
}
}
| protected boolean | isValidName(java.lang.String name)
return XMLChar.isValidName(name);
| protected boolean | isValidNmtoken(java.lang.String nmtoken)
return XMLChar.isValidNmtoken(nmtoken);
| private boolean | normalizeDefaultAttrValue(org.apache.xerces.xni.XMLString value)Normalize the attribute value of a non CDATA default attribute
collapsing sequences of space characters (x20)
boolean skipSpace = true; // skip leading spaces
int current = value.offset;
int end = value.offset + value.length;
for (int i = value.offset; i < end; i++) {
if (value.ch[i] == ' ") {
if (!skipSpace) {
// take the first whitespace as a space and skip the others
value.ch[current++] = ' ";
skipSpace = true;
}
else {
// just skip it.
}
}
else {
// simply shift non space chars if needed
if (current != i) {
value.ch[current] = value.ch[i];
}
current++;
skipSpace = false;
}
}
if (current != end) {
if (skipSpace) {
// if we finished on a space trim it
current--;
}
// set the new value length
value.length = current - value.offset;
return true;
}
return false;
| public void | notationDecl(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, org.apache.xerces.xni.Augmentations augs)A notation declaration
// 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);
}
| public void | occurrence(short occurrence, org.apache.xerces.xni.Augmentations augs)The occurrence count for a child in a children content model or
for the mixed content model group.
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.occurrence(occurrence, augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.occurrence(occurrence, augs);
}
| public void | pcdata(org.apache.xerces.xni.Augmentations augs)The appearance of "#PCDATA" within a group signifying a
mixed content model. This method will be the first called
following the content model's startGroup() .
fMixed = true;
if(fDTDGrammar != null)
fDTDGrammar.pcdata(augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.pcdata(augs);
}
| public void | processingInstruction(java.lang.String target, org.apache.xerces.xni.XMLString data, org.apache.xerces.xni.Augmentations augs)A processing instruction. Processing instructions consist of a
target name and, optionally, text data. The data is only meaningful
to the application.
Typically, a processing instruction's data will contain a series
of pseudo-attributes. These pseudo-attributes follow the form of
element attributes but are not parsed or presented
to the application as anything other than text. The application is
responsible for parsing the data.
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.processingInstruction(target, data, augs);
if (fDTDHandler != null) {
fDTDHandler.processingInstruction(target, data, augs);
}
| public void | reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
boolean parser_settings;
try {
parser_settings = componentManager.getFeature(PARSER_SETTINGS);
} catch (XMLConfigurationException e) {
parser_settings = true;
}
if (!parser_settings) {
// parser settings have not been changed
reset();
return;
}
// sax features
try {
fValidation = componentManager.getFeature(VALIDATION);
} catch (XMLConfigurationException e) {
fValidation = false;
}
try {
fDTDValidation =
!(componentManager
.getFeature(
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE));
} catch (XMLConfigurationException e) {
// must be in a schema-less configuration!
fDTDValidation = true;
}
// Xerces features
try {
fWarnDuplicateAttdef = componentManager.getFeature(WARN_ON_DUPLICATE_ATTDEF);
}
catch (XMLConfigurationException e) {
fWarnDuplicateAttdef = false;
}
try {
fWarnOnUndeclaredElemdef = componentManager.getFeature(WARN_ON_UNDECLARED_ELEMDEF);
}
catch (XMLConfigurationException e) {
fWarnOnUndeclaredElemdef = false;
}
// get needed components
fErrorReporter =
(XMLErrorReporter) componentManager.getProperty(
Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY);
fSymbolTable =
(SymbolTable) componentManager.getProperty(
Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
try {
fGrammarPool = (XMLGrammarPool) componentManager.getProperty(GRAMMAR_POOL);
} catch (XMLConfigurationException e) {
fGrammarPool = null;
}
try {
fValidator = (XMLDTDValidator) componentManager.getProperty(DTD_VALIDATOR);
} catch (XMLConfigurationException e) {
fValidator = null;
} catch (ClassCastException e) {
fValidator = null;
}
// we get our grammarBucket from the validator...
if (fValidator != null) {
fGrammarBucket = fValidator.getGrammarBucket();
} else {
fGrammarBucket = null;
}
reset();
| protected void | reset()
// clear grammars
fDTDGrammar = null;
// initialize state
fInDTDIgnore = false;
fNDataDeclNotations.clear();
// datatype validators
if (fValidation) {
if (fNotationEnumVals == null) {
fNotationEnumVals = new Hashtable();
}
fNotationEnumVals.clear();
fTableOfIDAttributeNames = new Hashtable();
fTableOfNOTATIONAttributeNames = new Hashtable();
}
| public void | separator(short separator, org.apache.xerces.xni.Augmentations augs)The separator between choices or sequences of a mixed or children
content model.
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.separator(separator, augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.separator(separator, augs);
}
| public void | setDTDContentModelHandler(org.apache.xerces.xni.XMLDTDContentModelHandler dtdContentModelHandler)Sets the DTD content model handler.
fDTDContentModelHandler = dtdContentModelHandler;
| public void | setDTDContentModelSource(org.apache.xerces.xni.parser.XMLDTDContentModelSource source)
fDTDContentModelSource = source;
| public void | setDTDHandler(org.apache.xerces.xni.XMLDTDHandler dtdHandler)Sets the DTD handler.
fDTDHandler = dtdHandler;
| public void | setDTDSource(org.apache.xerces.xni.parser.XMLDTDSource source)
fDTDSource = source;
| public void | setFeature(java.lang.String featureId, boolean state)Sets the state of a feature. This method is called by the component
manager any time after reset when a feature changes state.
Note: Components should silently ignore features
that do not affect the operation of the component.
| public void | setProperty(java.lang.String propertyId, java.lang.Object value)Sets the value of a property. This method is called by the component
manager any time after reset when a property changes value.
Note: Components should silently ignore properties
that do not affect the operation of the component.
| public void | startAttlist(java.lang.String elementName, org.apache.xerces.xni.Augmentations augs)The start of an attribute list.
// call handlers
if(fDTDGrammar != null )
fDTDGrammar.startAttlist(elementName, augs);
if (fDTDHandler != null) {
fDTDHandler.startAttlist(elementName, augs);
}
| public void | startConditional(short type, org.apache.xerces.xni.Augmentations augs)The start of a conditional section.
// set state
fInDTDIgnore = type == XMLDTDHandler.CONDITIONAL_IGNORE;
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.startConditional(type, augs);
if (fDTDHandler != null) {
fDTDHandler.startConditional(type, augs);
}
| public void | startContentModel(java.lang.String elementName, org.apache.xerces.xni.Augmentations augs)The start of a content model. Depending on the type of the content
model, specific methods may be called between the call to the
startContentModel method and the call to the endContentModel method.
if (fValidation) {
fDTDElementDeclName = elementName;
fMixedElementTypes.removeAllElements();
}
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.startContentModel(elementName, augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.startContentModel(elementName, augs);
}
| public void | startDTD(org.apache.xerces.xni.XMLLocator locator, org.apache.xerces.xni.Augmentations augs)The start of the DTD.
// initialize state
fNDataDeclNotations.clear();
fDTDElementDecls.removeAllElements();
// the grammar bucket's DTDGrammar will now be the
// one we want, whether we're constructing it or not.
// if we're not constructing it, then we should not have a reference
// to it!
if( !fGrammarBucket.getActiveGrammar().isImmutable()) {
fDTDGrammar = fGrammarBucket.getActiveGrammar();
}
// call handlers
if(fDTDGrammar != null )
fDTDGrammar.startDTD(locator, augs);
if (fDTDHandler != null) {
fDTDHandler.startDTD(locator, augs);
}
| public void | startExternalSubset(org.apache.xerces.xni.XMLResourceIdentifier identifier, org.apache.xerces.xni.Augmentations augs)The start of the DTD external subset.
if(fDTDGrammar != null)
fDTDGrammar.startExternalSubset(identifier, augs);
if(fDTDHandler != null){
fDTDHandler.startExternalSubset(identifier, augs);
}
| public void | startGroup(org.apache.xerces.xni.Augmentations augs)A start of either a mixed or children content model. A mixed
content model will immediately be followed by a call to the
pcdata() method. A children content model will
contain additional groups and/or elements.
fMixed = false;
// call handlers
if(fDTDGrammar != null)
fDTDGrammar.startGroup(augs);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.startGroup(augs);
}
| public void | startParameterEntity(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)This method notifies of the start of a parameter entity. The parameter
entity name start with a '%' character.
if (fPerformValidation && fDTDGrammar != null &&
fGrammarBucket.getStandalone()) {
checkStandaloneEntityRef(name, fDTDGrammar, fEntityDecl, fErrorReporter);
}
// call handlers
if(fDTDGrammar != null )
fDTDGrammar.startParameterEntity(name, identifier, encoding, augs);
if (fDTDHandler != null) {
fDTDHandler.startParameterEntity(name, identifier, encoding, augs);
}
| public void | textDecl(java.lang.String version, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)Notifies of the presence of a TextDecl line in an entity. If present,
this method will be called immediately following the startParameterEntity call.
Note: This method is only called for external
parameter entities referenced in the DTD.
// call handlers
if(fDTDGrammar != null )
fDTDGrammar.textDecl(version, encoding, augs);
if (fDTDHandler != null) {
fDTDHandler.textDecl(version, encoding, augs);
}
| public void | unparsedEntityDecl(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, java.lang.String notation, org.apache.xerces.xni.Augmentations augs)An unparsed entity declaration.
// 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);
}
|
|