286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * The Apache Software License, Version 1.1 286N/A * Copyright (c) 1999-2002 The Apache Software Foundation. 286N/A * Redistribution and use in source and binary forms, with or without 286N/A * modification, are permitted provided that the following conditions 286N/A * 1. Redistributions of source code must retain the above copyright 286N/A * notice, this list of conditions and the following disclaimer. 286N/A * 2. Redistributions in binary form must reproduce the above copyright 286N/A * notice, this list of conditions and the following disclaimer in 286N/A * the documentation and/or other materials provided with the 286N/A * 3. The end-user documentation included with the redistribution, 286N/A * if any, must include the following acknowledgment: 286N/A * "This product includes software developed by the 286N/A * Alternately, this acknowledgment may appear in the software itself, 286N/A * if and wherever such third-party acknowledgments normally appear. 286N/A * 4. The names "Xerces" and "Apache Software Foundation" must 286N/A * not be used to endorse or promote products derived from this 286N/A * software without prior written permission. For written 286N/A * permission, please contact apache@apache.org. 286N/A * 5. Products derived from this software may not be called "Apache", 286N/A * nor may "Apache" appear in their name, without prior written 286N/A * permission of the Apache Software Foundation. 286N/A * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 286N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 286N/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 286N/A * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 286N/A * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 286N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 286N/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 286N/A * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 286N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 286N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 286N/A * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 286N/A * ==================================================================== 286N/A * This software consists of voluntary contributions made by many 286N/A * individuals on behalf of the Apache Software Foundation and was 286N/A * originally based on software copyright (c) 1999, International 286N/A * information on the Apache Software Foundation, please see 286N/A * The DTD processor. The processor implements a DTD 286N/A * filter: receiving DTD events from the DTD scanner; validating 286N/A * the content and structure; building a grammar, if applicable; 286N/A * and notifying the DTDHandler of the information resulting from the 286N/A * This component requires the following features and properties from the 286N/A * component manager that uses it: 286N/A * @author Neil Graham, IBM 286N/A /** Top level scope (-1). */ 286N/A /** Feature identifier: validation. */ 286N/A /** Feature identifier: notify character references. */ 286N/A /** Feature identifier: warn on duplicate attdef */ 286N/A /** Feature identifier: warn on undeclared element referenced in content model. */ 286N/A // property identifiers 286N/A /** Property identifier: symbol table. */ 286N/A /** Property identifier: error reporter. */ 286N/A /** Property identifier: grammar pool. */ 286N/A /** Property identifier: validator . */ 286N/A // recognized features and properties 286N/A /** Recognized features. */ 286N/A /** Feature defaults. */ 286N/A /** Recognized properties. */ 286N/A /** Property defaults. */ 286N/A /** Validation against only DTD */ 286N/A /** warn on duplicate attribute definition, this feature works only when validation is true */ 286N/A /** warn on undeclared element referenced in content model, this feature only works when valiation is true */ 286N/A // the validator to which we look for our grammar bucket (the 286N/A // validator needs to hold the bucket so that it can initialize 286N/A // the grammar with details like whether it's for a standalone document... 286N/A // the grammar pool we'll try to add the grammar to: 286N/A /** DTD content model handler. */ 286N/A /** DTD content model source. */ 286N/A /** Perform validation. */ 286N/A /** True if in an ignore conditional section of the DTD. */ 286N/A // information regarding the current element 286N/A /** Temporary entity declaration. */ 286N/A /** Notation declaration hash. */ 286N/A /** DTD element declaration name. */ 286N/A /** Mixed element type "hash". */ 286N/A /** Element declarations in DTD. */ 286N/A // to check for duplicate ID or ANNOTATION attribute declare in 286N/A // ATTLIST, and misc VCs 286N/A /** ID attribute names. */ 286N/A /** NOTATION attribute names. */ 286N/A /** NOTATION enumeration values. */ 286N/A /** Default constructor. */ 286N/A // XMLComponent methods 286N/A * Resets the component. The component can query the component manager 286N/A * about any features and properties that affect the operation of the 286N/A * @param componentManager The component manager. 286N/A * @throws SAXException Thrown by component on finitialization error. 286N/A * For example, if a feature or property is 286N/A * required for the operation of the component, the 286N/A * component manager may throw a 286N/A * SAXNotRecognizedException or a 286N/A * SAXNotSupportedException. 286N/A // parser settings have not been changed 286N/A // get needed components 286N/A // we get our grammarBucket from the validator... 286N/A }
// reset(XMLComponentManager) 286N/A * Returns a list of feature identifiers that are recognized by 286N/A * this component. This method may return null if no features 286N/A * are recognized by this component. 286N/A }
// getRecognizedFeatures():String[] 286N/A * Sets the state of a feature. This method is called by the component 286N/A * manager any time after reset when a feature changes state. 286N/A * <strong>Note:</strong> Components should silently ignore features 286N/A * that do not affect the operation of the component. 286N/A * @param featureId The feature identifier. 286N/A * @param state The state of the feature. 286N/A * @throws SAXNotRecognizedException The component should not throw 286N/A * @throws SAXNotSupportedException The component should not throw 286N/A }
// setFeature(String,boolean) 286N/A * Returns a list of property identifiers that are recognized by 286N/A * this component. This method may return null if no properties 286N/A * are recognized by this component. 286N/A }
// getRecognizedProperties():String[] 286N/A * Sets the value of a property. This method is called by the component 286N/A * manager any time after reset when a property changes value. 286N/A * <strong>Note:</strong> Components should silently ignore properties 286N/A * that do not affect the operation of the component. 286N/A * @param propertyId The property identifier. 286N/A * @param value The value of the property. 286N/A * @throws SAXNotRecognizedException The component should not throw 286N/A * @throws SAXNotSupportedException The component should not throw 286N/A }
// setProperty(String,Object) 286N/A * Returns the default state for a feature, or null if this 286N/A * component does not want to report a default value for this 286N/A * @param featureId The feature identifier. 286N/A }
// getFeatureDefault(String):Boolean 286N/A * Returns the default state for a property, or null if this 286N/A * component does not want to report a default value for this 286N/A * @param propertyId The property identifier. 286N/A }
// getPropertyDefault(String):Object 286N/A // XMLDTDSource methods 286N/A * Sets the DTD handler. 286N/A * @param dtdHandler The DTD handler. 286N/A }
// setDTDHandler(XMLDTDHandler) 286N/A * Returns the DTD handler. 286N/A * @return The DTD handler. 286N/A }
// getDTDHandler(): XMLDTDHandler 286N/A // XMLDTDContentModelSource methods 286N/A * Sets the DTD content model handler. 286N/A * @param dtdContentModelHandler The DTD content model handler. 286N/A }
// setDTDContentModelHandler(XMLDTDContentModelHandler) 286N/A * Gets the DTD content model handler. 286N/A * @return dtdContentModelHandler The DTD content model handler. 286N/A }
// getDTDContentModelHandler(): XMLDTDContentModelHandler 286N/A // XMLDTDContentModelHandler and XMLDTDHandler methods 286N/A * The start of the DTD external subset. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * The end of the DTD external subset. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * Check standalone entity reference. 286N/A * Made static to make common between the validator and loader. 286N/A *@param grammar grammar to which entity belongs 286N/A * @param tempEntityDecl empty entity declaration to put results in 286N/A * @param errorReporter error reporter to send errors to 286N/A * @throws XNIException Thrown by application to signal an error. 286N/A // check VC: Standalone Document Declartion, entities references appear in the document. 286N/A "MSG_REFERENCE_TO_EXTERNALLY_DECLARED_ENTITY_WHEN_STANDALONE",
286N/A * @param text The text in the comment. 286N/A * @param augs Additional information that may include infoset augmentations 286N/A * @throws XNIException Thrown by application to signal an error. 286N/A }
// comment(XMLString) 286N/A * A processing instruction. Processing instructions consist of a 286N/A * target name and, optionally, text data. The data is only meaningful 286N/A * Typically, a processing instruction's data will contain a series 286N/A * of pseudo-attributes. These pseudo-attributes follow the form of 286N/A * element attributes but are <strong>not</strong> parsed or presented 286N/A * to the application as anything other than text. The application is 286N/A * responsible for parsing the data. 286N/A * @param target The target. 286N/A * @param data The data or null if none specified. 286N/A * @param augs Additional information that may include infoset augmentations 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A }
// processingInstruction(String,XMLString) 286N/A // XMLDTDHandler methods 286N/A * The start of the DTD. 286N/A * @param locator The document locator, or null if the document 286N/A * location cannot be reported during the parsing of 286N/A * the document DTD. However, it is <em>strongly</em> 286N/A * recommended that a locator be supplied that can 286N/A * at least report the base system identifier of the 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A // the grammar bucket's DTDGrammar will now be the 286N/A // one we want, whether we're constructing it or not. 286N/A // if we're not constructing it, then we should not have a reference 286N/A }
// startDTD(XMLLocator) 286N/A * Characters within an IGNORE conditional section. 286N/A * @param text The ignored text. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A // ignored characters in DTD 286N/A * Notifies of the presence of a TextDecl line in an entity. If present, 286N/A * this method will be called immediately following the startParameterEntity call. 286N/A * <strong>Note:</strong> This method is only called for external 286N/A * parameter entities referenced in the DTD. 286N/A * @param version The XML version, or null if not specified. 286N/A * @param encoding The IANA encoding name of the entity. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * This method notifies of the start of a parameter entity. The parameter 286N/A * entity name start with a '%' character. 286N/A * @param name The name of the parameter entity. 286N/A * @param identifier The resource identifier. 286N/A * @param encoding The auto-detected IANA encoding name of the entity 286N/A * stream. This value will be null in those situations 286N/A * where the entity encoding is not auto-detected (e.g. 286N/A * internal parameter entities). 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * This method notifies the end of a parameter entity. Parameter entity 286N/A * names begin with a '%' character. 286N/A * @param name The name of the parameter entity. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * An element declaration. 286N/A * @param name The name of the element. 286N/A * @param contentModel The element content model. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A //check VC: Unique Element Declaration 286N/A "MSG_ELEMENT_ALREADY_DECLARED",
286N/A }
// elementDecl(String,String) 286N/A * The start of an attribute list. 286N/A * @param elementName The name of the element that this attribute 286N/A * list is associated with. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A }
// startAttlist(String) 286N/A * An attribute declaration. 286N/A * @param elementName The name of the element that this attribute 286N/A * @param attributeName The name of the attribute. 286N/A * @param type The attribute type. This value will be one of 286N/A * the following: "CDATA", "ENTITY", "ENTITIES", 286N/A * "ENUMERATION", "ID", "IDREF", "IDREFS", 286N/A * "NMTOKEN", "NMTOKENS", or "NOTATION". 286N/A * @param enumeration If the type has the value "ENUMERATION" or 286N/A * "NOTATION", this array holds the allowed attribute 286N/A * values; otherwise, this array is null. 286N/A * @param defaultType The attribute default type. This value will be 286N/A * one of the following: "#FIXED", "#IMPLIED", 286N/A * "#REQUIRED", or null. 286N/A * @param defaultValue The attribute default value, or null if no 286N/A * default value is specified. 286N/A * @param nonNormalizedDefaultValue The attribute default value with no normalization 286N/A * performed, or null if no default value is specified. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A //Get Grammar index to grammar array 286N/A //more than one attribute definition is provided for the same attribute of a given element type. 286N/A //this feature works only when validation is true. 286N/A "MSG_DUPLICATE_ATTRIBUTE_DEFINITION",
286N/A // a) VC: One ID per Element Type, If duplicate ID attribute 286N/A // b) VC: ID attribute Default. if there is a declareared attribute 286N/A // default for ID it should be of type #IMPLIED or #REQUIRED 286N/A "IDDefaultTypeInvalid",
286N/A //we should not report an error, when there is duplicate attribute definition for given element type 286N/A //according to XML 1.0 spec, When more than one definition is provided for the same attribute of a given 286N/A //element type, the first declaration is binding and later declaration are *ignored*. So processor should 286N/A //ignore the second declarations, however an application would be warned of the duplicate attribute defintion 286N/A // one typical case where this could be a problem, when any XML file 286N/A // provide the ID type information through internal subset so that it is available to the parser which read 286N/A //only internal subset. Now that attribute declaration(ID Type) can again be part of external parsed entity 286N/A //referenced. At that time if parser doesn't make this distinction it will throw an error for VC One ID per 286N/A //Element Type, which (second defintion) actually should be ignored. Application behavior may differ on the 286N/A //basis of error or warning thrown. - nb. 286N/A "MSG_MORE_THAN_ONE_ID_ATTRIBUTE",
286N/A // VC: One Notation Per Element Type, should check if there is a 286N/A // duplicate NOTATION attribute 286N/A // VC: Notation Attributes: all notation names in the 286N/A // (attribute) declaration must be declared. 286N/A //we should not report an error, when there is duplicate attribute definition for given element type 286N/A //according to XML 1.0 spec, When more than one definition is provided for the same attribute of a given 286N/A //element type, the first declaration is binding and later declaration are *ignored*. So processor should 286N/A //ignore the second declarations, however an application would be warned of the duplicate attribute definition 286N/A //warning thrown. - nb. 286N/A "MSG_MORE_THAN_ONE_NOTATION_ATTRIBUTE",
286N/A // VC: No Duplicate Tokens 286N/A // XML 1.0 SE Errata - E2 286N/A // Only report the first uniqueness violation. There could be others, 286N/A // but additional overhead would be incurred tracking unique tokens 286N/A // that have already been encountered. -- mrglavas 286N/A ?
"MSG_DISTINCT_TOKENS_IN_ENUMERATION" 286N/A :
"MSG_DISTINCT_NOTATION_IN_ENUMERATION",
286N/A // VC: Attribute Default Legal 286N/A "MSG_ATT_DEFAULT_INVALID",
286N/A }
// attributeDecl(String,String,String,String[],String,XMLString, XMLString, Augmentations) 286N/A * The end of an attribute list. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * An internal entity declaration. 286N/A * @param name The name of the entity. Parameter entity names start with 286N/A * '%', whereas the name of a general entity is just the 286N/A * @param text The value of the entity. 286N/A * @param nonNormalizedText The non-normalized value of the entity. This 286N/A * value contains the same sequence of characters that was in 286N/A * the internal entity declaration, without any entity 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A //If the same entity is declared more than once, the first declaration 286N/A //encountered is binding, SAX requires only effective(first) declaration 286N/A //to be reported to the application 286N/A //REVISIT: Does it make sense to pass duplicate Entity information across 286N/A //its a new entity and hasn't been declared. 286N/A //store internal entity declaration in grammar 286N/A }
// internalEntityDecl(String,XMLString,XMLString) 286N/A * An external entity declaration. 286N/A * @param name The name of the entity. Parameter entity names start 286N/A * with '%', whereas the name of a general entity is just 286N/A * @param identifier An object containing all location information 286N/A * pertinent to this external entity. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A //If the same entity is declared more than once, the first declaration 286N/A //encountered is binding, SAX requires only effective(first) declaration 286N/A //to be reported to the application 286N/A //REVISIT: Does it make sense to pass duplicate entity information across 286N/A //its a new entity and hasn't been declared. 286N/A //store external entity declaration in grammar 286N/A }
// externalEntityDecl(String,XMLResourceIdentifier, Augmentations) 286N/A * An unparsed entity declaration. 286N/A * @param name The name of the entity. 286N/A * @param identifier An object containing all location information 286N/A * pertinent to this entity. 286N/A * @param notation The name of the notation. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A // VC: Notation declared, in the production of NDataDecl 286N/A }
// unparsedEntityDecl(String,XMLResourceIdentifier,String,Augmentations) 286N/A * A notation declaration 286N/A * @param name The name of the notation. 286N/A * @param identifier An object containing all location information 286N/A * pertinent to this notation. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A // VC: Unique Notation Name 286N/A }
// notationDecl(String,XMLResourceIdentifier, Augmentations) 286N/A * The start of a conditional section. 286N/A * @param type The type of the conditional section. This value will 286N/A * either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * @see #CONDITIONAL_INCLUDE 286N/A * @see #CONDITIONAL_IGNORE 286N/A }
// startConditional(short) 286N/A * The end of a conditional section. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A // VC : Notation Declared. for external entity declaration [Production 76]. 286N/A "MSG_NOTATION_NOT_DECLARED_FOR_UNPARSED_ENTITYDECL",
286N/A // VC: Notation Attributes: 286N/A // all notation names in the (attribute) declaration must be declared. 286N/A "MSG_NOTATION_NOT_DECLARED_FOR_NOTATIONTYPE_ATTRIBUTE",
286N/A // VC: No Notation on Empty Element 286N/A // An attribute of type NOTATION must not be declared on an element declared EMPTY. 286N/A "NoNotationOnEmptyElement",
286N/A // should be safe to release these references 286N/A // check whether each element referenced in a content model is declared 286N/A // sets the XMLDTDSource of this handler 286N/A }
// setDTDSource(XMLDTDSource) 286N/A // returns the XMLDTDSource of this handler 286N/A }
// getDTDSource(): XMLDTDSource 286N/A // XMLDTDContentModelHandler methods 286N/A // sets the XMLContentModelDTDSource of this handler 286N/A }
// setDTDContentModelSource(XMLDTDContentModelSource) 286N/A // returns the XMLDTDSource of this handler 286N/A }
// getDTDContentModelSource(): XMLDTDContentModelSource 286N/A * The start of a content model. Depending on the type of the content 286N/A * model, specific methods may be called between the call to the 286N/A * startContentModel method and the call to the endContentModel method. 286N/A * @param elementName The name of the element. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A }
// startContentModel(String) 286N/A * A content model of ANY. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * A content model of EMPTY. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * A start of either a mixed or children content model. A mixed 286N/A * content model will immediately be followed by a call to the 286N/A * <code>pcdata()</code> method. A children content model will 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * The appearance of "#PCDATA" within a group signifying a 286N/A * mixed content model. This method will be the first called 286N/A * following the content model's <code>startGroup()</code>. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * A referenced element in a mixed or children content model. 286N/A * @param elementName The name of the referenced element. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A // check VC: No duplicate Types, in a single mixed-content declaration 286N/A "DuplicateTypeInMixedContent",
286N/A }
// childrenElement(String) 286N/A * The separator between choices or sequences of a mixed or children 286N/A * @param separator The type of children separator. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * @see #SEPARATOR_CHOICE 286N/A * @see #SEPARATOR_SEQUENCE 286N/A * The occurrence count for a child in a children content model or 286N/A * for the mixed content model group. 286N/A * @param occurrence The occurrence count for the last element 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * @see #OCCURS_ZERO_OR_ONE 286N/A * @see #OCCURS_ZERO_OR_MORE 286N/A * @see #OCCURS_ONE_OR_MORE 286N/A * The end of a group for mixed or children content models. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * The end of a content model. 286N/A * @param augs Additional information that may include infoset 286N/A * @throws XNIException Thrown by handler to signal an error. 286N/A * Normalize the attribute value of a non CDATA default attribute 286N/A * collapsing sequences of space characters (x20) 286N/A * @param value The value to normalize 286N/A * @return Whether the value was changed or not. 286N/A // take the first whitespace as a space and skip the others 286N/A // simply shift non space chars if needed 286N/A // if we finished on a space trim it 286N/A // set the new value length 286N/A }
// isValidNmtoken(String): boolean 286N/A }
// isValidName(String): boolean 286N/A * Checks that all elements referenced in content models have 286N/A * been declared. This method calls out to the error handler 286N/A * to indicate warnings. 286N/A * Does a recursive (if necessary) check on the specified element's 286N/A * content spec to make sure that all children refer to declared 286N/A "UndeclaredElementInContentSpec",
286N/A // It's not a leaf, so we have to recurse its left and maybe right 286N/A // nodes. Save both values before we recurse and trash the node. 286N/A // Recurse on both children. 286N/A}
// class XMLDTDProcessor