stephan 2003/04/09 05:17:21
Modified: src/java/org/apache/cocoon/components/source SourceUtil.java src/blocks/chaperon/java/org/apache/cocoon/transformation LexicalTransformer.java ParserTransformer.java PatternTransformer.java Log: Allow to serialize sources outside of cocoon. Revision Changes Path 1.5 +19 -3 cocoon-2.1/src/java/org/apache/cocoon/components/source/SourceUtil.java Index: SourceUtil.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/source/SourceUtil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SourceUtil.java 24 Mar 2003 14:33:54 -0000 1.4 +++ SourceUtil.java 9 Apr 2003 12:17:20 -0000 1.5 @@ -122,7 +122,8 @@ static public void toSAX( Source source, ContentHandler handler) throws SAXException, IOException, ProcessingException { - toSAX(source, null, handler); + toSAX(CocoonComponentManager.getSitemapComponentManager(), + source, null, handler); } /** @@ -137,7 +138,22 @@ String mimeTypeHint, ContentHandler handler) throws SAXException, IOException, ProcessingException { - ComponentManager manager = CocoonComponentManager.getSitemapComponentManager(); + toSAX(CocoonComponentManager.getSitemapComponentManager(), + source, mimeTypeHint, handler); + } + + /** + * Generates SAX events from the given source + * <b>NOTE</b> : if the implementation can produce lexical events, care should be taken + * that <code>handler</code> can actually + * directly implement the LexicalHandler interface! + * @param source the data + * @throws ProcessingException if no suitable converter is found + */ + static public void toSAX( ComponentManager manager, Source source, + String mimeTypeHint, + ContentHandler handler) + throws SAXException, IOException, ProcessingException { if ( source instanceof XMLizable ) { ((XMLizable)source).toSAX( handler ); } else { 1.4 +2 -2 cocoon-2.1/src/blocks/chaperon/java/org/apache/cocoon/transformation/LexicalTransformer.java Index: LexicalTransformer.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/chaperon/java/org/apache/cocoon/transformation/LexicalTransformer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- LexicalTransformer.java 1 Apr 2003 16:33:49 -0000 1.3 +++ LexicalTransformer.java 9 Apr 2003 12:17:20 -0000 1.4 @@ -217,7 +217,7 @@ this.lexiconSource.getURI()+ "' not found"); } - SourceUtil.toSAX(this.lexiconSource, confighandler); + SourceUtil.toSAX(this.manager, this.lexiconSource, null, confighandler); Configuration config = confighandler.getConfiguration(); Lexicon lexicon = LexiconFactory.createLexicon(config); 1.4 +2 -2 cocoon-2.1/src/blocks/chaperon/java/org/apache/cocoon/transformation/ParserTransformer.java Index: ParserTransformer.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/chaperon/java/org/apache/cocoon/transformation/ParserTransformer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ParserTransformer.java 1 Apr 2003 16:33:49 -0000 1.3 +++ ParserTransformer.java 9 Apr 2003 12:17:20 -0000 1.4 @@ -221,7 +221,7 @@ this.grammarSource.getURI()+ "' not found"); } - SourceUtil.toSAX(this.grammarSource, confighandler); + SourceUtil.toSAX(this.manager, this.grammarSource, null, confighandler); Configuration config = confighandler.getConfiguration(); Grammar grammar = GrammarFactory.createGrammar(config); 1.3 +2 -2 cocoon-2.1/src/blocks/chaperon/java/org/apache/cocoon/transformation/PatternTransformer.java Index: PatternTransformer.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/chaperon/java/org/apache/cocoon/transformation/PatternTransformer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PatternTransformer.java 19 Mar 2003 15:42:14 -0000 1.2 +++ PatternTransformer.java 9 Apr 2003 12:17:20 -0000 1.3 @@ -208,7 +208,7 @@ this.lexiconSource.getURI()+ "' not found"); } - SourceUtil.toSAX(this.lexiconSource, confighandler); + SourceUtil.toSAX(this.manager, this.lexiconSource, null, confighandler); Configuration config = confighandler.getConfiguration(); Lexicon lexicon = LexiconFactory.createLexicon(config);