/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
*/
/**
* A DTD grammar. This class implements the XNI handler interfaces
* for DTD information so that it can build the approprate validation
* structures automatically from the callbacks.
*
* @xerces.internal
*
* @author Eric Ye, IBM
* @author Jeffrey Rodriguez, IBM
* @author Andy Clark, IBM
* @author Neil Graham, IBM
*
* @version $Id: DTDGrammar.java,v 1.4 2010/08/11 07:18:37 joehw Exp $
*/
public class DTDGrammar
//
// Constants
//
/** Top level scope (-1). */
// private
/** Chunk shift (8). */
/** Chunk size (1 << CHUNK_SHIFT). */
/** Chunk mask (CHUNK_SIZE - 1). */
/** Initial chunk count (1 << (10 - CHUNK_SHIFT)). */
/** List flag (0x80). */
/** List mask (~LIST_FLAG). */
// debugging
/** Debug DTDGrammar. */
private static final boolean DEBUG = false;
//
// Data
//
/** Current element index. */
protected int fCurrentElementIndex;
/** Current attribute index. */
protected int fCurrentAttributeIndex;
/** fReadingExternalDTD */
protected boolean fReadingExternalDTD = false;
/** Symbol table. */
// The XMLDTDDescription with which this Grammar is associated
// element declarations
/** Number of element declarations. */
/** Element declaration name. */
/**
* Element declaration type.
* @see XMLElementDecl
*/
/**
* Element declaration content spec index. This index value is used
* to refer to the content spec information tables.
*/
/**
* Element declaration content model validator. This validator is
* constructed from the content spec nodes.
*/
private ContentModelValidator fElementDeclContentModelValidator[][] = new ContentModelValidator[INITIAL_CHUNK_COUNT][];
/** First attribute declaration of an element declaration. */
/** Last attribute declaration of an element declaration. */
// attribute declarations
/** Number of attribute declarations. */
/** Attribute declaration name. */
// is this grammar immutable? (fully constructed and not changeable)
private boolean fIsImmutable = false;
/**
* Attribute declaration type.
* @see XMLAttributeDecl
*/
/** Attribute declaration enumeration values. */
private DatatypeValidator fAttributeDeclDatatypeValidator[][] = new DatatypeValidator[INITIAL_CHUNK_COUNT][];
// content specs
// here saves the content spec binary trees for element decls,
// each element with a content model will hold a pointer which is
// the index of the head node of the content spec tree.
// entities
// notations
// other information
/** Element index mapping table. */
/** Entity index mapping table. */
/** Notation index mapping table. */
// temp variables
/** Mixed. */
private boolean fMixed;
/** Temporary qualified name. */
/** Temporary qualified name. */
/** Temporary Attribute decl. */
// for buildSyntaxTree method
/** Element declaration. */
/** Entity declaration. */
/** Simple type. */
/** Content spec node. */
/** table of XMLElementDecl */
/** Children content model operation stack. */
/** Children content model index stack. */
/** Children content model previous node index stack. */
/** Stack depth */
/** Entity stack. */
// additional fields(columns) for the element Decl pool in the Grammar
/** flag if the elementDecl is External. */
// additional fields(columns) for the attribute Decl pool in the Grammar
/** flag if the AttributeDecl is External. */
// for mixedElement method
//
// Constructors
//
/** Default constructor. */
} // <init>(SymbolTable)
// Grammar methods
// return the XMLDTDDescription object with which this is associated
return fGrammarDescription;
} // getGrammarDescription(): XMLGrammarDescription
//
// Public methods
//
/**
* Returns true if the specified element declaration is external.
*
* @param elementDeclIndex The element declaration index.
*/
if (elementDeclIndex < 0) {
return false;
}
} // getElementDeclIsExternal(int):boolean
/**
* Returns true if the specified attribute declaration is external.
*
* @param attributeDeclIndex Attribute declaration index.
*/
if (attributeDeclIndex < 0) {
return false;
}
}
if (elementDeclIndex == -1) {
return -1;
}
while (attDefIndex != -1) {
return attDefIndex;
}
}
return -1;
} // getAttributeDeclIndex (int,QName)
//
// XMLDTDHandler methods
//
/**
* The start of the DTD.
*
* @param locator The document locator, or null if the document
* location cannot be reported during the parsing of
* the document DTD. However, it is <em>strongly</em>
* recommended that a locator be supplied that can
* at least report the base system identifier of the
* DTD.
*
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
//Initialize stack
} // startDTD(XMLLocator)
/**
* This method notifies of the start of an entity. The DTD has the
* pseudo-name of "[dtd]" and parameter entity names start with '%'.
* <p>
* <strong>Note:</strong> Since the DTD is an entity, the handler
* will be notified of the start of the DTD entity by calling the
* startParameterEntity method with the entity name "[dtd]" <em>before</em> calling
* the startDTD method.
*
* @param name The name of the parameter 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 parameter entities).
* @param augs Additional information that may include infoset
* augmentations.
*
* @throws XNIException Thrown by handler to signal an error.
*/
// keep track of this entity before fEntityDepth is increased
}
fPEDepth++;
} // startParameterEntity(String,XMLResourceIdentifier,String,Augmentations)
/**
* The start of the DTD external subset.
*
* @param augs Additional information that may include infoset
* augmentations.
*
* @throws XNIException Thrown by handler to signal an error.
*/
fReadingExternalDTD = true;
} // startExternalSubset(Augmentations)
/**
* This method notifies the end of an entity. The DTD has the pseudo-name
* of "[dtd]" and parameter entity names start with '%'.
* <p>
* <strong>Note:</strong> Since the DTD is an entity, the handler
* will be notified of the end of the DTD entity by calling the
* endEntity method with the entity name "[dtd]" <em>after</em> calling
* the endDTD method.
*
* @param name The name of the entity.
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
fPEDepth--;
} // endParameterEntity(String,Augmentations)
/**
* The end of the DTD external subset.
*
* @param augs Additional information that may include infoset
* augmentations.
*
* @throws XNIException Thrown by handler to signal an error.
*/
fReadingExternalDTD = false;
} // endExternalSubset(Augmentations)
/**
* An element declaration.
*
* @param name The name of the element.
* @param contentModel The element content model.
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
throws XNIException {
// check if it is already defined
if ( tmpElementDecl != null ) {
}
else {
// duplicate element, ignored.
return;
}
}
else {
}
}
}
}
else {
}
}
//add(or set) this elementDecl to the local cache
if ( DEBUG ) {
}
} // elementDecl(String,String)
/**
* An attribute declaration.
*
* @param elementName The name of the element that this attribute
* is associated with.
* @param attributeName The name of the attribute.
* @param type The attribute type. This value will be one of
* the following: "CDATA", "ENTITY", "ENTITIES",
* "ENUMERATION", "ID", "IDREF", "IDREFS",
* "NMTOKEN", "NMTOKENS", or "NOTATION".
* @param enumeration If the type has the value "ENUMERATION", this
* array holds the allowed attribute values;
* otherwise, this array is null.
* @param defaultType The attribute default type. This value will be
* one of the following: "#FIXED", "#IMPLIED",
* "#REQUIRED", or null.
* @param defaultValue The attribute default value, or null if no
* default value is specified.
* @param nonNormalizedDefaultValue The attribute default value with no normalization
* performed, or null if no default value is specified.
*
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
//if ElementDecl has already being created in the Grammar then remove from table,
//this.fElementDeclTab.remove( (String) elementName );
}
// then it is forward reference to a element decl, create the elementDecl first.
else {
//add(or set) this elementDecl to the local cache
//set internal structure
}
//Get Grammar index to grammar array
//return, when more than one definition is provided for the same attribute of given element type
//only the first declaration is binding and later declarations are ignored
return;
}
fSimpleType.clear();
if ( defaultType != null ) {
}
}
if ( DEBUG ) {
}
fSimpleType.nonNormalizedDefaultValue = nonNormalizedDefaultValue!=null ? nonNormalizedDefaultValue.toString() : null;
}
}
fSimpleType.list = true;
}
}
fSimpleType.list = true;
}
}
fSimpleType.list = true;
}
}
}
}
else {
// REVISIT: Report error message. -Ac
}
// REVISIT: The datatype should be stored with the attribute value
// and not special-cased in the XMLValidator. -Ac
//fSimpleType.datatypeValidator = fDatatypeValidatorFactory.createDatatypeValidator(type, null, facets, fSimpleType.list);
} // attributeDecl(String,String,String,String[],String,XMLString,XMLString, Augmentations)
/**
* 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.
*/
if( entityIndex == -1){
}
} // 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 declaration.
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
if( entityIndex == -1){
}
} // 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.
*/
if (entityIndex == -1) {
}
} // unparsedEntityDecl(String,StringXMLResourceIdentifier,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.
*/
if (notationIndex == -1) {
}
} // notationDecl(String,XMLResourceIdentifier,Augmentations)
/**
* The end of the DTD.
*
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
fIsImmutable = true;
// make sure our description contains useful stuff...
// we don't know what the root is; so use possibleRoots...
final int size = fElementDeclCount;
for (int i = 0; i < size; ++i) {
chunk = i >> CHUNK_SHIFT;
index = i & CHUNK_MASK;
}
}
} // endDTD()
// sets the source of this handler
fDTDSource = source;
} // setDTDSource(XMLDTDSource)
// returns the source of this handler
return fDTDSource;
} // getDTDSource(): XMLDTDSource
// no-op methods
/**
* 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 is only called for external
* parameter entities referenced in the DTD.
*
* @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.
*/
throws XNIException {}
/**
* 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.
*/
/**
* 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.
*/
/**
* The start of an attribute list.
*
* @param elementName The name of the element that this attribute
* list is associated with.
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
throws XNIException {}
/**
* The end of an attribute list.
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
/**
* 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 XMLDTDHandler#CONDITIONAL_INCLUDE
* @see XMLDTDHandler#CONDITIONAL_IGNORE
*/
throws XNIException {}
/**
* Characters within an IGNORE conditional section.
*
* @param text The ignored text.
* @param augs Additional information that may include infoset
* augmentations.
*/
throws XNIException {}
/**
* The end of a conditional section.
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
//
// XMLDTDContentModelHandler methods
//
// set content model source
}
// get content model source
return fDTDContentModelSource;
}
/**
* 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.
*
* @param elementName The name of the element.
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
throws XNIException {
if ( elementDecl != null ) {
}
fDepth = 0;
} // startContentModel(String)
/**
* A start of either a mixed or children content model. A mixed
* content model will immediately be followed by a call to the
* <code>pcdata()</code> method. A children content model will
*
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*
* @see #any
* @see #empty
*/
fDepth++;
fMixed = false;
} // startGroup()
/**
* The appearance of "#PCDATA" within a group signifying a
* mixed content model. This method will be the first called
* following the content model's <code>startGroup()</code>.
*
*@param augs Additional information that may include infoset
* augmentations.
*
* @throws XNIException Thrown by handler to signal an error.
*
* @see #startGroup
*/
fMixed = true;
} // pcdata()
/**
* A referenced element in a mixed or children content model.
*
* @param elementName The name of the referenced element.
* @param augs Additional information that may include infoset
* augmentations.
*
* @throws XNIException Thrown by handler to signal an error.
*/
if (fMixed) {
}
else {
}
}
else {
}
} // element(String)
/**
* The separator between choices or sequences of a mixed or children
* content model.
*
* @param separator The type of children separator.
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*
* @see org.apache.xerces.xni.XMLDTDContentModelHandler#SEPARATOR_CHOICE
* @see org.apache.xerces.xni.XMLDTDContentModelHandler#SEPARATOR_SEQUENCE
*/
if (!fMixed) {
if (fOpStack[fDepth] != XMLContentSpec.CONTENTSPECNODE_SEQ && separator == XMLDTDContentModelHandler.SEPARATOR_CHOICE ) {
fNodeIndexStack[fDepth] = addContentSpecNode(fOpStack[fDepth], fPrevNodeIndexStack[fDepth], fNodeIndexStack[fDepth]);
}
} else if (fOpStack[fDepth] != XMLContentSpec.CONTENTSPECNODE_CHOICE && separator == XMLDTDContentModelHandler.SEPARATOR_SEQUENCE) {
fNodeIndexStack[fDepth] = addContentSpecNode(fOpStack[fDepth], fPrevNodeIndexStack[fDepth], fNodeIndexStack[fDepth]);
}
}
}
} // separator(short)
/**
* The occurrence count for a child in a children content model or
* for the mixed content model group.
*
* @param occurrence The occurrence count for the last element
* or group.
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*
* @see org.apache.xerces.xni.XMLDTDContentModelHandler#OCCURS_ZERO_OR_ONE
* @see org.apache.xerces.xni.XMLDTDContentModelHandler#OCCURS_ZERO_OR_MORE
* @see org.apache.xerces.xni.XMLDTDContentModelHandler#OCCURS_ONE_OR_MORE
*/
if (!fMixed) {
fNodeIndexStack[fDepth] = addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE, fNodeIndexStack[fDepth], -1);
fNodeIndexStack[fDepth] = addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE, fNodeIndexStack[fDepth], -1 );
fNodeIndexStack[fDepth] = addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE, fNodeIndexStack[fDepth], -1 );
}
}
} // occurrence(short)
/**
* The end of a group for mixed or children content models.
*
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*/
if (!fMixed) {
fNodeIndexStack[fDepth] = addContentSpecNode(fOpStack[fDepth], fPrevNodeIndexStack[fDepth], fNodeIndexStack[fDepth]);
}
}
} // endGroup()
// no-op methods
/**
* A content model of ANY.
*
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*
* @see #empty
* @see #startGroup
*/
/**
* A content model of EMPTY.
*
* @param augs Additional information that may include infoset
* augmentations.
* @throws XNIException Thrown by handler to signal an error.
*
* @see #any
* @see #startGroup
*/
/**
* The end of a content model.
* @param augs Additional information that may include infoset
* augmentations.
*
* @throws XNIException Thrown by handler to signal an error.
*/
//
// Grammar methods
//
/** Returns true if this grammar is namespace aware. */
public boolean isNamespaceAware() {
return false;
} // isNamespaceAware():boolean
/** Returns the symbol table. */
return fSymbolTable;
} // getSymbolTable():SymbolTable
/**
* Returns the index of the first element declaration. This index
* is then used to query more information about the element declaration.
*
* @see #getNextElementDeclIndex
* @see #getElementDecl
*/
public int getFirstElementDeclIndex() {
} // getFirstElementDeclIndex():int
/**
* Returns the next index of the element declaration following the
* specified element declaration.
*
* @param elementDeclIndex The element declaration index.
*/
} // getNextElementDeclIndex(int):int
/**
* getElementDeclIndex
*
* @param elementDeclName
*
* @return index of the elementDeclName in scope
*/
//System.out.println("getElementDeclIndex("+elementDeclName+") -> "+mapping);
return mapping;
} // getElementDeclIndex(String):int
/** Returns the element decl index.
* @param elementDeclQName qualilfied name of the element
*/
} // getElementDeclIndex(QName):int
/** make separate function for getting contentSpecType of element.
* we can avoid setting of the element values.
*/
return -1 ;
}
return -1 ;
}
else{
}
}//getContentSpecType
/**
* getElementDecl
*
* @param elementDeclIndex
* @param elementDecl The values of this structure are set by this call.
*
* @return True if find the element, False otherwise.
*/
return false;
}
} else {
}
/* Validators are null until we add that code */
if (elementDecl.type == XMLElementDecl.TYPE_CHILDREN || elementDecl.type == XMLElementDecl.TYPE_MIXED) {
}
return true;
} // getElementDecl(int,XMLElementDecl):boolean
return null;
}
}
// REVISIT: Make this getAttributeDeclCount/getAttributeDeclAt. -Ac
/**
* getFirstAttributeDeclIndex
*
* @param elementDeclIndex
*
* @return index of the first attribute for element declaration elementDeclIndex
*/
} // getFirstAttributeDeclIndex
/**
* getNextAttributeDeclIndex
*
* @param attributeDeclIndex
*
* @return index of the next attribute of the attribute at attributeDeclIndex
*/
} // getNextAttributeDeclIndex
/**
* getAttributeDecl
*
* @param attributeDeclIndex
* @param attributeDecl The values of this structure are set by this call.
*
* @return true if getAttributeDecl was able to fill in the value of attributeDecl
*/
return false;
}
short attributeType;
boolean isList;
attributeType = -1;
isList = false;
} else {
}
return true;
} // getAttributeDecl
/**
* Returns whether the given attribute is of type CDATA or not
*
* @param elName The element name.
* @param atName The attribute name.
*
* @return true if the attribute is of type CDATA
*/
return false;
}
return true;
}
/**
* getEntityDeclIndex
*
* @param entityDeclName
*
* @return the index of the EntityDecl
*/
if (entityDeclName == null) {
return -1;
}
} // getEntityDeclIndex
/**
* getEntityDecl
*
* @param entityDeclIndex
* @param entityDecl
*
* @return true if getEntityDecl was able to fill entityDecl with the contents of the entity
* with index entityDeclIndex
*/
return false;
}
return true;
} // getEntityDecl
/**
* getNotationDeclIndex
*
* @param notationDeclName
*
* @return the index if found a notation with the name, otherwise -1.
*/
if (notationDeclName == null) {
return -1;
}
} // getNotationDeclIndex
/**
* getNotationDecl
*
* @param notationDeclIndex
* @param notationDecl
*
* @return return true of getNotationDecl can fill notationDecl with information about
* the notation at notationDeclIndex.
*/
return false;
}
return true;
} // getNotationDecl
/**
* getContentSpec
*
* @param contentSpecIndex
* @param contentSpec
*
* @return true if find the requested contentSpec node, false otherwise
*/
return false;
return true;
}
/**
* Returns the index to the content spec for the given element
* declaration, or <code>-1</code> if the element declaration
* index was invalid.
*/
return -1;
}
}
/**
* getContentSpecAsString
*
* @param elementDeclIndex
*
* @return String
*/
return null;
}
// lookup content spec node
// build string
int nextContentSpec;
switch (parentContentSpecType) {
case XMLContentSpec.CONTENTSPECNODE_LEAF: {
}
else {
}
break;
}
true, parentContentSpecType );
} else {
true, parentContentSpecType );
}
break;
}
}
}
}
else {
true, parentContentSpecType );
}
true, parentContentSpecType );
} else {
true, parentContentSpecType );
}
break;
}
}
}
}
else {
}
true, parentContentSpecType );
} else {
true, parentContentSpecType);
}
break;
}
case XMLContentSpec.CONTENTSPECNODE_SEQ: {
true, parentContentSpecType );
break;
}
case XMLContentSpec.CONTENTSPECNODE_ANY: {
}
break;
}
break;
}
break;
}
default: {
}
} // switch type
// return string
}
// not found
return null;
} // getContentSpecAsString(int):String
// debugging
public void printElements( ) {
int elementDeclIndex = 0;
// ", "+ elementDecl.contentModelValidator.toString());
}
}
while (attributeDeclIndex != -1) {
if (attributeDeclIndex != -1) {
}
}
}
//
// Protected methods
//
/**
* Adds the content spec to the given element declaration.
*/
fNodeIndexStack != null) {
}
else {
}
}
}
}
/**
* getElementContentModelValidator
*
* @param elementDeclIndex
*
* @return its ContentModelValidator if any.
*/
// If we have one, just return that. Otherwise, gotta create one
if (contentModel != null) {
return contentModel;
}
return null;
}
// Get the type of content this element has
/***
if ( contentSpecIndex == -1 )
return null;
/***/
// And create the content model according to the spec type
//
// Just create a mixel content model object. This type of
// content model is optimized for mixed content validation.
//
false);
// This method will create an optimal model for the complexity
// of the element's defined model. If its simple, it will create
// a SimpleContentModel object. If its a simple list, it will
// create a SimpleListContentModel object. If its complex, it
// will create a DFAContentModel object.
//
} else {
throw new RuntimeException("Unknown content type for a element decl "
+ "in getElementContentModelValidator() in AbstractDTDGrammar class");
}
// Add the new model to the content model for this element
return contentModel;
} // getElementContentModelValidator(int):ContentModelValidator
protected int createElementDecl() {
return fElementDeclCount++;
}
return;
}
}
}
int elementDeclIndex) {
}
return;
}
}
return;
}
}
protected int createAttributeDecl() {
return fAttributeDeclCount++;
}
}
fAttributeDeclNonNormalizedDefaultValue[attrChunk][attrIndex] = attributeDecl.simpleType.nonNormalizedDefaultValue;
while (index != -1) {
if (index == attributeDeclIndex) {
break;
}
}
if (index == -1) {
} else {
}
}
}
protected int createContentSpec() {
return fContentSpecCount++;
}
}
protected int createEntityDecl() {
return fEntityCount++;
}
}
protected int createNotationDecl() {
return fNotationCount++;
}
}
/**
* Create an XMLContentSpec for a single non-leaf
*
* @param nodeType the type of XMLContentSpec to create - from XMLContentSpec.CONTENTSPECNODE_*
* @param nodeValue handle to an XMLContentSpec
* @return handle to the newly create XMLContentSpec
*/
// create content spec node
int contentSpecIndex = createContentSpec();
// set content spec node values
// return index
return contentSpecIndex;
} // addContentSpecNode(short,String):int
/**
* create an XMLContentSpec for a leaf
*
* @param elementName the name (Element) for the node
* @return handle to the newly create XMLContentSpec
*/
// create content spec node
int contentSpecIndex = createContentSpec();
// set content spec node values
elementName, null);
// return index
return contentSpecIndex;
} // addUniqueLeafNode(String):int
/**
* Create an XMLContentSpec for a two child leaf
*
* @param nodeType the type of XMLContentSpec to create - from XMLContentSpec.CONTENTSPECNODE_*
* @param leftNodeIndex handle to an XMLContentSpec
* @param rightNodeIndex handle to an XMLContentSpec
* @return handle to the newly create XMLContentSpec
*/
int leftNodeIndex, int rightNodeIndex) {
// create content spec node
int contentSpecIndex = createContentSpec();
// set content spec node values
int[] leftIntArray = new int[1];
int[] rightIntArray = new int[1];
// return index
return contentSpecIndex;
} // addContentSpecNode(short,int,int):int
/** Initialize content model stack. */
protected void initializeContentModelStack() {
fOpStack = new short[8];
fNodeIndexStack = new int[8];
fPrevNodeIndexStack = new int[8];
}
} // initializeContentModelStack()
boolean isImmutable() {
return fIsImmutable;
}
//
// Private methods
//
int parentContentSpecType ) {
switch (thisContentSpec) {
case XMLContentSpec.CONTENTSPECNODE_LEAF: {
}
}
}
else {
}
break;
}
}
else {
}
break;
}
}
else {
}
break;
}
}
else {
}
break;
}
case XMLContentSpec.CONTENTSPECNODE_SEQ: {
if (parens) {
}
}
else {
}
if (parens) {
}
break;
}
case XMLContentSpec.CONTENTSPECNODE_ANY: {
}
break;
}
break;
}
break;
}
default: {
break;
}
} // switch type
} // appendContentSpec(XMLContentSpec.Provider,StringPool,XMLContentSpec,StringBuffer,boolean)
// debugging
}
} // printAttribute(int)
// content models
/**
* When the element has a 'CHILDREN' model, this method is called to
* create the content model object. It looks for some special case simple
* models and creates SimpleContentModel objects for those. For the rest
* it creates the standard DFA style model.
*/
//
// Get the content spec node for the element we are working on.
// This will tell us what kind of node it is, which tells us what
// kind of model we will try to create.
//
// let fall through to build a DFAContentModel
}
//
// Check that the left value is not -1, since any content model
// with PCDATA should be MIXED, so we should not have gotten here.
//
throw new RuntimeException("ImplementationMessages.VAL_NPCD");
//
// Its a single leaf, so its an 'a' type of content model, i.e.
// just one instance of one element. That one is definitely a
// simple content model.
//
//
// Lets see if both of the children are leafs. If so, then it
// it has to be a simple content model
//
//
// Its a simple choice or sequence, so we can do a simple
// content model for it.
//
}
//
// Its a repetition, so see if its one child is a leaf. If so
// its a repetition of a single element, so we can do a simple
// content model for that.
//
//
// It is, so we can create a simple content model here that
// will check for this repetition. We pass -1 for the unused
// right node.
//
}
} else {
throw new RuntimeException("ImplementationMessages.VAL_CST");
}
//
// Its not a simple content model, so here we have to create a DFA
// for this element. So we create a DFAContentModel object. He
// encapsulates all of the work to create the DFA.
//
fLeafCount = 0;
//int leafCount = countLeaves(contentSpecIndex);
fLeafCount = 0;
// REVISIT: has to be fLeafCount because we convert x+ to x,x*, one more leaf
} // createChildModel(int):ContentModelValidator
// We will build a node at this level for the new tree
//nodeRet = new CMAny(contentSpec.type, -1, fLeafCount++);
}
}
}
//
// If this node is a leaf, then its an easy one. We just add it
// to the tree.
//
//
// Create a new leaf node, and pass it the current leaf count,
// which is its DFA state position. Bump the leaf count after
// storing it. This makes the positions zero based since we
// store first and then increment.
//
}
else {
//
// Its not a leaf, so we have to recurse its left and maybe right
// nodes. Save both values before we recurse and trash the node.
//
// Recurse on both children, and return a binary op node
// with the two created sub nodes as its children. The node
// type is the same type as the source.
//
}
}
}
else {
throw new RuntimeException("ImplementationMessages.VAL_CST");
}
}
// And return our new node for this level
return nodeRet;
}
/**
* Build a vector of valid QNames from Content Spec
* table.
*
* @param contentSpecIndex
* Content Spec index
* @param vectorQName
* Array of QName
* @exception RuntimeException
*/
// Handle any and leaf nodes
// resize arrays, if needed
}
// save values and return length
return;
}
//
// Its not a leaf, so we have to recurse its left and maybe right
// nodes. Save both values before we recurse and trash the node.
//
int rightNode = -1 ;
else
return;
return;
}
return;
}
// error
throw new RuntimeException("Invalid content spec type seen in contentSpecTree() method of AbstractDTDGrammar class : "+contentSpec.type);
} // contentSpecTree(int,XMLContentSpec,ChildrenList)
// ensure capacity
fElementDeclContentModelValidator = resize(fElementDeclContentModelValidator, fElementDeclContentModelValidator.length * 2);
fElementDeclContentSpecIndex = resize(fElementDeclContentSpecIndex,fElementDeclContentSpecIndex.length * 2);
fElementDeclFirstAttributeDeclIndex = resize(fElementDeclFirstAttributeDeclIndex, fElementDeclFirstAttributeDeclIndex.length * 2);
fElementDeclLastAttributeDeclIndex = resize(fElementDeclLastAttributeDeclIndex, fElementDeclLastAttributeDeclIndex.length * 2);
}
return;
}
return;
}
fAttributeDeclEnumeration = resize(fAttributeDeclEnumeration, fAttributeDeclEnumeration.length * 2);
fAttributeDeclDefaultType = resize(fAttributeDeclDefaultType, fAttributeDeclDefaultType.length * 2);
fAttributeDeclDatatypeValidator = resize(fAttributeDeclDatatypeValidator, fAttributeDeclDatatypeValidator.length * 2);
fAttributeDeclDefaultValue = resize(fAttributeDeclDefaultValue, fAttributeDeclDefaultValue.length * 2);
fAttributeDeclNonNormalizedDefaultValue = resize(fAttributeDeclNonNormalizedDefaultValue, fAttributeDeclNonNormalizedDefaultValue.length * 2);
fAttributeDeclNextAttributeDeclIndex = resize(fAttributeDeclNextAttributeDeclIndex, fAttributeDeclNextAttributeDeclIndex.length * 2);
}
return;
}
return;
}
}
return;
}
return;
}
}
return;
}
return;
}
}
return;
}
return;
}
//
// Private static methods
//
// resize chunks
return newarray;
}
return newarray;
}
return newarray;
}
return newarray;
}
return newarray;
}
return newarray;
}
return newarray;
}
return newarray;
}
return newarray;
}
//
// Classes
//
/**
* Children list for <code>contentSpecTree</code> method.
*
* @xerces.internal
*
* @author Eric Ye, IBM
*/
private static class ChildrenList {
//
// Data
//
/** Length. */
// NOTE: The following set of data is mutually exclusive. It is
// written this way because Java doesn't have a native
// union data structure. -Ac
/** Left and right children names. */
/** Left and right children types. */
//
// Constructors
//
public ChildrenList () {}
} // class ChildrenList
//
// Classes
//
/**
* A simple Hashtable implementation that takes a tuple (String, String)
* as the key and a int as value.
*
* @xerces.internal
*
* @author Eric Ye, IBM
* @author Andy Clark, IBM
*/
protected static final class QNameHashtable {
//
// Constants
//
/** Initial bucket size (4). */
// NOTE: Changed previous hashtable size from 512 to 101 so
// that we get a better distribution for hashing. -Ac
/** Hashtable size (101). */
//
// Data
//
//
// Public methods
//
/** Associates the given value with the specified key tuple. */
} else {
}
boolean found = false;
int j=1;
for (int i=0; i<count; i++){
found = true;
break;
}
j += 2;
}
if (! found) {
}
}
//System.out.println("put("+key+" -> "+value+')');
//System.out.println("get("+key+") -> "+get(key));
} // put(int,String,String,int)
/** Returns the value associated with the specified key tuple. */
return -1;
}
int j=1;
for (int i=0; i<count; i++){
}
j += 2;
}
return -1;
} // get(int,String,String)
} // class QNameHashtable
//
// EntityState methods
//
}
if (entityIndex >-1) {
//for unparsed entity notation!=null
}
return false;
}
} // class DTDGrammar