You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@apache.org on 2001/02/13 20:05:00 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/parsers AbstractDOMParser.java AbstractSAXParser.java DOMParser.java SAXParser.java XMLDocumentParser.java

lehors      01/02/13 11:05:00

  Modified:    java/src/org/apache/xerces/parsers Tag: xerces_j_2
                        DOMParser.java SAXParser.java
                        XMLDocumentParser.java
  Added:       java/src/org/apache/xerces/parsers Tag: xerces_j_2
                        AbstractDOMParser.java AbstractSAXParser.java
  Log:
  Moved the "pipeline" setup from XMLDocumentScanner to the lowest classes in
  the hierarchy so that it can be changed without having to rewrite the whole
  SAX and DOM parser classes.
  
  This is achieved through the introduction of two new classes
  AbstractSAXParser and AbstractDOMParser which implement the appropriate
  callbacks independently of the actual pipeline being used.
  
  While this allows some code to be reused it is still not 100% satisfactory
  because the pipeline setup code can no longer be shared between different
  parsers. So we end up duplicating some code anyway. For this reason, We
  might want to move to using some kind of "ParserConfiguration" object.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.19.2.11 +341 -445  xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java
  
  Index: DOMParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java,v
  retrieving revision 1.19.2.10
  retrieving revision 1.19.2.11
  diff -u -r1.19.2.10 -r1.19.2.11
  --- DOMParser.java	2000/12/21 07:38:34	1.19.2.10
  +++ DOMParser.java	2001/02/13 19:04:57	1.19.2.11
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -57,545 +57,441 @@
   
   package org.apache.xerces.parsers;
   
  -import org.apache.xerces.dom.DocumentImpl;
  -import org.apache.xerces.dom.EntityReferenceImpl;
  -import org.apache.xerces.dom.TextImpl;
  +import java.io.IOException;
   
  +import org.apache.xerces.impl.Constants;
  +import org.apache.xerces.impl.XMLDocumentScanner;
  +import org.apache.xerces.impl.XMLDTDScanner;
  +import org.apache.xerces.impl.XMLEntityManager;
  +import org.apache.xerces.impl.XMLInputSource;
  +import org.apache.xerces.impl.XMLValidator;
  +import org.apache.xerces.impl.validation.DatatypeValidatorFactory;
   import org.apache.xerces.impl.validation.GrammarPool;
  +import org.apache.xerces.impl.validation.datatypes.DatatypeValidatorFactoryImpl;
   
   import org.apache.xerces.util.SymbolTable;
   
  -import org.apache.xerces.xni.QName;
  -import org.apache.xerces.xni.XMLAttributes;
  -import org.apache.xerces.xni.XMLString;
  -
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.CDATASection;
  -import org.w3c.dom.Comment;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentType;
  -import org.w3c.dom.DOMImplementation;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.EntityReference;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.ProcessingInstruction;
  -import org.w3c.dom.Text;
  -
  +import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
  +import org.xml.sax.SAXNotRecognizedException;
  +import org.xml.sax.SAXNotSupportedException;
   
   /**
  - * A parser configuration that builds a W3C DOM tree structure from
  - * a parse stream. This class implements the XNI callback methods to
  - * create the DOM tree. After a successful parse of an XML document,
  - * the DOM Document object can be queried using the getDocument
  - * method.
  - * 
  + * This is the main Xerces DOM parser class. It uses the abstract DOM parser
  + * with a document scanner, a dtd scanner, and a validator, as well as a
  + * grammar pool.
  + *
    * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
  + * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * 
  - * @version $Id: DOMParser.java,v 1.19.2.10 2000/12/21 07:38:34 andyc Exp $
  - */
  + * @version $Id: DOMParser.java,v 1.19.2.11 2001/02/13 19:04:57 lehors Exp $ */
   public class DOMParser
  -    extends XMLDocumentParser {
  +    extends AbstractDOMParser {
   
       //
  -    // Data
  +    // Constants
       //
   
  -    // dom information
  +    // debugging
   
  -    /** The document. */
  -    protected Document fDocument;
  +    /** Set to true and recompile to print exception stack trace. */
  +    private static final boolean PRINT_EXCEPTION_STACK_TRACE = false;
  +
  +    //
  +    // Data
  +    //
   
  -    /** The default Xerces document implementation, if used. */
  -    protected DocumentImpl fDocumentImpl;
  +    // components (non-configurable)
   
  -    /** Current node. */
  -    protected Node fCurrentNode;
  +    /** Grammar pool. */
  +    protected GrammarPool fGrammarPool;
   
  -    // state
  +    /** Datatype validator factory. */
  +    protected DatatypeValidatorFactory fDatatypeValidatorFactory;
   
  -    /** True if inside document. */
  -    protected boolean fInDocument;
  +    // components (configurable)
   
  -    /** True if inside DTD. */
  -    protected boolean fInDTD;
  +    /** Document scanner. */
  +    protected XMLDocumentScanner fScanner;
   
  -    /** True if inside CDATA section. */
  -    protected boolean fInCDATASection;
  +    /** DTD scanner. */
  +    protected XMLDTDScanner fDTDScanner;
   
  -    // data
  -    
  -    /** Attribute QName. */
  -    private QName fAttrQName = new QName();
  +    /** Validator. */
  +    protected XMLValidator fValidator;
   
       //
       // Constructors
       //
   
  -    /** Default constructor. */
  +    /**
  +     * Constructs a document parser using the default symbol table
  +     * and grammar pool.
  +     */
       public DOMParser() {
           this(new SymbolTable(), new GrammarPool());
       } // <init>()
   
  -    /**
  -     * 
  -     * 
  -     * @param symbolTable 
  -     * @param grammarPool 
  +    /** 
  +     * Constructs a document parser using the specified symbol table
  +     * and a default grammar pool.
        */
  -    protected DOMParser(SymbolTable symbolTable, GrammarPool grammarPool) {
  -        super(symbolTable, grammarPool);
  -    } // <init>(SymbolTable,GrammarPool)
  -
  -    //
  -    // Public methods
  -    //
  +    public DOMParser(SymbolTable symbolTable) {
  +        this(symbolTable, new GrammarPool());
  +    } // <init>(SymbolTable)
  +
  +    /**
  +     * Constructor allowing to specify the symbol table and grammar pool 
  +     * to use. The symbol table and grammar pool are specified together
  +     * because the grammars contained in the grammar pool must use the
  +     * symbols from the specified symbol table.
  +     * 
  +     * @param symbolTable The symbol table.
  +     * @param grammarPool The grammar pool.
  +     */
  +    public DOMParser(SymbolTable symbolTable, GrammarPool grammarPool) {
  +        super(symbolTable);
  +
  +        // set default features
  +        final String NAMESPACES = Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
  +        fFeatures.put(NAMESPACES, Boolean.TRUE);
  +        final String VALIDATION = Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
  +        fFeatures.put(VALIDATION, Boolean.FALSE);
  +        final String EXTERNAL_GENERAL_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE;
  +        fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
  +        final String EXTERNAL_PARAMETER_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
  +        fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
  +
  +        // create and register components
  +        final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  +        fProperties.put(SYMBOL_TABLE, fSymbolTable);
  +
  +        fGrammarPool = grammarPool;
  +        final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
  +        fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +
  +        fScanner = createDocumentScanner();
  +        final String DOCUMENT_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
  +        fProperties.put(DOCUMENT_SCANNER, fScanner);
  +
  +        fDTDScanner = createDTDScanner();
  +        final String DTD_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
  +        fProperties.put(DTD_SCANNER, fDTDScanner);
  +
  +        fValidator = createValidator();
  +        final String VALIDATOR = Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATOR_PROPERTY;
  +        fProperties.put(VALIDATOR, fValidator);
  +        
  +        fDatatypeValidatorFactory = createDatatypeValidatorFactory();
  +        final String DATATYPE_VALIDATOR_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
  +        fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
   
  -    /** Returns the DOM document object. */
  -    public Document getDocument() {
  -        return fDocument;
  -    } // getDocument():Document
  +    } // <init>(SymbolTable,GrammarPool)
   
       //
  -    // XMLDocumentParser methods
  +    // XMLParser methods
       //
   
  -    /**
  -     * Resets the parser state.
  +    /** 
  +     * Reset all components before parsing. 
        *
  -     * @throws SAXException Thrown on initialization error.
  +     * @throws SAXException Thrown if an error occurs during initialization.
        */
  -    public void reset() throws SAXException {
  +    protected void reset() throws SAXException {
           super.reset();
   
  -        // reset dom information
  -        fDocument = null;
  -        fCurrentNode = null;
  -
  -        // reset state information
  -        fInDocument = false;
  -        fInDTD = false;
  -        fInCDATASection = false;
   
  +        // setup document pipeline
  +        fScanner.setDocumentHandler(fValidator);
  +        fValidator.setDocumentHandler(this);
  +
  +        // setup dtd pipeline
  +        fDTDScanner.setDTDHandler(fValidator);
  +        fValidator.setDTDHandler(this);
  +
  +        // setup dtd content model pipeline
  +        /***/
  +        fDTDScanner.setDTDContentModelHandler(fValidator);
  +        fValidator.setDTDContentModelHandler(this);
  +
  +        // reset every component
  +        fScanner.reset(this);
  +        fDTDScanner.reset(this);
  +        fValidator.reset(this);
  +
       } // reset()
   
       //
  -    // XMLDocumentHandler methods
  +    // XMLReader methods
       //
   
       /**
  -     * This method notifies of the start of an entity. The document entity
  -     * has the pseudo-name of "[xml]"; The DTD has the pseudo-name of "[dtd]; 
  -     * parameter entity names start with '%'; and general entity names are
  -     * just the entity name.
  -     * <p>
  -     * <strong>Note:</strong> Since the document is an entity, the handler
  -     * will be notified of the start of the document entity by calling the
  -     * startEntity method with the entity name "[xml]" <em>before</em> calling
  -     * the startDocument method. When exposing entity boundaries through the
  -     * SAX API, the document entity is never reported, however.
  +     * Set the state of a feature.
        * <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
  -     * startEntity method with the entity name "[dtd]" <em>before</em> calling
  -     * the startDTD method.
  +     * The feature name is any fully-qualified URI.  It is
  +     * possible for an XMLReader to recognize a feature name but
  +     * to be unable to set its value; this is especially true
  +     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser},
  +     * which has no way of affecting whether the underlying parser is
  +     * validating, for example.
        * <p>
  -     * <strong>Note:</strong> This method is not called for entity references
  -     * appearing as part of attribute values.
  -     * 
  -     * @param name     The name of the entity.
  -     * @param publicId The public identifier of the entity if the entity
  -     *                 is external, null otherwise.
  -     * @param systemId The system identifier of the entity if the entity
  -     *                 is external, null otherwise.
  -     * @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).
  +     * Some feature values may be immutable or mutable only 
  +     * in specific contexts, such as before, during, or after 
  +     * a parse.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startEntity(String name, String publicId, String systemId,
  -                            String encoding) throws SAXException {
  -
  -        if (fInDocument && !fInDTD) {
  -            EntityReference entityRef = fDocument.createEntityReference(name);
  -            fCurrentNode.appendChild(entityRef);
  -            fCurrentNode = entityRef;
  -        }
  -
  -    } // startEntity(String,String,String,String)
  -
  -    /**
  -     * A comment.
  -     * 
  -     * @param text The text in the comment.
  +     * @param name The feature name, which is a fully-qualified URI.
  +     * @param state The requested state of the feature (true or false).
        *
  -     * @throws SAXException Thrown by application to signal an error.
  +     * @exception org.xml.sax.SAXNotRecognizedException When the
  +     *            XMLReader does not recognize the feature name.
  +     * @exception org.xml.sax.SAXNotSupportedException When the
  +     *            XMLReader recognizes the feature name but 
  +     *            cannot set the requested value.
  +     *
  +     * @see #getFeature
        */
  -    public void comment(XMLString text) throws SAXException {
  +    public void setFeature(String featureId, boolean state)
  +        throws SAXNotRecognizedException, SAXNotSupportedException {
  +
  +        super.setFeature(featureId, state);
   
  -        Comment comment = fDocument.createComment(text.toString());
  -        fCurrentNode.appendChild(comment);
  +        // forward to every component
  +        fScanner.setFeature(featureId, state);
  +        fDTDScanner.setFeature(featureId, state);
  +        fValidator.setFeature(featureId, state);
   
  -    } // comment(XMLString)
  +    } // setFeature(String,boolean)
   
       /**
  -     * A processing instruction. Processing instructions consist of a
  -     * target name and, optionally, text data. The data is only meaningful
  -     * to the application.
  +     * Set the value of a property.
        * <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.
  +     * The property name is any fully-qualified URI.  It is
  +     * possible for an XMLReader to recognize a property name but
  +     * to be unable to set its value; this is especially true
  +     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
  +     * Parser}.
  +     * <p>
  +     * Some property values may be immutable or mutable only 
  +     * in specific contexts, such as before, during, or after 
  +     * a parse.
  +     * <p>
  +     * This method is also the standard mechanism for setting
  +     * extended handlers.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void processingInstruction(String target, XMLString data)
  -        throws SAXException {
  -
  -        ProcessingInstruction pi = fDocument.createProcessingInstruction(target, data.toString());
  -        fCurrentNode.appendChild(pi);
  -
  -    } // processingInstruction(String,XMLString)
  -
  -    /**
  -     * The start of the document.
  +     * @param name The property name, which is a fully-qualified URI.
  +     * @param state The requested value for the property.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startDocument() throws SAXException {
  -
  -        fInDocument = true;
  -        fDocument = new DocumentImpl();
  -        fDocumentImpl = (DocumentImpl)fDocument;
  -        fCurrentNode = fDocument;
  -
  -    } // startDocument()
  -
  -    /**
  -     * Notifies of the presence of the DOCTYPE line in the document.
  -     * 
  -     * @param rootElement The name of the root element.
  -     * @param publicId    The public identifier if an external DTD or null
  -     *                    if the external DTD is specified using SYSTEM.
  -     * @param systemId    The system identifier if an external DTD, null
  -     *                    otherwise.
  +     * @exception org.xml.sax.SAXNotRecognizedException When the
  +     *            XMLReader does not recognize the property name.
  +     * @exception org.xml.sax.SAXNotSupportedException When the
  +     *            XMLReader recognizes the property name but 
  +     *            cannot set the requested value.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  +     * @see #getProperty
        */
  -    public void doctypeDecl(String rootElement, String publicId, String systemId)
  -        throws SAXException {
  -        
  -        DocumentImpl docimpl = (DocumentImpl)fDocument;
  -        DocumentType doctype = docimpl.createDocumentType(rootElement, publicId, systemId);
  -        fCurrentNode.appendChild(doctype);
  -
  -    } // doctypeDecl(String,String,String)
  +    public void setProperty(String propertyId, Object value)
  +        throws SAXNotRecognizedException, SAXNotSupportedException {
   
  -    /**
  -     * The start of an element. If the document specifies the start element
  -     * by using an empty tag, then the startElement method will immediately
  -     * be followed by the endElement method, with no intervening methods.
  -     * 
  -     * @param element    The name of the element.
  -     * @param attributes The element attributes.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startElement(QName element, XMLAttributes attributes)
  -        throws SAXException {
  +        super.setProperty(propertyId, value);
   
  -        Element elementNode = element.prefix != null
  -                            ? fDocument.createElementNS(element.uri, element.rawname)
  -                            : fDocument.createElement(element.rawname);
  -        int attrCount = attributes.getLength();
  -        for (int i = 0; i < attrCount; i++) {
  -            attributes.getName(i, fAttrQName);
  -            Attr attr = fAttrQName.prefix != null
  -                      ? fDocument.createAttributeNS(fAttrQName.uri, fAttrQName.rawname)
  -                      : fDocument.createAttribute(fAttrQName.rawname);
  -            attr.setNodeValue(attributes.getValue(i));
  -            // REVISIT: Handle entities in attribute value.
  -            elementNode.setAttributeNode(attr);
  -
  -            // build entity references
  -            int entityCount = attributes.getEntityCount(i);
  -            if (entityCount > 0) {
  -                Text text = (Text)attr.getFirstChild();
  -                buildAttrEntityRefs(text, attributes, i, entityCount, 0, 0);
  -            }
  -        }
  -        fCurrentNode.appendChild(elementNode);
  -        fCurrentNode = elementNode;
  +        // forward to every component
  +        fScanner.setProperty(propertyId, value);
  +        fDTDScanner.setProperty(propertyId, value);
  +        fValidator.setProperty(propertyId, value);
   
  -    } // startElement(QName,XMLAttributes)
  +    } // setProperty(String,Object)
   
       /**
  -     * Character content.
  -     * 
  -     * @param text The content.
  +     * Parses the specified input source.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void characters(XMLString text) throws SAXException {
  -
  -        if (fInCDATASection) {
  -            CDATASection cdataSection = (CDATASection)fCurrentNode;
  -            cdataSection.appendData(text.toString());
  -        }
  -        else {
  -            Node child = fCurrentNode.getLastChild();
  -            if (child != null && child.getNodeType() == Node.TEXT_NODE) {
  -                Text textNode = (Text)child;
  -                textNode.appendData(text.toString());
  -            }
  -            else {
  -                Text textNode = fDocument.createTextNode(text.toString());
  -                fCurrentNode.appendChild(textNode);
  -            }
  -        }
  -
  -    } // characters(XMLString)
  -
  -    /**
  -     * Ignorable whitespace. For this method to be called, the document
  -     * source must have some way of determining that the text containing
  -     * only whitespace characters should be considered ignorable. For
  -     * example, the validator can determine if a length of whitespace
  -     * characters in the document are ignorable based on the element
  -     * content model.
  -     * 
  -     * @param text The ignorable whitespace.
  +     * @param source The input source.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  +     * @exception org.xml.sax.SAXException Throws exception on SAX error.
  +     * @exception java.io.IOException Throws exception on i/o error.
        */
  -    public void ignorableWhitespace(XMLString text) throws SAXException {
  +    public void parse(InputSource source)
  +        throws SAXException, IOException {
   
  -        Node child = fCurrentNode.getLastChild();
  -        if (child != null && child.getNodeType() == Node.TEXT_NODE) {
  -            Text textNode = (Text)child;
  -            textNode.appendData(text.toString());
  +        if (fParseInProgress) {
  +            // REVISIT - need to add new error message
  +            throw new SAXException("FWK005 parse may not be called while parsing.");
           }
  -        else {
  -            Text textNode = fDocument.createTextNode(text.toString());
  -            if (fDocumentImpl != null) {
  -                TextImpl textNodeImpl = (TextImpl)textNode;
  -                textNodeImpl.setIgnorableWhitespace(true);
  -            }
  -            fCurrentNode.appendChild(textNode);
  -        }
  -
  -    } // ignorableWhitespace(XMLString)
  -
  -    /**
  -     * The end of an element.
  -     * 
  -     * @param element The name of the element.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endElement(QName element) throws SAXException {
  -
  -        fCurrentNode = fCurrentNode.getParentNode();
  -
  -    } // endElement(QName)
  -
  -    /**
  -     * The end of a namespace prefix mapping. This method will only be
  -     * called when namespace processing is enabled.
  -     * 
  -     * @param prefix The namespace prefix.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endPrefixMapping(String prefix) throws SAXException {
  -    } // endPrefixMapping(String)
   
  -    /** 
  -     * The start of a CDATA section. 
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startCDATA() throws SAXException {
  +        try {
  +            reset();
  +            fEntityManager.setEntityHandler(fScanner);
  +            fEntityManager.startDocumentEntity(new XMLInputSource(source));
  +            fScanner.scanDocument(true);
  +            fParseInProgress = false;
  +        } 
  +        catch (SAXException ex) {
  +            fParseInProgress = false;
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw ex;
  +        } 
  +        catch (IOException ex) {
  +            fParseInProgress = false;
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw ex;
  +        } 
  +        catch (Exception ex) {
  +            fParseInProgress = false;
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw new org.xml.sax.SAXException(ex);
  +        }
   
  -        fInCDATASection = true;
  -        CDATASection cdataSection = fDocument.createCDATASection("");
  -        fCurrentNode.appendChild(cdataSection);
  -        fCurrentNode = cdataSection;
  +    } // parse(InputSource)
   
  -    } // startCDATA()
  +    //
  +    // XMLParser methods
  +    //
   
       /**
  -     * The end of a CDATA section. 
  +     * Check a feature. If feature is know and supported, this method simply
  +     * returns. Otherwise, the appropriate exception is thrown.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endCDATA() throws SAXException {
  -
  -        fInCDATASection = false;
  -        fCurrentNode = fCurrentNode.getParentNode();
  -
  -    } // endCDATA()
  -
  -    /**
  -     * The end of the document.
  +     * @param featureId The unique identifier (URI) of the feature.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  +     * @exception org.xml.sax.SAXNotRecognizedException If the
  +     *            requested feature is not known.
  +     * @exception org.xml.sax.SAXNotSupportedException If the
  +     *            requested feature is known, but the requested
  +     *            state is not supported.
  +     * @exception org.xml.sax.SAXException If there is any other
  +     *            problem fulfilling the request.
        */
  -    public void endDocument() throws SAXException {
  +    protected void checkFeature(String featureId)
  +        throws SAXNotRecognizedException, SAXNotSupportedException {
   
  -        fInDocument = false;
  -        fCurrentNode = null;
  +        //
  +        // Xerces Features
  +        //
   
  -    } // endDocument()
  -
  -    /**
  -     * This method notifies the end of an entity. The document entity has
  -     * the pseudo-name of "[xml]"; the DTD has the pseudo-name of "[dtd]; 
  -     * parameter entity names start with '%'; and general entity names are
  -     * just the entity name.
  -     * <p>
  -     * <strong>Note:</strong> Since the document is an entity, the handler
  -     * will be notified of the end of the document entity by calling the
  -     * endEntity method with the entity name "[xml]" <em>after</em> calling
  -     * the endDocument method. When exposing entity boundaries through the
  -     * SAX API, the document entity is never reported, however.
  -     * <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.
  -     * <p>
  -     * <strong>Note:</strong> This method is not called for entity references
  -     * appearing as part of attribute values.
  -     * 
  -     * @param name The name of the entity.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endEntity(String name) throws SAXException {
  +        if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
  +            String feature = featureId.substring(Constants.XERCES_FEATURE_PREFIX.length());
  +            //
  +            // http://apache.org/xml/features/validation/schema
  +            //   Lets the user turn Schema validation support on/off.
  +            //
  +            if (feature.equals(Constants.SCHEMA_VALIDATION_FEATURE)) {
  +                return;
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/dynamic
  +            //   Allows the parser to validate a document only when it
  +            //   contains a grammar. Validation is turned on/off based
  +            //   on each document instance, automatically.
  +            //
  +            if (feature.equals(Constants.DYNAMIC_VALIDATION_FEATURE)) {
  +                return;
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/default-attribute-values
  +            //
  +            if (feature.equals(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
  +                // REVISIT
  +                throw new SAXNotSupportedException(featureId);
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/default-attribute-values
  +            //
  +            if (feature.equals(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
  +                // REVISIT
  +                throw new SAXNotSupportedException(featureId);
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
  +            //
  +            if (feature.equals(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
  +                return;
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
  +            //
  +            if (feature.equals(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
  +                return;
  +            }
   
  -        if (fInDocument && !fInDTD) {
  -            fCurrentNode = fCurrentNode.getParentNode();
  +            //
  +            // http://apache.org/xml/features/validation/default-attribute-values
  +            //
  +            if (feature.equals(Constants.VALIDATE_DATATYPES_FEATURE)) {
  +                throw new SAXNotSupportedException(featureId);
  +            }
           }
   
  -    } // endEntity(String)
  +        //
  +        // Not recognized
  +        //
  +
  +        super.checkFeature(featureId);
  +
  +    } // checkFeature(String)
  +
  +    /**
  +     * Check a property. If the property is know and supported, this method
  +     * simply returns. Otherwise, the appropriate exception is thrown.
  +     *
  +     * @param propertyId The unique identifier (URI) of the property
  +     *                   being set.
  +     * @exception org.xml.sax.SAXNotRecognizedException If the
  +     *            requested property is not known.
  +     * @exception org.xml.sax.SAXNotSupportedException If the
  +     *            requested property is known, but the requested
  +     *            value is not supported.
  +     * @exception org.xml.sax.SAXException If there is any other
  +     *            problem fulfilling the request.
  +     */
  +    protected void checkProperty(String propertyId)
  +        throws SAXNotRecognizedException, SAXNotSupportedException {
  +
  +        //
  +        // Xerces Properties
  +        //
  +
  +        if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
  +            String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
  +            if (property.equals(Constants.DTD_SCANNER_PROPERTY)) {
  +                return;
  +            }
  +        }
   
  -    //
  -    // XMLDTDHandler methods
  -    //
  +        //
  +        // Not recognized
  +        //
   
  -    /**
  -     * The start of the DTD.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startDTD() throws SAXException {
  -        fInDTD = true;
  -    } // startDTD()
  +        super.checkProperty(propertyId);
   
  -    /**
  -     * The end of the DTD.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endDTD() throws SAXException {
  -        fInDTD = false;
  -    } // endDTD()
  +    } // checkProperty(String)
   
       //
       // Protected methods
       //
   
  -    /** 
  -     * Builds entity references in attribute values. This method is
  -     * recursive because entity references can contain entity
  -     * references.
  -     *
  -     * @param text        The text node that needs to be split.
  -     * @param attributes  The attribute information.
  -     * @param attrIndex   The attribute index.
  -     * @param entityCount The number of entities. This is passed as
  -     *                    a convenience so that this method doesn't
  -     *                    have to call XMLAttributes#getEntityCount.
  -     *                    The caller already has the entity count so
  -     *                    it's kind of a waste to make each invocation
  -     *                    of this method query it again.
  -     * @param entityIndex The entity index that this method invocation
  -     *                    should start building from.
  -     * @param textOffset  The offset at which the start of this text
  -     *                    should be considered. We need this to adjust
  -     *                    the offset since the characters in the current
  -     *                    text string are indexed from zero.
  -     *
  -     * @return Returns the number of entities built by this method.
  -     */
  -    protected int buildAttrEntityRefs(Text text, XMLAttributes attributes, 
  -                                      int attrIndex, 
  -                                      int entityCount, int entityIndex, 
  -                                      int textOffset) {
  -
  -        // iterate over entities
  -        String textString = text.getNodeValue();
  -        int textLength = textString.length();
  -        int i = entityIndex;
  -        while (i < entityCount) {
  -
  -            // get entity information
  -            String entityName = attributes.getEntityName(attrIndex, i);
  -            int entityOffset = attributes.getEntityOffset(attrIndex, i);
  -            int entityLength = attributes.getEntityLength(attrIndex, i);
  -
  -            // is this entity not in this text?
  -            if (entityOffset > textOffset + textLength) {
  -                break;
  -            }
  -         
  -            // split text into 3 parts; first part remains the
  -            // text node that was passed into this method
  -            Text text1 = text.splitText(entityOffset - textOffset);
  -            Text text2 = text1.splitText(entityLength);
  -
  -            // create entity reference
  -            EntityReference entityRef = fDocument.createEntityReference(entityName);
  -            ((EntityReferenceImpl)entityRef).setReadOnly(false, false);
  -
  -            // insert entity ref into tree and append middle text
  -            Node parent = text.getParentNode();
  -            parent.replaceChild(entityRef, text1);
  -            entityRef.appendChild(text1);
  -
  -            // see if there are any nested entity refs
  -            if (i < entityCount - 1) {
  -                int nextEntityOffset = attributes.getEntityOffset(attrIndex, i + 1);
  -                if (nextEntityOffset < entityOffset + entityLength) {
  -                    // NOTE: Notice that we're incrementing the entity
  -                    //       index variable. Since the following call will
  -                    //       "consume" some of the entities.
  -                    i += buildAttrEntityRefs(text1, attributes, attrIndex, entityCount, i + 1, entityOffset);
  -                }
  -            }
  -            ((EntityReferenceImpl)entityRef).setReadOnly(true, false);
  -
  -            // adjust text node
  -            textOffset += text.getLength() + entityLength;
  -            text = text2;
  -            
  -            // increment and keep going
  -            i++;
  -        }
  -        
  -        // return number of entities we handled
  -        return i - entityIndex;
  +    // factory methods
   
  -    } // buildAttrEntityRefs(Text,XMLAttributes,int,int,int,int):int
  +    /** Create a document scanner. */
  +    protected XMLDocumentScanner createDocumentScanner() {
  +        return new XMLDocumentScanner();
  +    } // createDocumentScanner():XMLDocumentScanner
  +
  +    /** Create a DTD scanner. */
  +    protected XMLDTDScanner createDTDScanner() {
  +        return new XMLDTDScanner();
  +    } // createDTDScanner():XMLDTDScanner
  +
  +    /** Create a validator. */
  +    protected XMLValidator createValidator() {
  +        return new XMLValidator();
  +    } // createValidator():XMLValidator
  +
  +    /** Create a datatype validator factory. */
  +    protected DatatypeValidatorFactory createDatatypeValidatorFactory() {
  +        return new DatatypeValidatorFactoryImpl();
  +    } // createDatatypeValidatorFactory():DatatypeValidatorFactory
   
   } // class DOMParser
  
  
  
  1.12.2.18 +287 -968  xml-xerces/java/src/org/apache/xerces/parsers/SAXParser.java
  
  Index: SAXParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/SAXParser.java,v
  retrieving revision 1.12.2.17
  retrieving revision 1.12.2.18
  diff -u -r1.12.2.17 -r1.12.2.18
  --- SAXParser.java	2001/01/30 04:17:02	1.12.2.17
  +++ SAXParser.java	2001/02/13 19:04:58	1.12.2.18
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -60,1119 +60,438 @@
   import java.io.IOException;
   
   import org.apache.xerces.impl.Constants;
  +import org.apache.xerces.impl.XMLDocumentScanner;
  +import org.apache.xerces.impl.XMLDTDScanner;
  +import org.apache.xerces.impl.XMLEntityManager;
  +import org.apache.xerces.impl.XMLInputSource;
  +import org.apache.xerces.impl.XMLValidator;
  +import org.apache.xerces.impl.validation.DatatypeValidatorFactory;
   import org.apache.xerces.impl.validation.GrammarPool;
  +import org.apache.xerces.impl.validation.datatypes.DatatypeValidatorFactoryImpl;
  +
   import org.apache.xerces.util.SymbolTable;
  -import org.apache.xerces.xni.XMLString;
  -import org.apache.xerces.xni.XMLAttributes;
  -import org.apache.xerces.xni.XMLDTDHandler;
  -import org.apache.xerces.xni.QName;
  -
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.DTDHandler;
  -import org.xml.sax.DocumentHandler;
  -import org.xml.sax.EntityResolver;
  -import org.xml.sax.ErrorHandler;
  +
   import org.xml.sax.InputSource;
  -import org.xml.sax.Parser;
   import org.xml.sax.SAXException;
   import org.xml.sax.SAXNotRecognizedException;
   import org.xml.sax.SAXNotSupportedException;
  -import org.xml.sax.XMLReader;
  -import org.xml.sax.ext.DeclHandler;
  -import org.xml.sax.ext.LexicalHandler;
   
   /**
  - * The Xerces SAX parser implementation. This parser class implements
  - * both the SAX1 and SAX2 parser functionality.
  + * This is the main Xerces SAX parser class. It uses the abstract SAX parser
  + * with a document scanner, a dtd scanner, and a validator, as well as a
  + * grammar pool.
    *
    * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
  + * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: SAXParser.java,v 1.12.2.17 2001/01/30 04:17:02 andyc Exp $
  - */
  + * @version $Id: SAXParser.java,v 1.12.2.18 2001/02/13 19:04:58 lehors Exp $ */
   public class SAXParser
  -    extends XMLDocumentParser
  -    implements Parser, XMLReader // SAX1, SAX2
  -    {
  +    extends AbstractSAXParser {
  +
  +    //
  +    // Constants
  +    //
   
  +    // debugging
  +
  +    /** Set to true and recompile to print exception stack trace. */
  +    private static final boolean PRINT_EXCEPTION_STACK_TRACE = false;
  +
       //
       // Data
       //
   
  -    // parser handlers
  +    // components (non-configurable)
   
  -    /** Content handler. */
  -    protected ContentHandler fContentHandler;
  +    /** Grammar pool. */
  +    protected GrammarPool fGrammarPool;
   
  -    /** Document handler. */
  -    protected DocumentHandler fDocumentHandler;
  +    /** Datatype validator factory. */
  +    protected DatatypeValidatorFactory fDatatypeValidatorFactory;
   
  -    /** DTD handler. */
  -    protected org.xml.sax.DTDHandler fDTDHandler;
  +    // components (configurable)
   
  -    /** Decl handler. */
  -    protected DeclHandler fDeclHandler;
  +    /** Document scanner. */
  +    protected XMLDocumentScanner fScanner;
   
  -    /** Lexical handler. */
  -    protected LexicalHandler fLexicalHandler;
  +    /** DTD scanner. */
  +    protected XMLDTDScanner fDTDScanner;
   
  -    // symbols
  -       
  -    /** Symbol: empty string (""). */
  -    private String fEmptySymbol;
  +    /** Validator. */
  +    protected XMLValidator fValidator;
   
       //
       // Constructors
       //
   
  -    /** Default constructor. */
  +    /**
  +     * Constructs a document parser using the default symbol table
  +     * and grammar pool.
  +     */
       public SAXParser() {
  +        this(new SymbolTable(), new GrammarPool());
       } // <init>()
   
  +    /** 
  +     * Constructs a document parser using the specified symbol table
  +     * and a default grammar pool.
  +     */
  +    public SAXParser(SymbolTable symbolTable) {
  +        this(symbolTable, new GrammarPool());
  +    } // <init>(SymbolTable)
  +
       /**
  -     * Constructs a SAX parser specifying the symbol table and grammar
  -     * pool. This enables a pool of parsers to share the same validation
  -     * data structures.
  +     * Constructor allowing to specify the symbol table and grammar pool 
  +     * to use. The symbol table and grammar pool are specified together
  +     * because the grammars contained in the grammar pool must use the
  +     * symbols from the specified symbol table.
        * 
        * @param symbolTable The symbol table.
        * @param grammarPool The grammar pool.
        */
       public SAXParser(SymbolTable symbolTable, GrammarPool grammarPool) {
  -        super(symbolTable, grammarPool);
  +        super(symbolTable);
  +
  +        // set default features
  +        final String NAMESPACES = Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
  +        fFeatures.put(NAMESPACES, Boolean.TRUE);
  +        final String VALIDATION = Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
  +        fFeatures.put(VALIDATION, Boolean.FALSE);
  +        final String EXTERNAL_GENERAL_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE;
  +        fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
  +        final String EXTERNAL_PARAMETER_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
  +        fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
  +
  +        // create and register components
  +        final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  +        fProperties.put(SYMBOL_TABLE, fSymbolTable);
  +
  +        fGrammarPool = grammarPool;
  +        final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
  +        fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +
  +        fScanner = createDocumentScanner();
  +        final String DOCUMENT_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
  +        fProperties.put(DOCUMENT_SCANNER, fScanner);
  +
  +        fDTDScanner = createDTDScanner();
  +        final String DTD_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
  +        fProperties.put(DTD_SCANNER, fDTDScanner);
  +
  +        fValidator = createValidator();
  +        final String VALIDATOR = Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATOR_PROPERTY;
  +        fProperties.put(VALIDATOR, fValidator);
  +        
  +        fDatatypeValidatorFactory = createDatatypeValidatorFactory();
  +        final String DATATYPE_VALIDATOR_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
  +        fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
  +
       } // <init>(SymbolTable,GrammarPool)
   
       //
  -    // XMLDocumentHandler methods
  +    // XMLParser methods
       //
  -
  -    /**
  -     * The start of the document.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startDocument() throws SAXException {
  -
  -        // SAX1
  -        if (fDocumentHandler != null) {
  -            fDocumentHandler.startDocument();
  -        }
  -
  -        // SAX2
  -        if (fContentHandler != null) {
  -            fContentHandler.startDocument();
  -        }
  -
  -    } // startDocument()
   
  -    /**
  -     * Notifies of the presence of the DOCTYPE line in the document.
  -     * 
  -     * @param rootElement The name of the root element.
  -     * @param publicId    The public identifier if an external DTD or null
  -     *                    if the external DTD is specified using SYSTEM.
  -     * @param systemId    The system identifier if an external DTD, null
  -     *                    otherwise.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void doctypeDecl(String rootElement,
  -                            String publicId, String systemId)
  -        throws SAXException {
  -
  -        // SAX2 extension
  -        if (fLexicalHandler != null) {
  -            fLexicalHandler.startDTD(rootElement, publicId, systemId);
  -        }
  -
  -    } // doctypeDecl(String,String,String)
  -
  -    /**
  -     * The start of a namespace prefix mapping. This method will only be
  -     * called when namespace processing is enabled.
  -     * 
  -     * @param prefix The namespace prefix.
  -     * @param uri    The URI bound to the prefix.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -        throws SAXException {
  -
  -        // SAX2
  -        if (fContentHandler != null) {
  -            fContentHandler.startPrefixMapping(prefix, uri);
  -        }
  -
  -    } // startPrefixMapping(String prefix, String uri)
  -
  -    /**
  -     * The start of an element. If the document specifies the start element
  -     * by using an empty tag, then the startElement method will immediately
  -     * be followed by the endElement method, with no intervening methods.
  -     * 
  -     * @param element    The name of the element.
  -     * @param attributes The element attributes.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startElement(QName element, XMLAttributes attributes) 
  -        throws SAXException {
  -
  -        // SAX1
  -        if (fDocumentHandler != null) {
  -            fDocumentHandler.startElement(element.rawname, attributes);
  -        }
  -
  -        // SAX2
  -        if (fContentHandler != null) {
  -            String uri = element.uri != null ? element.uri : fEmptySymbol;
  -            fContentHandler.startElement(uri, element.localpart,
  -                                         element.rawname, attributes);
  -        }
  -
  -    } // startElement(QName,XMLAttributes)
  -
  -    /**
  -     * Character content.
  -     * 
  -     * @param text The content.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void characters(XMLString text) throws SAXException {
  -
  -        // SAX1
  -        if (fDocumentHandler != null) {
  -            fDocumentHandler.characters(text.ch, text.offset, text.length);
  -        }
  -
  -        // SAX2
  -        if (fContentHandler != null) {
  -            fContentHandler.characters(text.ch, text.offset, text.length);
  -        }
  -
  -    } // characters(XMLString)
  -
  -    /**
  -     * Ignorable whitespace. For this method to be called, the document
  -     * source must have some way of determining that the text containing
  -     * only whitespace characters should be considered ignorable. For
  -     * example, the validator can determine if a length of whitespace
  -     * characters in the document are ignorable based on the element
  -     * content model.
  -     * 
  -     * @param text The ignorable whitespace.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void ignorableWhitespace(XMLString text) 
  -        throws SAXException {
  -
  -        // SAX1
  -        if (fDocumentHandler != null) {
  -            fDocumentHandler.ignorableWhitespace(text.ch, text.offset, text.length);
  -        }
  -
  -        // SAX2
  -        if (fContentHandler != null) {
  -            fContentHandler.ignorableWhitespace(text.ch, text.offset, text.length);
  -        }
  -
  -    } // ignorableWhitespace(XMLString)
  -
  -    /**
  -     * The end of an element.
  -     * 
  -     * @param element The name of the element.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endElement(QName element) throws SAXException {
  -
  -        // SAX1
  -        if (fDocumentHandler != null) {
  -            fDocumentHandler.endElement(element.rawname);
  -        }
  -
  -        // SAX2
  -        if (fContentHandler != null) {
  -            String uri = element.uri != null ? element.uri : fEmptySymbol;
  -            fContentHandler.endElement(uri, element.localpart,
  -                                       element.rawname);
  -        }
  -
  -    } // endElement(QName)
  -
  -    /**
  -     * The end of a namespace prefix mapping. This method will only be
  -     * called when namespace processing is enabled.
  -     * 
  -     * @param prefix The namespace prefix.
  +    /** 
  +     * Reset all components before parsing. 
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  +     * @throws SAXException Thrown if an error occurs during initialization.
        */
  -    public void endPrefixMapping(String prefix) throws SAXException {
  -
  -        // SAX2
  -        if (fContentHandler != null) {
  -            fContentHandler.endPrefixMapping(prefix);
  -        }
  -
  -    } // endPrefixMapping(String)
  +    protected void reset() throws SAXException {
  +        super.reset();
   
  -    /**
  -     * The end of the document.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endDocument() throws SAXException {
   
  -        // SAX1
  -        if (fDocumentHandler != null) {
  -            fDocumentHandler.endDocument();
  -        }
  +        // setup document pipeline
  +        fScanner.setDocumentHandler(fValidator);
  +        fValidator.setDocumentHandler(this);
  +
  +        // setup dtd pipeline
  +        fDTDScanner.setDTDHandler(fValidator);
  +        fValidator.setDTDHandler(this);
  +
  +        // setup dtd content model pipeline
  +        /***/
  +        fDTDScanner.setDTDContentModelHandler(fValidator);
  +        fValidator.setDTDContentModelHandler(this);
  +
  +        // reset every component
  +        fScanner.reset(this);
  +        fDTDScanner.reset(this);
  +        fValidator.reset(this);
   
  -        // SAX2
  -        if (fContentHandler != null) {
  -            fContentHandler.endDocument();
  -        }
  -
  -    } // endDocument()
  +    } // reset()
   
       //
  -    // XMLDocumentHandler and XMLDTDHandler methods
  +    // XMLReader methods
       //
   
  -    /**
  -     * This method notifies of the start of an entity. The document entity
  -     * has the pseudo-name of "[xml]"; The DTD has the pseudo-name of "[dtd]; 
  -     * parameter entity names start with '%'; and general entity names are
  -     * just the entity name.
  -     * <p>
  -     * <strong>Note:</strong> Since the document is an entity, the handler
  -     * will be notified of the start of the document entity by calling the
  -     * startEntity method with the entity name "[xml]" <em>before</em> calling
  -     * the startDocument method. When exposing entity boundaries through the
  -     * SAX API, the document entity is never reported, however.
  -     * <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
  -     * startEntity method with the entity name "[dtd]" <em>before</em> calling
  -     * the startDTD method.
  -     * <p>
  -     * <strong>Note:</strong> This method is not called for entity references
  -     * appearing as part of attribute values.
  -     * 
  -     * @param name     The name of the entity.
  -     * @param publicId The public identifier of the entity if the entity
  -     *                 is external, null otherwise.
  -     * @param systemId The system identifier of the entity if the entity
  -     *                 is external, null otherwise.
  -     * @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).
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startEntity(String name, String publicId, String systemId,
  -                            String encoding) throws SAXException {
  -        if (fLexicalHandler != null && !name.equals("[xml]")) {
  -            fLexicalHandler.startEntity(name);
  -        }
  -    } // startEntity(String,String,String,String)
  -
  -    /**
  -     * This method notifies the end of an entity. The document entity has
  -     * the pseudo-name of "[xml]"; the DTD has the pseudo-name of "[dtd]; 
  -     * parameter entity names start with '%'; and general entity names are
  -     * just the entity name.
  -     * <p>
  -     * <strong>Note:</strong> Since the document is an entity, the handler
  -     * will be notified of the end of the document entity by calling the
  -     * endEntity method with the entity name "[xml]" <em>after</em> calling
  -     * the endDocument method. When exposing entity boundaries through the
  -     * SAX API, the document entity is never reported, however.
  -     * <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.
  -     * <p>
  -     * <strong>Note:</strong> This method is not called for entity references
  -     * appearing as part of attribute values.
  -     * 
  -     * @param name The name of the entity.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endEntity(String name) throws SAXException {
  -        if (fLexicalHandler != null && !name.equals("[xml]")) {
  -            fLexicalHandler.endEntity(name);
  -        }
  -    } // endEntity(String)
  -
  -    /**
  -     * A comment.
  -     * 
  -     * @param text The text in the comment.
  -     *
  -     * @throws SAXException Thrown by application to signal an error.
  -     */
  -    public void comment(XMLString text) throws SAXException {
  -
  -        // SAX2 extension
  -        if (fLexicalHandler != null) {
  -            fLexicalHandler.comment(text.ch, 0, text.length);
  -        }
  -
  -    } // comment(XMLString)
  -
       /**
  -     * A processing instruction. Processing instructions consist of a
  -     * target name and, optionally, text data. The data is only meaningful
  -     * to the application.
  +     * Set the state of a feature.
        * <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.
  +     * The feature name is any fully-qualified URI.  It is
  +     * possible for an XMLReader to recognize a feature name but
  +     * to be unable to set its value; this is especially true
  +     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser},
  +     * which has no way of affecting whether the underlying parser is
  +     * validating, for example.
  +     * <p>
  +     * Some feature values may be immutable or mutable only 
  +     * in specific contexts, such as before, during, or after 
  +     * a parse.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void processingInstruction(String target, XMLString data)
  -        throws SAXException {
  -
  -        //
  -        // REVISIT - I keep running into SAX apps that expect
  -        //   null data to be an empty string, which is contrary
  -        //   to the comment for this method in the SAX API.
  -        //
  -
  -        // SAX1
  -        if (fDocumentHandler != null) {
  -            fDocumentHandler.processingInstruction(target,
  -                                                   data.toString());
  -        }
  -
  -        // SAX2
  -        if (fContentHandler != null) {
  -            fContentHandler.processingInstruction(target, data.toString());
  -        }
  -
  -    } // processingInstruction(String,XMLString)
  -
  -    //
  -    // XMLDTDHandler methods
  -    //
  -
  -    /**
  -     * An element declaration.
  -     * 
  -     * @param name         The name of the element.
  -     * @param contentModel The element content model.
  +     * @param name The feature name, which is a fully-qualified URI.
  +     * @param state The requested state of the feature (true or false).
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void elementDecl(String name, String contentModel) 
  -        throws SAXException {
  -
  -        // SAX2 extension
  -        if (fDeclHandler != null) {
  -            fDeclHandler.elementDecl(name, contentModel);
  -        }
  -
  -    } // 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" or
  -     *                      "NOTATION", 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.
  +     * @exception org.xml.sax.SAXNotRecognizedException When the
  +     *            XMLReader does not recognize the feature name.
  +     * @exception org.xml.sax.SAXNotSupportedException When the
  +     *            XMLReader recognizes the feature name but 
  +     *            cannot set the requested value.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  +     * @see #getFeature
        */
  -    public void attributeDecl(String elementName, String attributeName, 
  -                              String type, String[] enumeration, 
  -                              String defaultType, XMLString defaultValue)
  -        throws SAXException {
  -
  -        // SAX2 extension
  -        if (fDeclHandler != null) {
  -            if (type.equals("NOTATION")) {
  -                StringBuffer str = new StringBuffer();
  -                str.append(type);
  -                str.append(" (");
  -                for (int i = 0; i < enumeration.length; i++) {
  -                    str.append(enumeration[i]);
  -                    if (i < enumeration.length - 1) {
  -                        str.append('|');
  -                    }
  -                }
  -                str.append(')');
  -                type = str.toString();
  -            }
  -            String value = defaultValue.toString();
  -            fDeclHandler.attributeDecl(elementName, attributeName,
  -                                       type, defaultType, value);
  -        }
  -
  -    } // attributeDecl(String,String,String,String[],String,XMLString)
  +    public void setFeature(String featureId, boolean state)
  +        throws SAXNotRecognizedException, SAXNotSupportedException {
   
  -    /**
  -     * 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.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void internalEntityDecl(String name, XMLString text)
  -        throws SAXException {
  +        super.setFeature(featureId, state);
   
  -        // SAX2 extensions
  -        if (fDeclHandler != null) {
  -            fDeclHandler.internalEntityDecl(name, text.toString());
  -        }
  +        // forward to every component
  +        fScanner.setFeature(featureId, state);
  +        fDTDScanner.setFeature(featureId, state);
  +        fValidator.setFeature(featureId, state);
   
  -    } // internalEntityDecl(String,XMLString)
  +    } // setFeature(String,boolean)
   
       /**
  -     * 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 publicId The public identifier of the entity or null if the
  -     *                 the entity was specified with SYSTEM.
  -     * @param systemId The system identifier of the entity.
  +     * Set the value of a property.
  +     * <p>
  +     * The property name is any fully-qualified URI.  It is
  +     * possible for an XMLReader to recognize a property name but
  +     * to be unable to set its value; this is especially true
  +     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
  +     * Parser}.
  +     * <p>
  +     * Some property values may be immutable or mutable only 
  +     * in specific contexts, such as before, during, or after 
  +     * a parse.
  +     * <p>
  +     * This method is also the standard mechanism for setting
  +     * extended handlers.
  +     *
  +     * @param name The property name, which is a fully-qualified URI.
  +     * @param state The requested value for the property.
  +     *
  +     * @exception org.xml.sax.SAXNotRecognizedException When the
  +     *            XMLReader does not recognize the property name.
  +     * @exception org.xml.sax.SAXNotSupportedException When the
  +     *            XMLReader recognizes the property name but 
  +     *            cannot set the requested value.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  +     * @see #getProperty
        */
  -    public void externalEntityDecl(String name, String publicId,
  -                                   String systemId) throws SAXException {
  -
  -        // SAX2 extension
  -        if (fDeclHandler != null) {
  -            fDeclHandler.externalEntityDecl(name, publicId, systemId);
  -        }
  +    public void setProperty(String propertyId, Object value)
  +        throws SAXNotRecognizedException, SAXNotSupportedException {
   
  -    } // externalEntityDecl(String,String,String)
  +        super.setProperty(propertyId, value);
   
  -    /**
  -     * An unparsed entity declaration.
  -     * 
  -     * @param name     The name of the entity.
  -     * @param publicId The public identifier of the entity, or null if not
  -     *                 specified.
  -     * @param systemId The system identifier of the entity, or null if not
  -     *                 specified.
  -     * @param notation The name of the notation.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void unparsedEntityDecl(String name, String publicId,
  -                                   String systemId, String notation)
  -        throws SAXException {
  -
  -        // SAX2 extension
  -        if (fDTDHandler != null) {
  -            fDTDHandler.unparsedEntityDecl(name, publicId,
  -                                           systemId, notation);
  -        }
  +        // forward to every component
  +        fScanner.setProperty(propertyId, value);
  +        fDTDScanner.setProperty(propertyId, value);
  +        fValidator.setProperty(propertyId, value);
   
  -    } // unparsedEntityDecl(String,String,String,String)
  +    } // setProperty(String,Object)
   
       /**
  -     * A notation declaration
  -     * 
  -     * @param name     The name of the notation.
  -     * @param publicId The public identifier of the notation, or null if not
  -     *                 specified.
  -     * @param systemId The system identifier of the notation, or null if not
  -     *                 specified.
  +     * Parses the specified input source.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void notationDecl(String name, String publicId, String systemId)
  -        throws SAXException {
  -
  -        // SAX1 and SAX2
  -        if (fDTDHandler != null) {
  -            fDTDHandler.notationDecl(name, publicId, systemId);
  -        }
  -
  -    } // notationDecl(String,String,String)
  -
  -    /**
  -     * The end of the DTD.
  +     * @param source The input source.
        *
  -     * @throws SAXException Thrown by handler to signal an error.
  +     * @exception org.xml.sax.SAXException Throws exception on SAX error.
  +     * @exception java.io.IOException Throws exception on i/o error.
        */
  -    public void endDTD() throws SAXException {
  -
  -        // SAX2 extension
  -        if (fLexicalHandler != null) {
  -            fLexicalHandler.endDTD();
  -        }
  -
  -    } // endDTD()
  -
  -    //
  -    // Parser and XMLReader methods
  -    //
  +    public void parse(InputSource source)
  +        throws SAXException, IOException {
   
  -    /**
  -     * Allow an application to register a DTD event handler.
  -     * <p>
  -     * If the application does not register a DTD handler, all DTD
  -     * events reported by the SAX parser will be silently ignored.
  -     * <p>
  -     * Applications may register a new or different handler in the
  -     * middle of a parse, and the SAX parser must begin using the new
  -     * handler immediately.
  -     *
  -     * @param dtdHandler The DTD handler.
  -     *
  -     * @exception java.lang.NullPointerException If the handler 
  -     *            argument is null.
  -     *
  -     * @see #getDTDHandler
  -     */
  -    public void setDTDHandler(DTDHandler dtdHandler) {
  -        // REVISIT: SAX1 doesn't require a null pointer exception
  -        //          to be thrown but SAX2 does. [Q] How do we
  -        //          resolve this? Currently I'm erring on the side
  -        //          of SAX2. -Ac
  -        if (dtdHandler == null) {
  -            throw new NullPointerException();
  +        if (fParseInProgress) {
  +            // REVISIT - need to add new error message
  +            throw new SAXException("FWK005 parse may not be called while parsing.");
           }
  -        fDTDHandler = dtdHandler;
  -    } // setDTDHandler(DTDHandler)
  -
  -    //
  -    // Parser methods
  -    //
   
  -    /**
  -     * Allow an application to register a document event handler.
  -     * <p>
  -     * If the application does not register a document handler, all
  -     * document events reported by the SAX parser will be silently
  -     * ignored (this is the default behaviour implemented by
  -     * HandlerBase).
  -     * <p>
  -     * Applications may register a new or different handler in the
  -     * middle of a parse, and the SAX parser must begin using the new
  -     * handler immediately.
  -     *
  -     * @param documentHandler The document handler.
  -     */
  -    public void setDocumentHandler(DocumentHandler documentHandler) {
  -        fDocumentHandler = documentHandler;
  -        fDocumentHandler.setDocumentLocator(fLocator);
  -    } // setDocumentHandler(DocumentHandler)
  +        try {
  +            reset();
  +            fEntityManager.setEntityHandler(fScanner);
  +            fEntityManager.startDocumentEntity(new XMLInputSource(source));
  +            fScanner.scanDocument(true);
  +            fParseInProgress = false;
  +        } 
  +        catch (SAXException ex) {
  +            fParseInProgress = false;
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw ex;
  +        } 
  +        catch (IOException ex) {
  +            fParseInProgress = false;
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw ex;
  +        } 
  +        catch (Exception ex) {
  +            fParseInProgress = false;
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw new org.xml.sax.SAXException(ex);
  +        }
  +
  +    } // parse(InputSource)
   
       //
  -    // XMLReader methods
  +    // XMLParser methods
       //
   
       /**
  -     * Allow an application to register a content event handler.
  -     * <p>
  -     * If the application does not register a content handler, all
  -     * content events reported by the SAX parser will be silently
  -     * ignored.
  -     * <p>
  -     * Applications may register a new or different handler in the
  -     * middle of a parse, and the SAX parser must begin using the new
  -     * handler immediately.
  -     *
  -     * @param contentHandler The content handler.
  -     *
  -     * @exception java.lang.NullPointerException If the handler 
  -     *            argument is null.
  +     * Check a feature. If feature is know and supported, this method simply
  +     * returns. Otherwise, the appropriate exception is thrown.
        *
  -     * @see #getContentHandler
  -     */
  -    public void setContentHandler(ContentHandler contentHandler) {
  -        if (contentHandler == null) {
  -            throw new NullPointerException();
  -        }
  -        fContentHandler = contentHandler;
  -    } // setContentHandler(ContentHandler)
  -
  -    /**
  -     * Return the current content handler.
  -     *
  -     * @return The current content handler, or null if none
  -     *         has been registered.
  -     *
  -     * @see #setContentHandler
  -     */
  -    public ContentHandler getContentHandler() {
  -        return fContentHandler;
  -    } // getContentHandler():ContentHandler
  -
  -    /**
  -     * Return the current DTD handler.
  -     *
  -     * @return The current DTD handler, or null if none
  -     *         has been registered.
  -     * @see #setDTDHandler
  -     */
  -    public DTDHandler getDTDHandler() {
  -        return fDTDHandler;
  -    } // getDTDHandler():DTDHandler
  -
  -    /**
  -     * Set the state of any feature in a SAX2 parser.  The parser
  -     * might not recognize the feature, and if it does recognize
  -     * it, it might not be able to fulfill the request.
  -     *
        * @param featureId The unique identifier (URI) of the feature.
  -     * @param state The requested state of the feature (true or false).
        *
  -     * @exception SAXNotRecognizedException If the
  +     * @exception org.xml.sax.SAXNotRecognizedException If the
        *            requested feature is not known.
  -     * @exception SAXNotSupportedException If the
  +     * @exception org.xml.sax.SAXNotSupportedException If the
        *            requested feature is known, but the requested
        *            state is not supported.
  +     * @exception org.xml.sax.SAXException If there is any other
  +     *            problem fulfilling the request.
        */
  -    public void setFeature(String featureId, boolean state)
  +    protected void checkFeature(String featureId)
           throws SAXNotRecognizedException, SAXNotSupportedException {
   
           //
  -        // SAX2 Features
  +        // Xerces Features
           //
   
  -        if (featureId.startsWith(Constants.SAX_FEATURE_PREFIX)) {
  -            String feature = featureId.substring(Constants.SAX_FEATURE_PREFIX.length());
  -
  -            // http://xml.org/sax/features/namespace-prefixes
  -            //   controls the reporting of raw prefixed names and Namespace 
  -            //   declarations (xmlns* attributes): when this feature is false 
  -            //   (the default), raw prefixed names may optionally be reported, 
  -            //   and xmlns* attributes must not be reported.
  +        if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
  +            String feature = featureId.substring(Constants.XERCES_FEATURE_PREFIX.length());
               //
  -            if (feature.equals(Constants.NAMESPACE_PREFIXES_FEATURE)) {
  -                fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
  -                return;
  -            }
  -            // http://xml.org/sax/features/string-interning
  -            //   controls the use of java.lang.String#intern() for strings
  -            //   passed to SAX handlers.
  +            // http://apache.org/xml/features/validation/schema
  +            //   Lets the user turn Schema validation support on/off.
               //
  -            if (feature.equals(Constants.STRING_INTERNING_FEATURE)) {
  -                if (state) {
  -                    // REVISIT: Localize this error message. -Ac
  -                    throw new SAXNotSupportedException(
  -                        "PAR018 " + state + " state for feature \"" + featureId
  -                        + "\" is not supported.\n" + state + '\t' + featureId);
  -                }
  +            if (feature.equals(Constants.SCHEMA_VALIDATION_FEATURE)) {
                   return;
               }
  -   
               //
  -            // Drop through and perform default processing
  +            // http://apache.org/xml/features/validation/dynamic
  +            //   Allows the parser to validate a document only when it
  +            //   contains a grammar. Validation is turned on/off based
  +            //   on each document instance, automatically.
               //
  -        }
  -
  -        //
  -        // Xerces Features
  -        //
  -
  -        /*
  -        else if (featureId.startsWith(XERCES_FEATURES_PREFIX)) {
  -            String feature = featureId.substring(XERCES_FEATURES_PREFIX.length());
  -            //
  -            // Drop through and perform default processing
  -            //
  -        }
  -        */
  -
  -        //
  -        // Perform default processing
  -        //
  -
  -        super.setFeature(featureId, state);
  -
  -    } // setFeature(String,boolean)
  -
  -    /**
  -     * Query the state of a feature.
  -     *
  -     * Query the current state of any feature in a SAX2 parser.  The
  -     * parser might not recognize the feature.
  -     *
  -     * @param featureId The unique identifier (URI) of the feature
  -     *                  being set.
  -     * @return The current state of the feature.
  -     * @exception org.xml.sax.SAXNotRecognizedException If the
  -     *            requested feature is not known.
  -     * @exception SAXNotSupportedException If the
  -     *            requested feature is known but not supported.
  -     */
  -    public boolean getFeature(String featureId)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        //
  -        // SAX2 Features
  -        //
  -
  -        if (featureId.startsWith(Constants.SAX_FEATURE_PREFIX)) {
  -            String feature =
  -                featureId.substring(Constants.SAX_FEATURE_PREFIX.length());
  -
  -            // http://xml.org/sax/features/namespace-prefixes
  -            //   controls the reporting of raw prefixed names and Namespace 
  -            //   declarations (xmlns* attributes): when this feature is false 
  -            //   (the default), raw prefixed names may optionally be reported, 
  -            //   and xmlns* attributes must not be reported.
  -            //
  -            if (feature.equals(Constants.NAMESPACE_PREFIXES_FEATURE)) {
  -                Boolean state = (Boolean) fFeatures.get(featureId);
  -                return state.booleanValue();
  -            }
  -            // http://xml.org/sax/features/string-interning
  -            //   controls the use of java.lang.String#intern() for strings
  -            //   passed to SAX handlers.
  -            //
  -            if (feature.equals(Constants.STRING_INTERNING_FEATURE)) {
  -                return false;
  +            if (feature.equals(Constants.DYNAMIC_VALIDATION_FEATURE)) {
  +                return;
               }
  -
  -            //
  -            // Drop through and perform default processing
               //
  -        }
  -
  -        //
  -        // Xerces Features
  -        //
  -
  -        /*
  -        else if (featureId.startsWith(XERCES_FEATURES_PREFIX)) {
  +            // http://apache.org/xml/features/validation/default-attribute-values
               //
  -            // Drop through and perform default processing
  -            //
  -        }
  -        */
  -
  -        //
  -        // Perform default processing
  -        //
  -
  -        return super.getFeature(featureId);
  -
  -    } // getFeature(String):boolean
  -
  -    /**
  -     * Set the value of any property in a SAX2 parser.  The parser
  -     * might not recognize the property, and if it does recognize
  -     * it, it might not support the requested value.
  -     *
  -     * @param propertyId The unique identifier (URI) of the property
  -     *                   being set.
  -     * @param Object The value to which the property is being set.
  -     *
  -     * @exception SAXNotRecognizedException If the
  -     *            requested property is not known.
  -     * @exception SAXNotSupportedException If the
  -     *            requested property is known, but the requested
  -     *            value is not supported.
  -     */
  -    public void setProperty(String propertyId, Object value)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        //
  -        // SAX2 core properties
  -        //
  -
  -        if (propertyId.startsWith(Constants.SAX_PROPERTY_PREFIX)) {
  -            String property =
  -                propertyId.substring(Constants.SAX_PROPERTY_PREFIX.length());
  +            if (feature.equals(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
  +                // REVISIT
  +                throw new SAXNotSupportedException(featureId);
  +            }
               //
  -            // http://xml.org/sax/properties/lexical-handler
  -            // Value type: org.xml.sax.ext.LexicalHandler
  -            // Access: read/write, pre-parse only
  -            //   Set the lexical event handler.
  +            // http://apache.org/xml/features/validation/default-attribute-values
               //
  -            if (property.equals(Constants.LEXICAL_HANDLER_PROPERTY)) {
  -                try {
  -                    setLexicalHandler((LexicalHandler)value);
  -                }
  -                catch (ClassCastException e) {
  -                    // REVISIT: Localize this error message. -ac
  -                    throw new SAXNotSupportedException(
  -                    "PAR012 For propertyID \""
  -                    +propertyId+"\", the value \""
  -                    +value+"\" cannot be cast to LexicalHandler."
  -                    +'\n'+propertyId+'\t'+value+"\tLexicalHandler");
  -                }
  -                return;
  +            if (feature.equals(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
  +                // REVISIT
  +                throw new SAXNotSupportedException(featureId);
               }
               //
  -            // http://xml.org/sax/properties/declaration-handler
  -            // Value type: org.xml.sax.ext.DeclHandler
  -            // Access: read/write, pre-parse only
  -            //   Set the DTD declaration event handler.
  +            // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
               //
  -            if (property.equals(Constants.DECLARATION_HANDLER_PROPERTY)) {
  -                try {
  -                    setDeclHandler((DeclHandler)value);
  -                }
  -                catch (ClassCastException e) {
  -                    // REVISIT: Localize this error message. -ac
  -                    throw new SAXNotSupportedException(
  -                    "PAR012 For propertyID \""
  -                    +propertyId+"\", the value \""
  -                    +value+"\" cannot be cast to DeclHandler."
  -                    +'\n'+propertyId+'\t'+value+"\tDeclHandler"
  -                    );
  -                }
  +            if (feature.equals(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
                   return;
               }
               //
  -            // http://xml.org/sax/properties/dom-node
  -            // Value type: DOM Node
  -            // Access: read-only
  -            //   Get the DOM node currently being visited, if the SAX parser is
  -            //   iterating over a DOM tree.  If the parser recognises and
  -            //   supports this property but is not currently visiting a DOM
  -            //   node, it should return null (this is a good way to check for
  -            //   availability before the parse begins).
  +            // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
               //
  -            if (property.equals(Constants.DOM_NODE_PROPERTY)) {
  -                // REVISIT: Localize this error message. -ac
  -                throw new SAXNotSupportedException(
  -                    "PAR013 Property \""+propertyId+"\" is read only."
  -                    +'\n'+propertyId
  -                    ); // read-only property
  +            if (feature.equals(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
  +                return;
               }
  -            //
  -            // Drop through and perform default processing
  -            //
  -        }
   
  -        //
  -        // Xerces Properties
  -        //
  -
  -        /*
  -        else if (propertyId.startsWith(XERCES_PROPERTIES_PREFIX)) {
               //
  -            // Drop through and perform default processing
  +            // http://apache.org/xml/features/validation/default-attribute-values
               //
  +            if (feature.equals(Constants.VALIDATE_DATATYPES_FEATURE)) {
  +                throw new SAXNotSupportedException(featureId);
  +            }
           }
  -        */
   
           //
  -        // Perform default processing
  +        // Not recognized
           //
   
  -        super.setProperty(propertyId, value);
  +        super.checkFeature(featureId);
   
  -    } // setProperty(String,Object)
  +    } // checkFeature(String)
   
       /**
  -     * Query the value of a property.
  -     *
  -     * Return the current value of a property in a SAX2 parser.
  -     * The parser might not recognize the property.
  +     * Check a property. If the property is know and supported, this method
  +     * simply returns. Otherwise, the appropriate exception is thrown.
        *
        * @param propertyId The unique identifier (URI) of the property
        *                   being set.
  -     * @return The current value of the property.
        * @exception org.xml.sax.SAXNotRecognizedException If the
        *            requested property is not known.
  -     * @exception SAXNotSupportedException If the
  -     *            requested property is known but not supported.
  +     * @exception org.xml.sax.SAXNotSupportedException If the
  +     *            requested property is known, but the requested
  +     *            value is not supported.
  +     * @exception org.xml.sax.SAXException If there is any other
  +     *            problem fulfilling the request.
        */
  -    public Object getProperty(String propertyId)
  +    protected void checkProperty(String propertyId)
           throws SAXNotRecognizedException, SAXNotSupportedException {
   
           //
  -        // SAX2 core properties
  +        // Xerces Properties
           //
   
  -        if (propertyId.startsWith(Constants.SAX_PROPERTY_PREFIX)) {
  -            String property =
  -                propertyId.substring(Constants.SAX_PROPERTY_PREFIX.length());
  -            //
  -            // http://xml.org/sax/properties/lexical-handler
  -            // Value type: org.xml.sax.ext.LexicalHandler
  -            // Access: read/write, pre-parse only
  -            //   Set the lexical event handler.
  -            //
  -            if (property.equals(Constants.LEXICAL_HANDLER_PROPERTY)) {
  -                return getLexicalHandler();
  -            }
  -            //
  -            // http://xml.org/sax/properties/declaration-handler
  -            // Value type: org.xml.sax.ext.DeclHandler
  -            // Access: read/write, pre-parse only
  -            //   Set the DTD declaration event handler.
  -            //
  -            if (property.equals(Constants.DECLARATION_HANDLER_PROPERTY)) {
  -                return getDeclHandler();
  -            }
  -            //
  -            // http://xml.org/sax/properties/dom-node
  -            // Value type: DOM Node
  -            // Access: read-only
  -            //   Get the DOM node currently being visited, if the SAX parser is
  -            //   iterating over a DOM tree.  If the parser recognises and
  -            //   supports this property but is not currently visiting a DOM
  -            //   node, it should return null (this is a good way to check for
  -            //   availability before the parse begins).
  -            //
  -            if (property.equals(Constants.DOM_NODE_PROPERTY)) {
  -                // REVISIT: Localize this error message. -Ac
  -                throw new SAXNotSupportedException(
  -                "PAR014 Cannot getProperty(\""+propertyId
  -                +"\". No DOM Tree exists.\n"+propertyId
  -                ); // we are not iterating a DOM tree
  +        if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
  +            String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
  +            if (property.equals(Constants.DTD_SCANNER_PROPERTY)) {
  +                return;
               }
  -            //
  -            // Drop through and perform default processing
  -            //
  -        }
  -
  -        //
  -        // Xerces properties
  -        //
  -
  -        /*
  -        else if (propertyId.startsWith(XERCES_PROPERTIES_PREFIX)) {
  -            //
  -            // Drop through and perform default processing
  -            //
           }
  -        */
   
           //
  -        // Perform default processing
  +        // Not recognized
           //
   
  -        return super.getProperty(propertyId);
  +        super.checkProperty(propertyId);
   
  -    } // getProperty(String):Object
  +    } // checkProperty(String)
   
       //
       // Protected methods
       //
  -
  -    // SAX2 core properties
  -
  -    /**
  -     * Set the DTD declaration event handler.
  -     * <p>
  -     * This method is the equivalent to the property:
  -     * <pre>
  -     * http://xml.org/sax/properties/declaration-handler
  -     * </pre>
  -     *
  -     * @param handler The new handler.
  -     *
  -     * @see #getDeclHandler
  -     * @see #setProperty
  -     */
  -    protected void setDeclHandler(DeclHandler handler) 
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        if (fParseInProgress) {
  -            // REVISIT: Localize this error message. -Ac
  -            throw new SAXNotSupportedException(
  -                "PAR011 Feature: http://xml.org/sax/properties/declaration-handler"
  -                +" is not supported during parse."
  -                +"\nhttp://xml.org/sax/properties/declaration-handler");
  -        }
  -        fDeclHandler = handler;
  -
  -    } // setDeclHandler(DeclHandler)
  -
  -    /**
  -     * Returns the DTD declaration event handler.
  -     *
  -     * @see #setDeclHandler
  -     */
  -    protected DeclHandler getDeclHandler() 
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -        return fDeclHandler;
  -    } // getDeclHandler():DeclHandler
  -
  -    /**
  -     * Set the lexical event handler.
  -     * <p>
  -     * This method is the equivalent to the property:
  -     * <pre>
  -     * http://xml.org/sax/properties/lexical-handler
  -     * </pre>
  -     *
  -     * @param handler lexical event handler
  -     *
  -     * @see #getLexicalHandler
  -     * @see #setProperty
  -     */
  -    protected void setLexicalHandler(LexicalHandler handler)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        if (fParseInProgress) {
  -            // REVISIT: Localize this error message. -Ac
  -            throw new SAXNotSupportedException(
  -            "PAR011 Feature: http://xml.org/sax/properties/lexical-handler"
  -            +" is not supported during parse."
  -            +"\nhttp://xml.org/sax/properties/lexical-handler");
  -        }
  -        fLexicalHandler = handler;
  -
  -    } // setLexicalHandler(LexicalHandler)
  -
  -    /**
  -     * Returns the lexical handler.
  -     *
  -     * @see #setLexicalHandler
  -     */
  -    protected LexicalHandler getLexicalHandler() 
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -        return fLexicalHandler;
  -    } // getLexicalHandler():LexicalHandler
  -
  -    //
  -    // XMLDocumentParser methods
  -    //
   
  -    /** 
  -     * Reset all components before parsing. 
  -     *
  -     * @throws SAXException Thrown if an error occurs during initialization.
  -     */
  -    protected void reset() throws SAXException {
  -        super.reset();
  +    // factory methods
   
  -        // save needed symbols
  -        fEmptySymbol = fSymbolTable.addSymbol("");
  -
  -    } // reset()
  +    /** Create a document scanner. */
  +    protected XMLDocumentScanner createDocumentScanner() {
  +        return new XMLDocumentScanner();
  +    } // createDocumentScanner():XMLDocumentScanner
  +
  +    /** Create a DTD scanner. */
  +    protected XMLDTDScanner createDTDScanner() {
  +        return new XMLDTDScanner();
  +    } // createDTDScanner():XMLDTDScanner
  +
  +    /** Create a validator. */
  +    protected XMLValidator createValidator() {
  +        return new XMLValidator();
  +    } // createValidator():XMLValidator
  +
  +    /** Create a datatype validator factory. */
  +    protected DatatypeValidatorFactory createDatatypeValidatorFactory() {
  +        return new DatatypeValidatorFactoryImpl();
  +    } // createDatatypeValidatorFactory():DatatypeValidatorFactory
   
   } // class SAXParser
  
  
  
  1.1.2.31  +3 -389    xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLDocumentParser.java
  
  Index: XMLDocumentParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLDocumentParser.java,v
  retrieving revision 1.1.2.30
  retrieving revision 1.1.2.31
  diff -u -r1.1.2.30 -r1.1.2.31
  --- XMLDocumentParser.java	2001/01/30 04:17:02	1.1.2.30
  +++ XMLDocumentParser.java	2001/02/13 19:04:58	1.1.2.31
  @@ -64,10 +64,6 @@
   import org.apache.xerces.impl.XMLDTDScanner;
   import org.apache.xerces.impl.XMLEntityManager;
   import org.apache.xerces.impl.XMLInputSource;
  -import org.apache.xerces.impl.XMLValidator;
  -import org.apache.xerces.impl.validation.DatatypeValidatorFactory;
  -import org.apache.xerces.impl.validation.GrammarPool;
  -import org.apache.xerces.impl.validation.datatypes.DatatypeValidatorFactoryImpl;
   
   import org.apache.xerces.util.SymbolTable;
   
  @@ -94,44 +90,16 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLDocumentParser.java,v 1.1.2.30 2001/01/30 04:17:02 andyc Exp $
  + * @version $Id: XMLDocumentParser.java,v 1.1.2.31 2001/02/13 19:04:58 lehors Exp $
    */
   public abstract class XMLDocumentParser
       extends XMLParser
       implements XMLDocumentHandler, XMLDTDHandler, XMLDTDContentModelHandler {
   
       //
  -    // Constants
  -    //
  -
  -    // debugging
  -
  -    /** Set to true and recompile to print exception stack trace. */
  -    private static final boolean PRINT_EXCEPTION_STACK_TRACE = false;
  -
  -    //
       // Data
       //
   
  -    // components (non-configurable)
  -
  -    /** Grammar pool. */
  -    protected GrammarPool fGrammarPool;
  -
  -    /** Datatype validator factory. */
  -    protected DatatypeValidatorFactory fDatatypeValidatorFactory;
  -
  -    // components (configurable)
  -
  -    /** Document scanner. */
  -    protected XMLDocumentScanner fScanner;
  -
  -    /** DTD scanner. */
  -    protected XMLDTDScanner fDTDScanner;
  -
  -    /** Validator. */
  -    protected XMLValidator fValidator;
  -
       // state
   
       /** 
  @@ -150,7 +118,7 @@
        * and grammar pool.
        */
       protected XMLDocumentParser() {
  -        this(new SymbolTable(), new GrammarPool());
  +        this(new SymbolTable());
       } // <init>()
   
       /** 
  @@ -158,214 +126,8 @@
        * and a default grammar pool.
        */
       protected XMLDocumentParser(SymbolTable symbolTable) {
  -        this(symbolTable, new GrammarPool());
  -    } // <init>(SymbolTable)
  -
  -    /**
  -     * Constructor allowing to specify the symbol table and grammar pool 
  -     * to use. The symbol table and grammar pool are specified together
  -     * because the grammars contained in the grammar pool must use the
  -     * symbols from the specified symbol table.
  -     * 
  -     * @param symbolTable The symbol table.
  -     * @param grammarPool The grammar pool.
  -     */
  -    protected XMLDocumentParser(SymbolTable symbolTable,
  -                                GrammarPool grammarPool) {
           super(symbolTable);
  -
  -        // set default features
  -        final String NAMESPACES = Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
  -        fFeatures.put(NAMESPACES, Boolean.TRUE);
  -        final String VALIDATION = Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
  -        fFeatures.put(VALIDATION, Boolean.FALSE);
  -        final String EXTERNAL_GENERAL_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE;
  -        fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
  -        final String EXTERNAL_PARAMETER_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
  -        fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
  -
  -        // create and register components
  -        final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  -        fProperties.put(SYMBOL_TABLE, fSymbolTable);
  -
  -        fGrammarPool = grammarPool;
  -        final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
  -        fProperties.put(GRAMMAR_POOL, fGrammarPool);
  -
  -        fScanner = createDocumentScanner();
  -        final String DOCUMENT_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
  -        fProperties.put(DOCUMENT_SCANNER, fScanner);
  -
  -        fDTDScanner = createDTDScanner();
  -        final String DTD_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
  -        fProperties.put(DTD_SCANNER, fDTDScanner);
  -
  -        fValidator = createValidator();
  -        final String VALIDATOR = Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATOR_PROPERTY;
  -        fProperties.put(VALIDATOR, fValidator);
  -        
  -        fDatatypeValidatorFactory = createDatatypeValidatorFactory();
  -        final String DATATYPE_VALIDATOR_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
  -        fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
  -
  -    } // <init>(SymbolTable,GrammarPool)
  -
  -    //
  -    // XMLParser methods
  -    //
  -
  -    /** 
  -     * Reset all components before parsing. 
  -     *
  -     * @throws SAXException Thrown if an error occurs during initialization.
  -     */
  -    protected void reset() throws SAXException {
  -        super.reset();
  -
  -
  -        // setup document pipeline
  -        fScanner.setDocumentHandler(fValidator);
  -        fValidator.setDocumentHandler(this);
  -
  -        // setup dtd pipeline
  -        fDTDScanner.setDTDHandler(fValidator);
  -        fValidator.setDTDHandler(this);
  -
  -        // setup dtd content model pipeline
  -        /***/
  -        fDTDScanner.setDTDContentModelHandler(fValidator);
  -        fValidator.setDTDContentModelHandler(this);
  -
  -        // reset every component
  -        fScanner.reset(this);
  -        fDTDScanner.reset(this);
  -        fValidator.reset(this);
  -
  -    } // reset()
  -
  -    //
  -    // XMLReader methods
  -    //
  -
  -    /**
  -     * Set the state of a feature.
  -     * <p>
  -     * The feature name is any fully-qualified URI.  It is
  -     * possible for an XMLReader to recognize a feature name but
  -     * to be unable to set its value; this is especially true
  -     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser},
  -     * which has no way of affecting whether the underlying parser is
  -     * validating, for example.
  -     * <p>
  -     * Some feature values may be immutable or mutable only 
  -     * in specific contexts, such as before, during, or after 
  -     * a parse.
  -     *
  -     * @param name The feature name, which is a fully-qualified URI.
  -     * @param state The requested state of the feature (true or false).
  -     *
  -     * @exception org.xml.sax.SAXNotRecognizedException When the
  -     *            XMLReader does not recognize the feature name.
  -     * @exception org.xml.sax.SAXNotSupportedException When the
  -     *            XMLReader recognizes the feature name but 
  -     *            cannot set the requested value.
  -     *
  -     * @see #getFeature
  -     */
  -    public void setFeature(String featureId, boolean state)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        super.setFeature(featureId, state);
  -
  -        // forward to every component
  -        fScanner.setFeature(featureId, state);
  -        fDTDScanner.setFeature(featureId, state);
  -        fValidator.setFeature(featureId, state);
  -
  -    } // setFeature(String,boolean)
  -
  -    /**
  -     * Set the value of a property.
  -     * <p>
  -     * The property name is any fully-qualified URI.  It is
  -     * possible for an XMLReader to recognize a property name but
  -     * to be unable to set its value; this is especially true
  -     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
  -     * Parser}.
  -     * <p>
  -     * Some property values may be immutable or mutable only 
  -     * in specific contexts, such as before, during, or after 
  -     * a parse.
  -     * <p>
  -     * This method is also the standard mechanism for setting
  -     * extended handlers.
  -     *
  -     * @param name The property name, which is a fully-qualified URI.
  -     * @param state The requested value for the property.
  -     *
  -     * @exception org.xml.sax.SAXNotRecognizedException When the
  -     *            XMLReader does not recognize the property name.
  -     * @exception org.xml.sax.SAXNotSupportedException When the
  -     *            XMLReader recognizes the property name but 
  -     *            cannot set the requested value.
  -     *
  -     * @see #getProperty
  -     */
  -    public void setProperty(String propertyId, Object value)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        super.setProperty(propertyId, value);
  -
  -        // forward to every component
  -        fScanner.setProperty(propertyId, value);
  -        fDTDScanner.setProperty(propertyId, value);
  -        fValidator.setProperty(propertyId, value);
  -
  -    } // setProperty(String,Object)
  -
  -    /**
  -     * Parses the specified input source.
  -     *
  -     * @param source The input source.
  -     *
  -     * @exception org.xml.sax.SAXException Throws exception on SAX error.
  -     * @exception java.io.IOException Throws exception on i/o error.
  -     */
  -    public void parse(InputSource source)
  -        throws SAXException, IOException {
  -
  -        if (fParseInProgress) {
  -            // REVISIT - need to add new error message
  -            throw new SAXException("FWK005 parse may not be called while parsing.");
  -        }
  -
  -        try {
  -            reset();
  -            fEntityManager.setEntityHandler(fScanner);
  -            fEntityManager.startDocumentEntity(new XMLInputSource(source));
  -            fScanner.scanDocument(true);
  -            fParseInProgress = false;
  -        } 
  -        catch (SAXException ex) {
  -            fParseInProgress = false;
  -            if (PRINT_EXCEPTION_STACK_TRACE)
  -                ex.printStackTrace();
  -            throw ex;
  -        } 
  -        catch (IOException ex) {
  -            fParseInProgress = false;
  -            if (PRINT_EXCEPTION_STACK_TRACE)
  -                ex.printStackTrace();
  -            throw ex;
  -        } 
  -        catch (Exception ex) {
  -            fParseInProgress = false;
  -            if (PRINT_EXCEPTION_STACK_TRACE)
  -                ex.printStackTrace();
  -            throw new org.xml.sax.SAXException(ex);
  -        }
  -
  -    } // parse(InputSource)
  +    } // <init>(SymbolTable)
   
       //
       // XMLDocumentHandler methods
  @@ -910,153 +672,5 @@
        */
       public void endContentModel() throws SAXException {
       } // endContentModel()
  -
  -    //
  -    // XMLParser methods
  -    //
  -
  -    /**
  -     * Check a feature. If feature is know and supported, this method simply
  -     * returns. Otherwise, the appropriate exception is thrown.
  -     *
  -     * @param featureId The unique identifier (URI) of the feature.
  -     *
  -     * @exception org.xml.sax.SAXNotRecognizedException If the
  -     *            requested feature is not known.
  -     * @exception org.xml.sax.SAXNotSupportedException If the
  -     *            requested feature is known, but the requested
  -     *            state is not supported.
  -     * @exception org.xml.sax.SAXException If there is any other
  -     *            problem fulfilling the request.
  -     */
  -    protected void checkFeature(String featureId)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        //
  -        // Xerces Features
  -        //
  -
  -        if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
  -            String feature = featureId.substring(Constants.XERCES_FEATURE_PREFIX.length());
  -            //
  -            // http://apache.org/xml/features/validation/schema
  -            //   Lets the user turn Schema validation support on/off.
  -            //
  -            if (feature.equals(Constants.SCHEMA_VALIDATION_FEATURE)) {
  -                return;
  -            }
  -            //
  -            // http://apache.org/xml/features/validation/dynamic
  -            //   Allows the parser to validate a document only when it
  -            //   contains a grammar. Validation is turned on/off based
  -            //   on each document instance, automatically.
  -            //
  -            if (feature.equals(Constants.DYNAMIC_VALIDATION_FEATURE)) {
  -                return;
  -            }
  -            //
  -            // http://apache.org/xml/features/validation/default-attribute-values
  -            //
  -            if (feature.equals(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
  -                // REVISIT
  -                throw new SAXNotSupportedException(featureId);
  -            }
  -            //
  -            // http://apache.org/xml/features/validation/default-attribute-values
  -            //
  -            if (feature.equals(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
  -                // REVISIT
  -                throw new SAXNotSupportedException(featureId);
  -            }
  -            //
  -            // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
  -            //
  -            if (feature.equals(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
  -                return;
  -            }
  -            //
  -            // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
  -            //
  -            if (feature.equals(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
  -                return;
  -            }
  -
  -            //
  -            // http://apache.org/xml/features/validation/default-attribute-values
  -            //
  -            if (feature.equals(Constants.VALIDATE_DATATYPES_FEATURE)) {
  -                throw new SAXNotSupportedException(featureId);
  -            }
  -        }
  -
  -        //
  -        // Not recognized
  -        //
  -
  -        super.checkFeature(featureId);
  -
  -    } // checkFeature(String)
  -
  -    /**
  -     * Check a property. If the property is know and supported, this method
  -     * simply returns. Otherwise, the appropriate exception is thrown.
  -     *
  -     * @param propertyId The unique identifier (URI) of the property
  -     *                   being set.
  -     * @exception org.xml.sax.SAXNotRecognizedException If the
  -     *            requested property is not known.
  -     * @exception org.xml.sax.SAXNotSupportedException If the
  -     *            requested property is known, but the requested
  -     *            value is not supported.
  -     * @exception org.xml.sax.SAXException If there is any other
  -     *            problem fulfilling the request.
  -     */
  -    protected void checkProperty(String propertyId)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        //
  -        // Xerces Properties
  -        //
  -
  -        if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
  -            String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
  -            if (property.equals(Constants.DTD_SCANNER_PROPERTY)) {
  -                return;
  -            }
  -        }
  -
  -        //
  -        // Not recognized
  -        //
  -
  -        super.checkProperty(propertyId);
  -
  -    } // checkProperty(String)
  -
  -    //
  -    // Protected methods
  -    //
  -
  -    // factory methods
  -
  -    /** Create a document scanner. */
  -    protected XMLDocumentScanner createDocumentScanner() {
  -        return new XMLDocumentScanner();
  -    } // createDocumentScanner():XMLDocumentScanner
  -
  -    /** Create a DTD scanner. */
  -    protected XMLDTDScanner createDTDScanner() {
  -        return new XMLDTDScanner();
  -    } // createDTDScanner():XMLDTDScanner
  -
  -    /** Create a validator. */
  -    protected XMLValidator createValidator() {
  -        return new XMLValidator();
  -    } // createValidator():XMLValidator
  -
  -    /** Create a datatype validator factory. */
  -    protected DatatypeValidatorFactory createDatatypeValidatorFactory() {
  -        return new DatatypeValidatorFactoryImpl();
  -    } // createDatatypeValidatorFactory():DatatypeValidatorFactory
   
   } // class XMLDocumentParser
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +595 -0    xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractDOMParser.java
  
  
  
  
  1.1.2.1   +1174 -0   xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractSAXParser.java