Return-Path: Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 42412 invoked from network); 10 Feb 2000 13:13:54 -0000 Received: from taz.hyperreal.org (HELO hyperreal.org) (209.133.83.16) by locus.apache.org with SMTP; 10 Feb 2000 13:13:54 -0000 Received: (qmail 21695 invoked by uid 2016); 10 Feb 2000 13:13:53 -0000 Delivered-To: apcore-xml-cocoon-cvs@apache.org Received: (qmail 21693 invoked from network); 10 Feb 2000 13:13:53 -0000 Received: from locus.apache.org (63.211.145.10) by taz.hyperreal.org with SMTP; 10 Feb 2000 13:13:53 -0000 Received: (qmail 42406 invoked by uid 1023); 10 Feb 2000 13:13:52 -0000 Date: 10 Feb 2000 13:13:52 -0000 Message-ID: <20000210131352.42405.qmail@locus.apache.org> From: pier@locus.apache.org To: xml-cocoon-cvs@apache.org Subject: cvs commit: xml-cocoon/src/org/apache/cocoon/parsers XercesFactory.java pier 00/02/10 05:13:52 Modified: src/org/apache/cocoon/parsers Tag: xml-cocoon2-alpha0 XercesFactory.java Log: Updated the XercesFactory to be SAX 2.0 compliant. Revision Changes Path No revision No revision 1.1.2.2 +29 -14 xml-cocoon/src/org/apache/cocoon/parsers/Attic/XercesFactory.java Index: XercesFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/parsers/Attic/XercesFactory.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- XercesFactory.java 2000/02/07 15:35:40 1.1.2.1 +++ XercesFactory.java 2000/02/10 13:13:51 1.1.2.2 @@ -8,14 +8,12 @@ package org.apache.cocoon.parsers; import java.io.IOException; -import org.apache.cocoon.XMLProducer; -import org.apache.cocoon.XMLConsumer; +import org.apache.cocoon.sax.XMLProducer; +import org.apache.cocoon.sax.XMLConsumer; import org.apache.cocoon.dom.DocumentFactory; -import org.apache.cocoon.framework.Configurable; import org.apache.cocoon.framework.Configurations; import org.apache.cocoon.framework.ConfigurationException; import org.apache.xerces.dom.DocumentImpl; -import org.apache.xerces.dom.DocumentTypeImpl; import org.apache.xerces.parsers.SAXParser; import org.apache.xerces.utils.StringPool; import org.xml.sax.ErrorHandler; @@ -23,6 +21,7 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; /** * The Apache Xerces parser and document factory. @@ -31,7 +30,7 @@ * Exoffice Technologies, INC. * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/02/07 15:35:40 $ + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/10 13:13:51 $ */ public class XercesFactory implements ParserFactory, DocumentFactory, ErrorHandler { @@ -65,20 +64,29 @@ return(p); } - /** - * Return a new Document instance. + /** + * Create a new Document object. */ public Document newDocument() { - return(new DocumentImpl()); + return(this.newDocument(null)); } - /** - * Return a new Document instance. + /** + * Create a new Document object with a specified DOCTYPE. */ public Document newDocument(String name) { - if (name==null) return(this.newDocument()); + return(this.newDocument(null,null,null)); + } + + /** + * Create a new Document object with a specified DOCTYPE, public ID and + * system ID. + */ + public Document newDocument(String name, String publicId, String systemId) { + if (name==null) return(new DocumentImpl()); DocumentImpl doc=new DocumentImpl(); - DocumentTypeImpl doctype=new DocumentTypeImpl(doc,name); + DocumentType typ=doc.createDocumentType(name,publicId,systemId,""); + doc.appendChild(typ); return(doc); } @@ -181,12 +189,19 @@ public void produce(XMLConsumer consumer) throws IOException, SAXException { this.parser.setFeature( - "http://xml.org/sax/features/validation",this.validationFlag); + "http://xml.org/sax/features/validation", + this.validationFlag); this.parser.setFeature( "http://apache.org/xml/features/validation/dynamic", this.dynamicValidationFlag); + this.parser.setProperty( + "http://xml.org/sax/properties/lexical-handler", + consumer); + this.parser.setFeature( + "http://xml.org/sax/features/namespaces", + true); this.parser.setErrorHandler(this.errorHandler); - this.parser.setDocumentHandler(consumer); + this.parser.setContentHandler(consumer); this.parser.parse(this.inputSource); } }