You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by pi...@locus.apache.org on 2000/02/27 18:47:14 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/components/parser Parser.java XercesParser.java

pier        00/02/27 09:47:14

  Modified:    src/org/apache/cocoon/components/parser Tag: xml-cocoon2
                        Parser.java XercesParser.java
  Log:
  [Cocoon 2.0] DOM Level 2 support by the Parser.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +3 -2      xml-cocoon/src/org/apache/cocoon/components/parser/Attic/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/parser/Attic/Parser.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Parser.java	2000/02/27 01:33:06	1.1.2.2
  +++ Parser.java	2000/02/27 17:47:13	1.1.2.3
  @@ -10,6 +10,7 @@
   import java.io.IOException;
   import org.apache.arch.Component;
   import org.apache.cocoon.xml.XMLProducer;
  +import org.apache.cocoon.xml.util.DOMFactory;
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   
  @@ -17,9 +18,9 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 01:33:06 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/27 17:47:13 $
    */
  -public interface Parser extends Component, XMLProducer {
  +public interface Parser extends Component, XMLProducer, DOMFactory {
       
       public void parse(InputSource in)
       throws SAXException, IOException;
  
  
  
  1.1.2.3   +36 -2     xml-cocoon/src/org/apache/cocoon/components/parser/Attic/XercesParser.java
  
  Index: XercesParser.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/parser/Attic/XercesParser.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- XercesParser.java	2000/02/27 01:33:06	1.1.2.2
  +++ XercesParser.java	2000/02/27 17:47:13	1.1.2.3
  @@ -9,20 +9,24 @@
   
   import java.io.IOException;
   import org.apache.cocoon.xml.AbstractXMLProducer;
  +import org.apache.cocoon.xml.util.DOMFactory;
  +import org.apache.xerces.dom.DocumentImpl;
  +import org.apache.xerces.dom.DocumentTypeImpl;
   import org.apache.xerces.parsers.SAXParser;
   import org.xml.sax.ErrorHandler;
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   import org.xml.sax.SAXParseException;
  +import org.w3c.dom.Document;
   
   /**
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 01:33:06 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/27 17:47:13 $
    */
   public class XercesParser extends AbstractXMLProducer
  -implements Parser, ErrorHandler {
  +implements Parser, ErrorHandler, DOMFactory {
       
       public void parse(InputSource in)
       throws SAXException, IOException {
  @@ -36,6 +40,36 @@
           p.parse(in);
       }
           
  +    /** 
  +     * Create a new Document object.
  +     */
  +    public Document newDocument() {
  +        return(newDocument(null,null,null));
  +    }
  +
  +    /** 
  +     * Create a new Document object with a specified DOCTYPE.
  +     */
  +    public Document newDocument(String name) {
  +        return(newDocument(name,null,null));
  +    }
  +
  +    /** 
  +     * Create a new Document object with a specified DOCTYPE, public ID and 
  +     * system ID.
  +     */
  +    public Document newDocument(String name, String pub, String sys) {
  +        DocumentImpl doc=new DocumentImpl();
  +        if ((pub!=null)||(sys!=null)) {
  +            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name,pub,sys);
  +            doc.appendChild(dtd);
  +        } else if (name!=null) {
  +            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name);
  +            doc.appendChild(dtd);
  +        }
  +        return(doc);
  +    }
  +
       /**
        * Receive notification of a recoverable error.
        */