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/14 03:10:33 UTC

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

lehors      01/02/13 18:10:33

  Modified:    java/src/org/apache/xerces/parsers Tag: xerces_j_2
                        AbstractDOMParser.java AbstractSAXParser.java
                        DOMParser.java SAXParser.java
                        XMLDocumentParser.java XMLParser.java
  Added:       java/src/org/apache/xerces/parsers Tag: xerces_j_2
                        AbstractXMLDocumentParser.java
  Log:
  Finish up previous change.
  The old constructors are back to avoid having to change too much code around
  and the XMLDocumentScanner is again a concrete class so it can still be
  used in places like the XPathMatcher.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +9 -2      xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractDOMParser.java
  
  Index: AbstractDOMParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractDOMParser.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AbstractDOMParser.java	2001/02/13 22:51:24	1.1.2.2
  +++ AbstractDOMParser.java	2001/02/14 02:10:30	1.1.2.3
  @@ -91,9 +91,9 @@
    * @author Andy Clark, IBM
    *
    * 
  - * @version $Id: AbstractDOMParser.java,v 1.1.2.2 2001/02/13 22:51:24 lehors Exp $ */
  + * @version $Id: AbstractDOMParser.java,v 1.1.2.3 2001/02/14 02:10:30 lehors Exp $ */
   public abstract class AbstractDOMParser
  -    extends XMLDocumentParser {
  +    extends AbstractXMLDocumentParser {
   
       //
       // Data
  @@ -133,6 +133,13 @@
       /** Default constructor. */
       protected AbstractDOMParser() {
       } // <init>()
  +
  +    /**
  +     * Constructs a DOM parser using the specified symbol table.
  +     */
  +    protected AbstractDOMParser(SymbolTable symbolTable) {
  +        super(symbolTable);
  +    } // <init>(SymbolTable)
   
       //
       // Public methods
  
  
  
  1.1.2.3   +9 -2      xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractSAXParser.java
  
  Index: AbstractSAXParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractSAXParser.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AbstractSAXParser.java	2001/02/13 22:51:25	1.1.2.2
  +++ AbstractSAXParser.java	2001/02/14 02:10:30	1.1.2.3
  @@ -88,9 +88,9 @@
    * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
    * @author Andy Clark, IBM
    *
  - * @version $Id: AbstractSAXParser.java,v 1.1.2.2 2001/02/13 22:51:25 lehors Exp $ */
  + * @version $Id: AbstractSAXParser.java,v 1.1.2.3 2001/02/14 02:10:30 lehors Exp $ */
   public abstract class AbstractSAXParser
  -    extends XMLDocumentParser
  +    extends AbstractXMLDocumentParser
       implements Parser, XMLReader // SAX1, SAX2
       {
   
  @@ -127,6 +127,13 @@
       /** Default constructor. */
       protected AbstractSAXParser() {
       } // <init>()
  +
  +    /**
  +     * Constructs a SAX parser using the specified symbol table.
  +     */
  +    protected AbstractSAXParser(SymbolTable symbolTable) {
  +        super(symbolTable);
  +    } // <init>(SymbolTable)
   
       //
       // XMLDocumentHandler methods
  
  
  
  1.19.2.13 +22 -2     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.12
  retrieving revision 1.19.2.13
  diff -u -r1.19.2.12 -r1.19.2.13
  --- DOMParser.java	2001/02/13 22:51:25	1.19.2.12
  +++ DOMParser.java	2001/02/14 02:10:30	1.19.2.13
  @@ -85,7 +85,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: DOMParser.java,v 1.19.2.12 2001/02/13 22:51:25 lehors Exp $ */
  + * @version $Id: DOMParser.java,v 1.19.2.13 2001/02/14 02:10:30 lehors Exp $ */
   public class DOMParser
       extends AbstractDOMParser {
   
  @@ -126,10 +126,30 @@
       //
   
       /**
  -     * Constructs a DOM parser.
  +     * Constructs a DOM parser using the default symbol table and grammar pool
  +     * or the ones specified by the application (through the properties).
        */
       public DOMParser() {
       } // <init>
  +
  +    /**
  +     * Constructs a DOM parser using the specified symbol table.
  +     */
  +    public DOMParser(SymbolTable symbolTable) {
  +        super(symbolTable);
  +    } // <init>(SymbolTable)
  +
  +    /**
  +     * Constructs a DOM parser using the specified symbol table and grammar
  +     * pool.
  +     */
  +    public DOMParser(SymbolTable symbolTable, GrammarPool grammarPool) {
  +        super(symbolTable);
  +
  +        final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
  +        fGrammarPool = new GrammarPool();
  +        fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +    }
   
       /**
        * Initialize the parser with all the components specified via the
  
  
  
  1.12.2.20 +19 -0     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.19
  retrieving revision 1.12.2.20
  diff -u -r1.12.2.19 -r1.12.2.20
  --- SAXParser.java	2001/02/13 22:51:26	1.12.2.19
  +++ SAXParser.java	2001/02/14 02:10:31	1.12.2.20
  @@ -85,7 +85,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: SAXParser.java,v 1.12.2.19 2001/02/13 22:51:26 lehors Exp $ */
  + * @version $Id: SAXParser.java,v 1.12.2.20 2001/02/14 02:10:31 lehors Exp $ */
   public class SAXParser
       extends AbstractSAXParser {
   
  @@ -130,6 +130,25 @@
        */
       public SAXParser() {
       } // <init>
  +
  +    /**
  +     * Constructs a SAX parser using the specified symbol table.
  +     */
  +    public SAXParser(SymbolTable symbolTable) {
  +        super(symbolTable);
  +    } // <init>(SymbolTable)
  +
  +    /**
  +     * Constructs a SAX parser using the specified symbol table and grammar
  +     * pool.
  +     */
  +    public SAXParser(SymbolTable symbolTable, GrammarPool grammarPool) {
  +        super(symbolTable);
  +
  +        final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
  +        fGrammarPool = new GrammarPool();
  +        fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +    }
   
       /**
        * Initialize the parser with all the components specified via the
  
  
  
  1.1.2.33  +332 -555  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.32
  retrieving revision 1.1.2.33
  diff -u -r1.1.2.32 -r1.1.2.33
  --- XMLDocumentParser.java	2001/02/13 22:51:26	1.1.2.32
  +++ XMLDocumentParser.java	2001/02/14 02:10:31	1.1.2.33
  @@ -1,9 +1,8 @@
  -
   /*
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -65,604 +64,382 @@
   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.XMLDocumentHandler;
  -import org.apache.xerces.xni.XMLDTDHandler;
  -import org.apache.xerces.xni.XMLDTDContentModelHandler;
  -import org.apache.xerces.xni.XMLString;
  -
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   import org.xml.sax.SAXNotRecognizedException;
   import org.xml.sax.SAXNotSupportedException;
   
   /**
  - * This is the base class for all XML document parsers. XMLDocumentParser
  - * provides a common implementation shared by the various document parsers
  - * in the Xerces package. While this class is provided for convenience, it
  - * does not prevent other kinds of parsers to be constructed using the XNI
  - * interfaces.
  + * This is a concrete vanilla XML parser class. It uses the abstract 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: XMLDocumentParser.java,v 1.1.2.32 2001/02/13 22:51:26 lehors Exp $
  - */
  -public abstract class XMLDocumentParser
  -    extends XMLParser
  -    implements XMLDocumentHandler, XMLDTDHandler, XMLDTDContentModelHandler {
  + * @version $Id: XMLDocumentParser.java,v 1.1.2.33 2001/02/14 02:10:31 lehors Exp $ */
  +public class XMLDocumentParser
  +    extends AbstractDOMParser {
   
       //
  -    // Data
  +    // Constants
       //
  -
  -    // state
   
  -    /** 
  -     * True if a parse is in progress. This state is needed because
  -     * some features/properties cannot be set while parsing (e.g.
  -     * validation and namespaces).
  -     */
  -    protected boolean fParseInProgress = false;
  -
  -    //
  -    // Constructors
  -    //
  +    // debugging
   
  -    /**
  -     * Constructs a document parser using the default symbol table
  -     * and grammar pool.
  -     */
  -    protected XMLDocumentParser() {
  -    } // <init>()
  +    /** Set to true and recompile to print exception stack trace. */
  +    private static final boolean PRINT_EXCEPTION_STACK_TRACE = false;
   
       //
  -    // XMLDocumentHandler methods
  +    // Data
       //
  -
  -    /**
  -     * The start of the document.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startDocument() throws SAXException {
  -    } // startDocument()
  -
  -    /**
  -     * Notifies of the presence of an XMLDecl line in the document. If
  -     * present, this method will be called immediately following the
  -     * startDocument call.
  -     * 
  -     * @param version    The XML version.
  -     * @param encoding   The IANA encoding name of the document, or null if
  -     *                   not specified.
  -     * @param standalone The standalone value, or null if not specified.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void xmlDecl(String version, String encoding, String standalone)
  -        throws SAXException {
  -    } // xmlDecl(String,String,String)
  -
  -    /**
  -     * 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 {
  -    } // 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 {
  -    } // startPrefixMapping(String,String)
  -
  -    /**
  -     * 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 {
  -    } // 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 {
  -    } // 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 {
  -    } // 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 {
  -    } // endElement(QName)
  +    // components (non-configurable)
   
  -    /**
  -     * 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)
  +    /** Grammar pool. */
  +    protected GrammarPool fGrammarPool;
   
  -    /** 
  -     * The start of a CDATA section. 
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startCDATA() throws SAXException {
  -    } // startCDATA()
  +    /** Datatype validator factory. */
  +    protected DatatypeValidatorFactory fDatatypeValidatorFactory;
   
  -    /**
  -     * The end of a CDATA section. 
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endCDATA() throws SAXException {
  -    } // endCDATA()
  +    // components (configurable)
   
  -    /**
  -     * The end of the document.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endDocument() throws SAXException {
  -    } // endDocument()
  +    /** Document scanner. */
  +    protected XMLDocumentScanner fScanner;
   
  -    //
  -    // XMLDocumentHandler and XMLDTDHandler methods
  -    //
  +    /** DTD scanner. */
  +    protected XMLDTDScanner fDTDScanner;
   
  -    /**
  -     * 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 {
  -    } // startEntity(String,String,String,String)
  -
  -    /**
  -     * Notifies of the presence of a TextDecl line in an entity. If present,
  -     * this method will be called immediately following the startEntity call.
  -     * <p>
  -     * <strong>Note:</strong> This method will never be called for the
  -     * document entity; it is only called for external general entities
  -     * referenced in document content.
  -     * <p>
  -     * <strong>Note:</strong> This method is not called for entity references
  -     * appearing as part of attribute values.
  -     * 
  -     * @param version  The XML version, or null if not specified.
  -     * @param encoding The IANA encoding name of the entity.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void textDecl(String version, String encoding) throws SAXException {
  -    } // textDecl(String,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 {
  -    } // comment(XMLString)
  -
  -    /**
  -     * A processing instruction. Processing instructions consist of a
  -     * target name and, optionally, text data. The data is only meaningful
  -     * to the application.
  -     * <p>
  -     * Typically, a processing instruction's data will contain a series
  -     * of pseudo-attributes. These pseudo-attributes follow the form of
  -     * element attributes but are <strong>not</strong> parsed or presented
  -     * to the application as anything other than text. The application is
  -     * responsible for parsing the data.
  -     * 
  -     * @param target The target.
  -     * @param data   The data or null if none specified.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void processingInstruction(String target, XMLString data)
  -        throws SAXException {
  -    } // processingInstruction(String,XMLString)
  -
  -    /**
  -     * 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 {
  -    } // endEntity(String)
  +    /** Validator. */
  +    protected XMLValidator fValidator;
   
       //
  -    // XMLDTDHandler methods
  +    // Constructors
       //
   
  -    /**
  -     * The start of the DTD.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startDTD() throws SAXException {
  -    } // startDTD()
  -
  -    /**
  -     * An element declaration.
  -     * 
  -     * @param name         The name of the element.
  -     * @param contentModel The element content model.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void elementDecl(String name, String contentModel)
  -        throws SAXException {
  -    } // elementDecl(String,String)
  -
  -    /**
  -     * The start of an attribute list.
  -     * 
  -     * @param elementName The name of the element that this attribute
  -     *                    list is associated with.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void startAttlist(String elementName) throws SAXException {
  -    } // startAttlist(String)
  -
  -    /**
  -     * An attribute declaration.
  -     * 
  -     * @param elementName   The name of the element that this attribute
  -     *                      is associated with.
  -     * @param attributeName The name of the attribute.
  -     * @param type          The attribute type. This value will be one of
  -     *                      the following: "CDATA", "ENTITY", "ENTITIES",
  -     *                      "ENUMERATION", "ID", "IDREF", "IDREFS", 
  -     *                      "NMTOKEN", "NMTOKENS", or "NOTATION".
  -     * @param enumeration   If the type has the value "ENUMERATION", this
  -     *                      array holds the allowed attribute values;
  -     *                      otherwise, this array is null.
  -     * @param defaultType   The attribute default type. This value will be
  -     *                      one of the following: "#FIXED", "#IMPLIED",
  -     *                      "#REQUIRED", or null.
  -     * @param defaultValue  The attribute default value, or null if no
  -     *                      default value is specified.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void attributeDecl(String elementName, String attributeName, 
  -                              String type, String[] enumeration, 
  -                              String defaultType, XMLString defaultValue)
  -        throws SAXException {
  -    } // attributeDecl(String,String,String,String[],String,XMLString)
  -
       /**
  -     * The end of an attribute list.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endAttlist() throws SAXException {
  -    } // endAttlist()
  -
  -    /**
  -     * An internal entity declaration.
  -     * 
  -     * @param name The name of the entity. Parameter entity names start with
  -     *             '%', whereas the name of a general entity is just the 
  -     *             entity name.
  -     * @param text The value of the entity.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void internalEntityDecl(String name, XMLString text) 
  -        throws SAXException {
  -    } // internalEntityDecl(String,XMLString)
  -
  -    /**
  -     * An external entity declaration.
  -     * 
  -     * @param name     The name of the entity. Parameter entity names start
  -     *                 with '%', whereas the name of a general entity is just
  -     *                 the entity name.
  -     * @param 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.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void externalEntityDecl(String name, 
  -                                   String publicId, String systemId) 
  -        throws SAXException {
  -    } // externalEntityDecl(String,String,String)
  -
  -    /**
  -     * 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 {
  -    } // unparsedEntityDecl(String,String,String,String)
  -
  -    /**
  -     * 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.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void notationDecl(String name, String publicId, String systemId)
  -        throws SAXException {
  -    } // notationDecl(String,String,String)
  -
  -    /**
  -     * The start of a conditional section.
  -     * 
  -     * @param type The type of the conditional section. This value will
  -     *             either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     *
  -     * @see CONDITIONAL_INCLUDE
  -     * @see CONDITIONAL_IGNORE
  +     * Constructs a document parser using the default symbol table and grammar
  +     * pool or the ones specified by the application (through the properties).
        */
  -    public void startConditional(short type) throws SAXException {
  -    } // startConditional(short)
  +    public XMLDocumentParser() {
  +    } // <init>
   
       /**
  -     * The end of a conditional section.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  +     * Constructs a document parser using the specified symbol table.
        */
  -    public void endConditional() throws SAXException {
  -    } // endConditional()
  +    public XMLDocumentParser(SymbolTable symbolTable) {
  +        super(symbolTable);
  +    } // <init>(SymbolTable)
  +
  +    /**
  +     * Constructs a document parser using the specified symbol table and
  +     * grammar pool.
  +     */
  +    public XMLDocumentParser(SymbolTable symbolTable,
  +                             GrammarPool grammarPool) {
  +        super(symbolTable);
  +
  +        final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
  +        fGrammarPool = new GrammarPool();
  +        fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +    }
  +
  +    /**
  +     * Initialize the parser with all the components specified via the
  +     * properties plus any missing ones. This method MUST be called before
  +     * parsing. It is not called from the constructor though, so that the
  +     * application can pass in any components it wants by presetting the
  +     * relevant property.
  +     */
  +    public void initialize() {
  +        super.initialize();
  +
  +        // 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 missing components
  +        final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
  +        fGrammarPool = (GrammarPool) fProperties.get(GRAMMAR_POOL);
  +        if (fGrammarPool == null) {
  +            fGrammarPool = new GrammarPool();
  +            fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +        }
  +
  +        final String DOCUMENT_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
  +        fScanner = (XMLDocumentScanner) fProperties.get(DOCUMENT_SCANNER);
  +        if (fScanner == null) {
  +            fScanner = createDocumentScanner();
  +            fProperties.put(DOCUMENT_SCANNER, fScanner);
  +        }
  +        fComponents.add(fScanner);
  +
  +        final String DTD_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
  +        fDTDScanner = (XMLDTDScanner) fProperties.get(DTD_SCANNER);
  +        if (fDTDScanner == null) {
  +            fDTDScanner = createDTDScanner();
  +            fProperties.put(DTD_SCANNER, fDTDScanner);
  +        }
  +        fComponents.add(fDTDScanner);
  +
  +        final String VALIDATOR = Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATOR_PROPERTY;
  +        fValidator = (XMLValidator) fProperties.get(VALIDATOR);
  +        if (fValidator == null) {
  +            fValidator = createValidator();
  +            fProperties.put(VALIDATOR, fValidator);
  +        }
  +        fComponents.add(fValidator);
  +        
  +        final String DATATYPE_VALIDATOR_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
  +        fDatatypeValidatorFactory = (DatatypeValidatorFactory)
  +            fProperties.get(DATATYPE_VALIDATOR_FACTORY);
  +        if (fDatatypeValidatorFactory == null) {
  +            fDatatypeValidatorFactory = createDatatypeValidatorFactory();
  +            fProperties.put(DATATYPE_VALIDATOR_FACTORY,
  +                            fDatatypeValidatorFactory);
  +        }
   
  -    /**
  -     * The end of the DTD.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endDTD() throws SAXException {
  -    } // endDTD()
  +    } // initialize()
   
       //
  -    // XMLDTDContentModelHandler methods
  +    // XMLParser methods
       //
  -
  -    /**
  -     * The start of a content model. Depending on the type of the content
  -     * model, specific methods may be called between the call to the
  -     * startContentModel method and the call to the endContentModel method.
  -     * 
  -     * @param elementName The name of the element.
  -     * @param type        The content model type.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     *
  -     * @see TYPE_EMPTY
  -     * @see TYPE_ANY
  -     * @see TYPE_MIXED
  -     * @see TYPE_CHILDREN
  -     */
  -    public void startContentModel(String elementName, short type)
  -        throws SAXException {
  -    } // startContentModel(String,short)
  -
  -    /**
  -     * A referenced element in a mixed content model. If the mixed content 
  -     * model only allows text content, then this method will not be called
  -     * for that model. However, if this method is called for a mixed
  -     * content model, then the zero or more occurrence count is implied.
  -     * <p>
  -     * <strong>Note:</strong> This method is only called after a call to 
  -     * the startContentModel method where the type is TYPE_MIXED.
  -     * 
  -     * @param elementName The name of the referenced element. 
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     *
  -     * @see TYPE_MIXED
  -     */
  -    public void mixedElement(String elementName) throws SAXException {
  -    } // mixedElement(elementName)
  -
  -    /**
  -     * The start of a children group.
  -     * <p>
  -     * <strong>Note:</strong> This method is only called after a call to
  -     * the startContentModel method where the type is TYPE_CHILDREN.
  -     * <p>
  -     * <strong>Note:</strong> Children groups can be nested and have
  -     * associated occurrence counts.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     *
  -     * @see TYPE_CHILDREN
  -     */
  -    public void childrenStartGroup() throws SAXException {
  -    } // childrenStartGroup()
   
  -    /**
  -     * A referenced element in a children content model.
  -     * 
  -     * @param elementName The name of the referenced element.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     *
  -     * @see TYPE_CHILDREN
  -     */
  -    public void childrenElement(String elementName) throws SAXException {
  -    } // childrenElement(String)
  -
  -    /**
  -     * The separator between choices or sequences of a children content
  -     * model.
  -     * <p>
  -     * <strong>Note:</strong> This method is only called after a call to
  -     * the startContentModel method where the type is TYPE_CHILDREN.
  -     * 
  -     * @param separator The type of children separator.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     *
  -     * @see SEPARATOR_CHOICE
  -     * @see SEPARATOR_SEQUENCE
  -     * @see TYPE_CHILDREN
  -     */
  -    public void childrenSeparator(short separator) throws SAXException {
  -    } // childrenSeparator(short)
  -
  -    /**
  -     * The occurrence count for a child in a children content model.
  -     * <p>
  -     * <strong>Note:</strong> This method is only called after a call to
  -     * the startContentModel method where the type is TYPE_CHILDREN.
  -     * 
  -     * @param occurrence The occurrence count for the last children element
  -     *                   or children group.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     *
  -     * @see OCCURS_ZERO_OR_ONE
  -     * @see OCCURS_ZERO_OR_MORE
  -     * @see OCCURS_ONE_OR_MORE
  -     * @see TYPE_CHILDREN
  -     */
  -    public void childrenOccurrence(short occurrence) throws SAXException {
  -    } // childrenOccurrence(short)
  -
  -    /**
  -     * The end of a children group.
  -     * <p>
  -     * <strong>Note:</strong> This method is only called after a call to
  -     * the startContentModel method where the type is TYPE_CHILDREN.
  +    /** 
  +     * Reset all components before parsing. 
        *
  -     * @see TYPE_CHILDREN
  +     * @throws SAXException Thrown if an error occurs during initialization.
        */
  -    public void childrenEndGroup() throws SAXException {
  -    } // childrenEndGroup()
  +    protected void reset() throws SAXException {
   
  -    /**
  -     * The end of a content model.
  -     *
  -     * @throws SAXException Thrown by handler to signal an error.
  -     */
  -    public void endContentModel() throws SAXException {
  -    } // endContentModel()
  +        // 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);
  +
  +        // the following will reset every component
  +        super.reset();
  +
  +    } // reset()
  +
  +    //
  +    // XMLReader methods
  +    //
  +
  +    /**
  +     * 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.");
  +        }
  +        else if (fNeedInitialize) {
  +            initialize();
  +        }
  +
  +        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)
  +
  +    //
  +    // 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
  
  
  
  1.1.2.20  +13 -1     xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLParser.java
  
  Index: XMLParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLParser.java,v
  retrieving revision 1.1.2.19
  retrieving revision 1.1.2.20
  diff -u -r1.1.2.19 -r1.1.2.20
  --- XMLParser.java	2001/02/13 22:51:26	1.1.2.19
  +++ XMLParser.java	2001/02/14 02:10:31	1.1.2.20
  @@ -107,7 +107,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLParser.java,v 1.1.2.19 2001/02/13 22:51:26 lehors Exp $
  + * @version $Id: XMLParser.java,v 1.1.2.20 2001/02/14 02:10:31 lehors Exp $
    */
   public abstract class XMLParser
       implements XMLComponentManager {
  @@ -184,6 +184,18 @@
           fNeedInitialize = true;
   
       } // <init>
  +
  +    /**
  +     * Constructs a document parser using the specified symbol table
  +     * and a default grammar pool.
  +     *
  +     */
  +    protected XMLParser(SymbolTable symbolTable) {
  +        this();
  +        final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  +        fSymbolTable = new SymbolTable();
  +        fProperties.put(SYMBOL_TABLE, fSymbolTable);
  +    } // <init>(SymbolTable)
   
       /**
        * Initialize the parser with all the components specified via the
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +677 -0    xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractXMLDocumentParser.java