You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Robert Marcano <ro...@promca.com> on 2001/01/05 20:14:06 UTC

[Fwd: Added EntityResolver parameter for xsp utility parser]

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();
      }


AW: [C2]: Patch for DOMBuilder and namespace attributes

Posted by Carsten Ziegeler <cz...@sundn.de>.
> 
> Patch applied -- cross check it for me?
> 
Cross checked - everything alright

Carsten


Re: [C2]: Patch for DOMBuilder and namespace attributes

Posted by Paul Russell <pa...@luminas.co.uk>.
* Carsten Ziegeler (cziegeler@sundn.de) wrote :
> attached is a patch for the DOMBuilder which ignores namespace
> attributes.
> Some days ago the feature "http://xml.org/sax/features/namespace-prefixes"
> of xerces was set to true. Now xerces also includes namespace
> attributes in the sax events. This caused the DOMBuilder to throw
> SAXException for these attributes. 
> This patch fixes this.

Patch applied -- cross check it for me?

Thanks Carsten,


Paul

-- 
Paul Russell                                 Email:   paul@luminas.co.uk
Technical Director                             Tel:  +44 (0)20 8553 6622
Luminas Internet Applications                  Fax:  +44 (0)870 28 47489
This is not an official statement or order.    Web:    www.luminas.co.uk

[C2]: Patch for DOMBuilder and namespace attributes

Posted by Carsten Ziegeler <cz...@sundn.de>.
Hello,

attached is a patch for the DOMBuilder which ignores namespace
attributes.
Some days ago the feature "http://xml.org/sax/features/namespace-prefixes"
of xerces was set to true. Now xerces also includes namespace
attributes in the sax events. This caused the DOMBuilder to throw
SAXException for these attributes. 
This patch fixes this.


Carsten 

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de 
================================================================

Re: Status of XMLCompiler

Posted by Paul Russell <pa...@luminas.co.uk>.
* Carsten Ziegeler (cziegeler@sundn.de) wrote :
> a long time ago, Stefano posted an XMLCompiler to this list.
> Does someone of you know, what the current status of it is?

I'm not sure, I must admit.

> Wouldn't it be good to integrate the XMLCompiler/XMLInterpreter 
> into C2? (Perhaps for caching?)

The trouble is that the system was optimised for the reading phase of
the optimisation, which may not be what we want if the sax streams are
being cached on the fly. One option might be to have pluggable
encoder/decoders to enable us to store SAX events in conventional avalon
stream stores. That way, when it's something which is going to be viewed
very often, we could use Stefano's XMLCompiler and XMLInterpreter which
should give us maximal performance when retrieving from the cache, and
when the thing is more balanced, we could use something else? Does that
work for you guys, or do you have other thoughts of how to cache SAX
events?


Paul
-- 
Paul Russell                                 Email:   paul@luminas.co.uk
Technical Director                             Tel:  +44 (0)20 8553 6622
Luminas Internet Applications                  Fax:  +44 (0)870 28 47489
This is not an official statement or order.    Web:    www.luminas.co.uk

Status of XMLCompiler

Posted by Carsten Ziegeler <cz...@sundn.de>.
Hi,

a long time ago, Stefano posted an XMLCompiler to this list.

Does someone of you know, what the current status of it is?

Wouldn't it be good to integrate the XMLCompiler/XMLInterpreter 
into C2? (Perhaps for caching?)

Regards
Carsten Ziegeler

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de 
================================================================