cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Marcano <ro...@promca.com>
Subject [Fwd: Added EntityResolver parameter for xsp utility parser]
Date Fri, 05 Jan 2001 19:14:06 GMT
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();
      }


Mime
View raw message