stephan 2002/07/24 09:46:08 Modified: src/scratchpad/src/org/apache/cocoon/generation TextParserGenerator.java src/scratchpad/src/org/apache/cocoon/transformation TextFragmentParserTransformer.java Log: The TextParserGenerator produce now a 'error' document. The getLogger() method returns null, so I implemented direct the interface LogEnabled Revision Changes Path 1.3 +17 -12 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/TextParserGenerator.java Index: TextParserGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/TextParserGenerator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TextParserGenerator.java 26 Jun 2002 15:03:04 -0000 1.2 +++ TextParserGenerator.java 24 Jul 2002 16:46:08 -0000 1.3 @@ -30,6 +30,7 @@ import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.generation.ComposerGenerator; import org.apache.cocoon.util.HashUtil; +import org.apache.cocoon.xml.EmbeddedXMLPipe; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; @@ -66,7 +67,7 @@ * @version CVS $Id$ */ public class TextParserGenerator extends ComposerGenerator - implements CacheableProcessingComponent { + implements CacheableProcessingComponent, LogEnabled { /** The URI of the parser exception */ public final static String URI = "http://chaperon.sourceforge.net/schema/parser-exception/1.0"; @@ -154,7 +155,7 @@ if ((entry==null) || (entry.getValidity()==null) || (!entry.getValidity().isValid(this.grammarSource.getValidity()))) { - getLogger().debug("(Re)building the parsertable from '"+this.grammarSource.getSystemId()+"'"); + this.avalonlogger.debug("(Re)building the parsertable from '"+this.grammarSource.getSystemId()+"'"); SAXGrammarGenerator grammargenerator = new SAXGrammarGenerator(); SourceUtil.toSAX(this.grammarSource, grammargenerator, this.manager); @@ -162,7 +163,7 @@ Grammar grammar = grammargenerator.getGrammar(); SyntaxErrorException see = grammar.validate(); if (see!=null) { - getLogger().error("Grammar is not correct", see); + this.avalonlogger.error("Grammar is not correct", see); throw new ProcessingException("Grammar is not correct", see); } @@ -172,23 +173,23 @@ store.store(this.grammarSource.getSystemId(), new ParserTableEntry(this.parsertable, this.grammarSource.getValidity())); } else { - getLogger().debug("Getting parsertable from store for '"+this.grammarSource.getSystemId()+"'"); + this.avalonlogger.debug("Getting parsertable from store for '"+this.grammarSource.getSystemId()+"'"); this.parsertable = entry.getParserTable(); } this.inputSource = resolver.resolveURI(src); } catch (ParameterException pe) { - getLogger().error("Error during retrieving a parameter", pe); + this.avalonlogger.error("Error during retrieving a parameter", pe); throw new ProcessingException("Error during retrieving a parameter", pe); } catch (SourceException se) { - getLogger().error("Error during resolving of '" + src + "'.", se); + this.avalonlogger.error("Error during resolving of '" + src + "'.", se); throw new ProcessingException("Error during resolving of '" + src + "'.", se); } catch (ComponentException ce) { - getLogger().error("Could not lookup for component", ce); + this.avalonlogger.error("Could not lookup for component", ce); throw new ProcessingException("Could not lookup for component", ce); } catch (SyntaxErrorException see) { - getLogger().error("Grammar is not correct", see); + this.avalonlogger.error("Grammar is not correct", see); throw new ProcessingException("Grammar is not correct", see); } finally { if (store!=null) @@ -235,10 +236,10 @@ this.includeIgnorableTokens, false); queue.fireEvents(adapter); } catch (ParserException pe) { - getLogger().error("Could not parse source", pe); - throw new ProcessingException("Could not parse source", pe); + this.avalonlogger.error("Document ist not valid", pe); + toSAX(super.contentHandler, pe); } catch (SourceException se) { - getLogger().error("Could not get inputstream from source", se); + this.avalonlogger.error("Could not get inputstream from source", se); throw new ProcessingException("Could not get inputstream from source", se); } } @@ -252,6 +253,8 @@ */ public void toSAX(ContentHandler handler, ParserException pe) throws SAXException { handler.startDocument(); + + handler.startPrefixMapping("", URI); AttributesImpl attributes = new AttributesImpl(); @@ -272,6 +275,8 @@ } handler.endElement(URI, ELEMENT, ELEMENT); + + handler.endPrefixMapping(""); handler.endDocument(); } 1.3 +14 -10 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/TextFragmentParserTransformer.java Index: TextFragmentParserTransformer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/TextFragmentParserTransformer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TextFragmentParserTransformer.java 26 Jun 2002 15:03:04 -0000 1.2 +++ TextFragmentParserTransformer.java 24 Jul 2002 16:46:08 -0000 1.3 @@ -64,7 +64,7 @@ * @version CVS $Id$ */ public class TextFragmentParserTransformer extends AbstractTransformer - implements Composable, Recyclable, Disposable, CacheableProcessingComponent { + implements Composable, Recyclable, Disposable, CacheableProcessingComponent, LogEnabled { private static String EXTRACT_URI = "http://chaperon.sourceforge.net/schema/textfragment/1.0"; private static String EXTRACT_ELEMENT = "textfragment"; @@ -177,7 +177,7 @@ if ((entry==null) || (entry.getValidity()==null) || (!entry.getValidity().isValid(this.grammarSource.getValidity()))) { - getLogger().debug("(Re)building the parsertable from '"+this.grammarSource.getSystemId()+"'"); + this.avalonlogger.debug("(Re)building the parsertable from '"+this.grammarSource.getSystemId()+"'"); SAXGrammarGenerator grammargenerator = new SAXGrammarGenerator(); SourceUtil.toSAX(this.grammarSource, grammargenerator, this.manager); @@ -185,7 +185,7 @@ Grammar grammar = grammargenerator.getGrammar(); SyntaxErrorException see = grammar.validate(); if (see!=null) { - getLogger().error("Grammar is not correct", see); + this.avalonlogger.error("Grammar is not correct", see); throw new ProcessingException("Grammar is not correct", see); } @@ -195,21 +195,21 @@ store.store(this.grammarSource.getSystemId(), new ParserTableEntry(this.parsertable, this.grammarSource.getValidity())); } else { - getLogger().debug("Getting parsertable from store for '"+this.grammarSource.getSystemId()+"'"); + this.avalonlogger.debug("Getting parsertable from store for '"+this.grammarSource.getSystemId()+"'"); this.parsertable = entry.getParserTable(); } } catch (ParameterException pe) { - getLogger().error("Error during retrieving a parameter", pe); + this.avalonlogger.error("Error during retrieving a parameter", pe); throw new ProcessingException("Error during retrieving a parameter", pe); } catch (SourceException se) { - getLogger().error("Error during resolving of '" + src + "'.", se); + this.avalonlogger.error("Error during resolving of '" + src + "'.", se); throw new ProcessingException("Error during resolving of '" + src + "'.", se); } catch (ComponentException ce) { - getLogger().error("Could not lookup for component", ce); + this.avalonlogger.error("Could not lookup for component", ce); throw new ProcessingException("Could not lookup for component", ce); } catch (SyntaxErrorException see) { - getLogger().error("Grammar is not correct", see); + this.avalonlogger.error("Grammar is not correct", see); throw new ProcessingException("Grammar is not correct", see); } finally { if (store!=null) @@ -293,7 +293,7 @@ //adapter.enableLogging(getLogger()); queue.fireEvents(adapter); } catch (ParserException pe) { - getLogger().error("Document ist not valid", pe); + this.avalonlogger.error("Document ist not valid", pe); EmbeddedXMLPipe pipe = new EmbeddedXMLPipe(super.contentHandler); toSAX(pipe, pe); } @@ -327,6 +327,8 @@ public void toSAX(ContentHandler handler, ParserException pe) throws SAXException { handler.startDocument(); + handler.startPrefixMapping("", URI); + AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute(URI, MESSAGE_ATTRIBUTE, MESSAGE_ATTRIBUTE, @@ -346,6 +348,8 @@ } handler.endElement(URI, ELEMENT, ELEMENT); + + handler.endPrefixMapping(""); handler.endDocument(); }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]