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 82502 invoked from network); 5 Jan 2001 19:12:14 -0000 Received: from rs2s3.datacenter.cha.cantv.net (200.44.32.52) by h31.sny.collab.net with SMTP; 5 Jan 2001 19:12:14 -0000 Received: from mailgate ([200.11.252.248]) by rs2s3.datacenter.cha.cantv.net (8.10.2/8.10.2/2.0) with SMTP id f05JBwD13763 for ; Fri, 5 Jan 2001 15:11:58 -0400 Received: from [192.168.1.107] by (MailGate 3.3.153) with SMTP; Fri, 5 Jan 2001 15:11:48 -0400 Message-ID: <3A561CFE.6030102@promca.com> Date: Fri, 05 Jan 2001 15:14:06 -0400 From: Robert Marcano User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) Gecko/20001108 Netscape6/6.0 X-Accept-Language: en MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: [Fwd: Added EntityResolver parameter for xsp utility parser] Content-Type: multipart/mixed; boundary="------------080005040100030509020807" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N --------------080005040100030509020807 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I needed a way to set the EntityResolver to the parser that can be used in a XSP page, so i added a new parameter in a new method in org.apache.cocoon.parser.Parser in order to be able to use a custon EntityResolver. I think that it may be usefull to more people so I am attaching the diffs ------------------------------------------------------------- cvs server: Diffing . Index: AbstractParser.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/parser/AbstractParser.java,v retrieving revision 1.4 diff -c -r1.4 AbstractParser.java *** AbstractParser.java 2000/02/13 18:29:28 1.4 --- AbstractParser.java 2001/01/05 18:44:25 *************** *** 59,64 **** --- 59,65 ---- import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; + import org.xml.sax.EntityResolver; /** * This class implements all the common methods used by the XML parsers. *************** *** 80,88 **** * given entity resolver. */ public Document parse(InputSource input) throws SAXException, IOException { ! return parse(input, validation); } /** * Receive notification of a recoverable error. * --- 81,113 ---- * given entity resolver. */ public Document parse(InputSource input) throws SAXException, IOException { ! return parse(input, null, validation); } + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ + public Document parse(InputSource input, EntityResolver resolver) throws SAXException, IOException { + return parse(input, resolver, validation); + } + + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ + public Document parse(InputSource input, boolean validate) throws SAXException, IOException { + return parse(input, null, validate); + } + + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ + public Document parse(InputSource input, EntityResolver resolver, boolean validate) throws SAXException, IOException { + return parse(input, resolver, validate); + } + /** * Receive notification of a recoverable error. * Index: Parser.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/parser/Parser.java,v retrieving revision 1.7 diff -c -r1.7 Parser.java *** Parser.java 2000/02/13 18:29:29 1.7 --- Parser.java 2001/01/05 18:44:25 *************** *** 76,83 **** --- 76,95 ---- * Creates a DOM tree parsing the given input source and using the * given entity resolver. */ + public Document parse(InputSource input, EntityResolver resolver) throws SAXException, IOException; + + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ public Document parse(InputSource input, boolean validate) throws SAXException, IOException; + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ + public Document parse(InputSource input, EntityResolver resolver, boolean validate) throws SAXException, IOException; + /** * Creates an empty DOM tree. */ Index: SunXMLParser.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/parser/SunXMLParser.java,v retrieving revision 1.6 diff -c -r1.6 SunXMLParser.java *** SunXMLParser.java 2000/04/04 13:43:57 1.6 --- SunXMLParser.java 2001/01/05 18:44:25 *************** *** 70,76 **** /** * Creates a DOM tree parsing the given input source. */ ! public Document parse(InputSource input, boolean validate) throws SAXException, IOException { org.xml.sax.Parser parser; XmlDocumentBuilder builder; --- 70,76 ---- /** * Creates a DOM tree parsing the given input source. */ ! public Document parse(InputSource input, EntityResolver resolver, boolean validate) throws SAXException, IOException { org.xml.sax.Parser parser; XmlDocumentBuilder builder; *************** *** 82,90 **** builder = new XmlDocumentBuilder(); builder.setParser(parser); ! parser.setErrorHandler(this); parser.parse(input); ! return builder.getDocument(); } /** --- 82,92 ---- builder = new XmlDocumentBuilder(); builder.setParser(parser); ! parser.setErrorHandler(this); ! if (resolver != null) ! parser.setEntityResolver(resolver); parser.parse(input); ! return builder.getDocument(); } /** Index: XercesParser.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/parser/XercesParser.java,v retrieving revision 1.10 diff -c -r1.10 XercesParser.java *** XercesParser.java 2000/07/21 23:39:55 1.10 --- XercesParser.java 2001/01/05 18:44:27 *************** *** 71,77 **** /** * Creates a DOM tree parsing the given input source. */ ! public Document parse(InputSource input, boolean validate) throws SAXException, IOException { DOMParser parser = new DOMParser(); parser.setErrorHandler(this); parser.setFeature("http://xml.org/sax/features/validation", validate); --- 71,77 ---- /** * Creates a DOM tree parsing the given input source. */ ! public Document parse(InputSource input, EntityResolver resolver, boolean validate) throws SAXException, IOException { DOMParser parser = new DOMParser(); parser.setErrorHandler(this); parser.setFeature("http://xml.org/sax/features/validation", validate); *************** *** 81,86 **** --- 81,88 ---- parser.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes", false); parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", true); parser.setFeature("http://apache.org/xml/features/allow-java-encodings", true); + if (resolver != null) + parser.setEntityResolver(resolver); parser.parse(resolveSystemId(input)); return parser.getDocument(); } --------------080005040100030509020807 Content-Type: text/plain; name="diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diff.txt" cvs server: Diffing . Index: AbstractParser.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/parser/AbstractParser.java,v retrieving revision 1.4 diff -c -r1.4 AbstractParser.java *** AbstractParser.java 2000/02/13 18:29:28 1.4 --- AbstractParser.java 2001/01/05 18:44:25 *************** *** 59,64 **** --- 59,65 ---- import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; + import org.xml.sax.EntityResolver; /** * This class implements all the common methods used by the XML parsers. *************** *** 80,88 **** * given entity resolver. */ public Document parse(InputSource input) throws SAXException, IOException { ! return parse(input, validation); } /** * Receive notification of a recoverable error. * --- 81,113 ---- * given entity resolver. */ public Document parse(InputSource input) throws SAXException, IOException { ! return parse(input, null, validation); } + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ + public Document parse(InputSource input, EntityResolver resolver) throws SAXException, IOException { + return parse(input, resolver, validation); + } + + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ + public Document parse(InputSource input, boolean validate) throws SAXException, IOException { + return parse(input, null, validate); + } + + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ + public Document parse(InputSource input, EntityResolver resolver, boolean validate) throws SAXException, IOException { + return parse(input, resolver, validate); + } + /** * Receive notification of a recoverable error. * Index: Parser.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/parser/Parser.java,v retrieving revision 1.7 diff -c -r1.7 Parser.java *** Parser.java 2000/02/13 18:29:29 1.7 --- Parser.java 2001/01/05 18:44:25 *************** *** 76,83 **** --- 76,95 ---- * Creates a DOM tree parsing the given input source and using the * given entity resolver. */ + public Document parse(InputSource input, EntityResolver resolver) throws SAXException, IOException; + + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ public Document parse(InputSource input, boolean validate) throws SAXException, IOException; + /** + * Creates a DOM tree parsing the given input source and using the + * given entity resolver. + */ + public Document parse(InputSource input, EntityResolver resolver, boolean validate) throws SAXException, IOException; + /** * Creates an empty DOM tree. */ Index: SunXMLParser.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/parser/SunXMLParser.java,v retrieving revision 1.6 diff -c -r1.6 SunXMLParser.java *** SunXMLParser.java 2000/04/04 13:43:57 1.6 --- SunXMLParser.java 2001/01/05 18:44:25 *************** *** 70,76 **** /** * Creates a DOM tree parsing the given input source. */ ! public Document parse(InputSource input, boolean validate) throws SAXException, IOException { org.xml.sax.Parser parser; XmlDocumentBuilder builder; --- 70,76 ---- /** * Creates a DOM tree parsing the given input source. */ ! public Document parse(InputSource input, EntityResolver resolver, boolean validate) throws SAXException, IOException { org.xml.sax.Parser parser; XmlDocumentBuilder builder; *************** *** 82,90 **** builder = new XmlDocumentBuilder(); builder.setParser(parser); ! parser.setErrorHandler(this); parser.parse(input); ! return builder.getDocument(); } /** --- 82,92 ---- builder = new XmlDocumentBuilder(); builder.setParser(parser); ! parser.setErrorHandler(this); ! if (resolver != null) ! parser.setEntityResolver(resolver); parser.parse(input); ! return builder.getDocument(); } /** Index: XercesParser.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/parser/XercesParser.java,v retrieving revision 1.10 diff -c -r1.10 XercesParser.java *** XercesParser.java 2000/07/21 23:39:55 1.10 --- XercesParser.java 2001/01/05 18:44:27 *************** *** 71,77 **** /** * Creates a DOM tree parsing the given input source. */ ! public Document parse(InputSource input, boolean validate) throws SAXException, IOException { DOMParser parser = new DOMParser(); parser.setErrorHandler(this); parser.setFeature("http://xml.org/sax/features/validation", validate); --- 71,77 ---- /** * Creates a DOM tree parsing the given input source. */ ! public Document parse(InputSource input, EntityResolver resolver, boolean validate) throws SAXException, IOException { DOMParser parser = new DOMParser(); parser.setErrorHandler(this); parser.setFeature("http://xml.org/sax/features/validation", validate); *************** *** 81,86 **** --- 81,88 ---- parser.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes", false); parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", true); parser.setFeature("http://apache.org/xml/features/allow-java-encodings", true); + if (resolver != null) + parser.setEntityResolver(resolver); parser.parse(resolveSystemId(input)); return parser.getDocument(); } --------------080005040100030509020807--