Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 86150 invoked by uid 500); 3 Feb 2003 19:15:38 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 86141 invoked by uid 500); 3 Feb 2003 19:15:38 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 3 Feb 2003 19:15:37 -0000 Message-ID: <20030203191537.83853.qmail@icarus.apache.org> From: stephan@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/webapp/WEB-INF web.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N stephan 2003/02/03 11:15:36 Modified: lib jars.xml src/blocks/chaperon/samples sitemap.xmap src/blocks/chaperon/samples/grammars wiki.grm src/blocks/chaperon/samples/misc java.css mathexp.xsp samples.xml wiki.xsp src/blocks/chaperon/samples/stylesheets java2html.xsl mathexp2html.xsl wiki2html.xsl src/webapp/WEB-INF web.xml Added: lib/optional chaperon-20030203.jar src/blocks/chaperon/conf chaperon-transformator.xmap chaperon-xmlizer.xconf chaperon-xmlizer.xroles src/blocks/chaperon/java/org/apache/cocoon/transformation LexicalTransformer.java ParserTransformer.java PatternTransformer.java src/blocks/chaperon/java/org/apache/cocoon/xml TextXMLizer.java src/blocks/chaperon/samples/grammars grammar-v20.dtd grm.xgrm grm.xlex java.xgrm java.xlex javadoc.xgrm javadoc.xlex lexicon-v20.dtd mathexp.xgrm mathexp.xlex regex.xgrm regex.xlex src/blocks/chaperon/samples/misc/test Grammar.java PatternProcessor.java src/blocks/chaperon/samples/stylesheets class2html.xsl grm2xgrm.xsl grm2xlex.xsl index4java.xsl mathexp.xsl package2html.xsl remove4class.xsl text4javadoc.xsl text4javadoc2.xsl text4regex.xsl Removed: lib/optional chaperon-1.3-dev.jar src/blocks/chaperon/conf chaperon.generator.xmap chaperon.transformator.xmap src/blocks/chaperon/java/org/apache/cocoon/generation TextParserGenerator.java src/blocks/chaperon/java/org/apache/cocoon/transformation TextFragmentParserTransformer.java src/blocks/chaperon/samples/grammars java.rgrm mathexp.grm rgrm.grm wiki.rgrm src/blocks/chaperon/samples/misc test1.java test2.java src/blocks/chaperon/samples/stylesheets parsefragment.xsl rgrm2grm.xsl Log: Add new version of the chaperon text parser components. Revision Changes Path 1.73 +2 -2 xml-cocoon2/lib/jars.xml Index: jars.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/lib/jars.xml,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- jars.xml 2 Feb 2003 04:34:33 -0000 1.72 +++ jars.xml 3 Feb 2003 19:15:32 -0000 1.73 @@ -494,8 +494,8 @@ chaperon is parser which could parse text files, and convert those to XML files. - TextParserGenerator and TextFragmentParserTransformer - optional/chaperon-1.3-dev.jar + Chaperon block + optional/chaperon-20030203.jar http://chaperon.sourceforge.net 1.1 xml-cocoon2/lib/optional/chaperon-20030203.jar <> 1.1 xml-cocoon2/src/blocks/chaperon/conf/chaperon-transformator.xmap Index: chaperon-transformator.xmap =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/conf/chaperon-xmlizer.xconf Index: chaperon-xmlizer.xconf =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/conf/chaperon-xmlizer.xroles Index: chaperon-xmlizer.xroles =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/java/org/apache/cocoon/transformation/LexicalTransformer.java Index: LexicalTransformer.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ package org.apache.cocoon.transformation; import org.apache.avalon.excalibur.pool.Recyclable; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.SAXConfigurationHandler; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.parameters.ParameterException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.components.source.SourceUtil; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.transformation.Transformer; import org.apache.cocoon.xml.EmbeddedXMLPipe; import org.apache.cocoon.xml.XMLConsumer; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; import org.apache.excalibur.source.SourceValidity; import org.apache.excalibur.store.Store; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.ContentHandler; import org.xml.sax.helpers.AttributesImpl; import java.io.IOException; import java.io.Serializable; import java.util.Map; import net.sourceforge.chaperon.adapter.avalon.LexiconFactory; import net.sourceforge.chaperon.adapter.sax.LexicalHandlerAdapter; import net.sourceforge.chaperon.adapter.sax.LexicalProcessorAdapter; import net.sourceforge.chaperon.build.LexicalAutomatonBuilder; import net.sourceforge.chaperon.model.lexicon.Lexicon; import net.sourceforge.chaperon.process.LexicalAutomaton; import net.sourceforge.chaperon.process.LexicalProcessor; /** * This transfomer transforms special mark text part of a XML * file into lexemes by using a lexicon file. * *

Input:

*
   * <text xmlns="http://chaperon.sourceforge.net/schema/text/1.0">
   *  Text 123 bla
   * </text>
   * 
* *

were transform into the following output:

*
   * <lexemes xmlns="http://chaperon.sourceforge.net/schema/lexemes/1.0">
   *  <lexeme symbol="word" text="Text"/>
   *  <lexeme symbol="number" text="123"/>
   *  <lexeme symbol="word" text="bla"/>
   * </lexemes>
   * 
* * @author Stephan Michels * @version CVS $Id: LexicalTransformer.java,v 1.1 2003/02/03 19:15:33 stephan Exp $ */ public class LexicalTransformer extends LexicalProcessorAdapter implements Transformer, LogEnabled, Composable, Recyclable, Disposable, CacheableProcessingComponent { /** Namespace for the SAX events. */ /* public final static String NS = "http://apache.org/cocoon/lexemes/1.0";*/ private XMLConsumer consumer = null; private String lexicon = null; private Source lexiconSource = null; private Logger logger = null; private ComponentManager manager = null; private SourceResolver resolver = null; private LexicalAutomaton automaton = null; private LexicalHandlerAdapter adapter = new LexicalHandlerAdapter(true); /** * Provide component with a logger. * * @param logger the logger */ public void enableLogging(Logger logger) { this.logger = logger; } /** * Pass the ComponentManager to the composer. The Composable * implementation should use the specified ComponentManager * to acquire the components it needs for execution. * * @param manager The ComponentManager which this Composable uses. */ public void compose(ComponentManager manager) { this.manager = manager; } /** * Set the XMLConsumer that will receive XML data. * * @param consumer */ public void setConsumer(XMLConsumer consumer) { this.consumer = consumer; setContentHandler(consumer); setLexicalHandler(consumer); adapter.setContentHandler(consumer); // adapter.setNamespace(NS); } /** * Set the SourceResolver, objectModel Map, the source and sitemap * Parameters used to process the request. * * @param resolver Source resolver * @param objectmodel Object model * @param src Source * @param parameters Parameters * * @throws IOException * @throws ProcessingException * @throws SAXException */ public void setup(SourceResolver resolver, Map objectmodel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { this.resolver = resolver; Store store = null; try { this.lexicon = src; this.lexiconSource = resolver.resolveURI(this.lexicon); // Retrieve the parser table from the transient store store = (Store) this.manager.lookup(Store.TRANSIENT_STORE); LexicalAutomatonEntry entry = (LexicalAutomatonEntry) store.get(this.lexiconSource.getURI()); // If the parser table has changed, rebuild the parser table /*if (entry!=null) System.out.println("entry.getValidity()="+entry.getValidity()); System.out.println("this.lexiconSource.getValidity()="+this.lexiconSource.getValidity()+" of "+this.lexiconSource.getURI());*/ if ((entry==null) || (entry.getValidity()==null) || (entry.getValidity().isValid(this.lexiconSource.getValidity())<= 0)) { /* (!entry.getValidity().isValid(this.lexiconSource.getValidity()))) { */ this.logger.info("(Re)building the automaton from '"+ this.lexiconSource.getURI()+"'"); SAXConfigurationHandler confighandler = new SAXConfigurationHandler(); if (this.lexiconSource.getInputStream()==null) { throw new ProcessingException("Source '"+ this.lexiconSource.getURI()+ "' not found"); } SourceUtil.toSAX(this.lexiconSource, confighandler, this.manager); Configuration config = confighandler.getConfiguration(); Lexicon lexicon = LexiconFactory.createLexicon(config); LexicalAutomatonBuilder builder = new LexicalAutomatonBuilder(lexicon, this.logger); this.automaton = builder.getLexicalAutomaton(); this.logger.info("Store automaton into store for '"+ this.lexiconSource.getURI()+"'"); store.store(this.lexiconSource.getURI(), new LexicalAutomatonEntry(this.automaton, this.lexiconSource.getValidity())); } else { this.logger.info("Getting automaton from store for '"+ this.lexiconSource.getURI()+"'"); this.automaton = entry.getLexicalAutomaton(); } if (getLexicalProcessor()==null) { LexicalProcessor processor = new LexicalProcessor(); processor.setLexicalHandler(this.adapter); processor.setLogger(this.logger); setLexicalProcessor(processor); } getLexicalProcessor().setLexicalAutomaton(this.automaton); } catch (ConfigurationException confige) { throw new ProcessingException("Error during retrieving the lexicon", confige); } catch (SourceException se) { throw new ProcessingException("Error during resolving of '"+src+ "'.", se); } catch (ComponentException ce) { throw new ProcessingException("Could not lookup for component", ce); } finally { if (store!=null) { this.manager.release(store); } } } /** * Generate the unique key. * This key must be unique inside the space of this component. * * @return The generated key hashes the src */ public Serializable generateKey() { return this.lexiconSource.getURI(); } /** * Generate the validity object. * * @return The generated validity object or null if the * component is currently not cacheable. */ public SourceValidity generateValidity() { return this.lexiconSource.getValidity(); } /** * Recycle this component. * All instance variables are set to null. */ public void recycle() { if ((this.resolver!=null) && (this.lexiconSource!=null)) { this.resolver.release(this.lexiconSource); this.lexiconSource = null; } this.automaton = null; } /** * The dispose operation is called at the end of a * components lifecycle. */ public void dispose() { if ((this.resolver!=null) && (this.lexiconSource!=null)) { this.resolver.release(this.lexiconSource); this.lexiconSource = null; } this.manager = null; } /** * This class represent a entry in a store to cache the lexical automaton. */ public class LexicalAutomatonEntry implements Serializable { private SourceValidity validity = null; private LexicalAutomaton automaton = null; /** * Create a new entry. * * @param automaton Lexical automaton. * @param validity Validity of the lexicon file. */ public LexicalAutomatonEntry(LexicalAutomaton automaton, SourceValidity validity) { this.automaton = automaton; this.validity = validity; } /** * Return the validity of the lexicon file. * * @return Validity of the lexicon file. */ public SourceValidity getValidity() { return this.validity; } /** * Return the lexical automaton. * * @return Lexical automaton. */ public LexicalAutomaton getLexicalAutomaton() { return this.automaton; } } } 1.1 xml-cocoon2/src/blocks/chaperon/java/org/apache/cocoon/transformation/ParserTransformer.java Index: ParserTransformer.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ package org.apache.cocoon.transformation; import org.apache.avalon.excalibur.pool.Recyclable; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.SAXConfigurationHandler; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.parameters.ParameterException; import org.apache.avalon.framework.parameters.Parameterizable; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.components.source.SourceUtil; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.transformation.Transformer; import org.apache.cocoon.xml.EmbeddedXMLPipe; import org.apache.cocoon.xml.XMLConsumer; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; import org.apache.excalibur.source.SourceValidity; import org.apache.excalibur.store.Store; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.ContentHandler; import org.xml.sax.helpers.AttributesImpl; import java.io.IOException; import java.io.Serializable; import java.util.Map; import net.sourceforge.chaperon.adapter.avalon.GrammarFactory; import net.sourceforge.chaperon.adapter.sax.ParserHandlerAdapter; import net.sourceforge.chaperon.adapter.sax.ParserProcessorAdapter; import net.sourceforge.chaperon.build.ParserAutomatonBuilder; import net.sourceforge.chaperon.model.grammar.Grammar; import net.sourceforge.chaperon.process.ParserAutomaton; import net.sourceforge.chaperon.process.ParserProcessor; /** * This transfomer transforms lexical tokens in a XML * file into a XML hirachy by using a grammar file. * *

Input:

*
   * <lexemes xmlns="http://chaperon.sourceforge.net/schema/lexemes/1.0">
   *  <lexeme symbol="word" text="Text"/>
   *  <lexeme symbol="number" text="123"/>
   *  <lexeme symbol="word" text="bla"/>
   * </lexemes>
   * 
* *

were transform into the following output:

*
   * <sentence xmlns="http://chaperon.sourceforge.net/schema/syntaxtree/1.0">
   *  <word>Text</word>
   *  <number>123</number>
   *  <word>bla</word>
   * </sentence>
   * 
* * @author Stephan Michels * @version CVS $Id: ParserTransformer.java,v 1.1 2003/02/03 19:15:33 stephan Exp $ */ public class ParserTransformer extends ParserProcessorAdapter implements Transformer, LogEnabled, Composable, Parameterizable, Recyclable, Disposable, CacheableProcessingComponent { /** Namespace for the SAX events. */ /* public final static String NS = "http://apache.org/cocoon/lexemes/1.0";*/ private XMLConsumer consumer = null; private String grammar = null; private Source grammarSource = null; private Logger logger = null; private ComponentManager manager = null; private SourceResolver resolver = null; private ParserAutomaton automaton = null; private ParserHandlerAdapter adapter = new ParserHandlerAdapter(true); private boolean ignoring = false; /** * Provide component with a logger. * * @param logger the logger */ public void enableLogging(Logger logger) { this.logger = logger; } /** * Pass the ComponentManager to the composer. The Composable * implementation should use the specified ComponentManager * to acquire the components it needs for execution. * * @param manager The ComponentManager which this Composable uses. */ public void compose(ComponentManager manager) { this.manager = manager; } /** * Provide component with parameters. * * @param parameters the parameters * @throws ParameterException if parameters are invalid */ public void parameterize(Parameters parameters) throws ParameterException { adapter.setFlatten(parameters.getParameterAsBoolean("flatten", false)); ignoring = parameters.getParameterAsBoolean("ignoring", false); } /** * Set the XMLConsumer that will receive XML data. * * @param consumer */ public void setConsumer(XMLConsumer consumer) { this.consumer = consumer; setContentHandler(consumer); setLexicalHandler(consumer); adapter.setContentHandler(consumer); // adapter.setNamespace(NS); } /** * Set the SourceResolver, objectModel Map, the source and sitemap * Parameters used to process the request. * * @param resolver Source resolver * @param objectmodel Object model * @param src Source * @param parameters Parameters * * @throws IOException * @throws ProcessingException * @throws SAXException */ public void setup(SourceResolver resolver, Map objectmodel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { this.resolver = resolver; Store store = null; try { this.grammar = src; this.grammarSource = resolver.resolveURI(this.grammar); // Retrieve the parser automaton from the transient store store = (Store) this.manager.lookup(Store.TRANSIENT_STORE); ParserAutomatonEntry entry = (ParserAutomatonEntry) store.get(this.grammarSource.getURI()); // If the parser automaton has changed, rebuild the parser automaton if ((entry==null) || (entry.getValidity()==null) || (entry.getValidity().isValid(this.grammarSource.getValidity()))<= 0) { this.logger.info("(Re)building the automaton from '"+ this.grammarSource.getURI()+"'"); SAXConfigurationHandler confighandler = new SAXConfigurationHandler(); if (this.grammarSource.getInputStream()==null) { throw new ProcessingException("Source '"+ this.grammarSource.getURI()+ "' not found"); } SourceUtil.toSAX(this.grammarSource, confighandler, this.manager); Configuration config = confighandler.getConfiguration(); Grammar grammar = GrammarFactory.createGrammar(config); ParserAutomatonBuilder builder = new ParserAutomatonBuilder(grammar, this.logger); this.automaton = builder.getParserAutomaton(); this.logger.info("Store automaton into store for '"+ this.grammarSource.getURI()+"'"); store.store(this.grammarSource.getURI(), new ParserAutomatonEntry(this.automaton, this.grammarSource.getValidity())); } else { this.logger.info("Getting automaton from store for '"+ this.grammarSource.getURI()+"'"); this.automaton = entry.getParserAutomaton(); } if (getParserProcessor()==null) { ParserProcessor processor = new ParserProcessor(); processor.setParserHandler(this.adapter); processor.setLogger(this.logger); processor.setIgnoreUnexpectedLexemes(ignoring); setParserProcessor(processor); } getParserProcessor().setParserAutomaton(this.automaton); } catch (ConfigurationException confige) { throw new ProcessingException("Error during retrieving the grammar", confige); } catch (SourceException se) { throw new ProcessingException("Error during resolving of '"+src+ "'.", se); } catch (ComponentException ce) { throw new ProcessingException("Could not lookup for component", ce); } finally { if (store!=null) { this.manager.release(store); } } } /** * Generate the unique key. * This key must be unique inside the space of this component. * * @return The generated key hashes the src */ public Serializable generateKey() { return this.grammarSource.getURI(); } /** * Generate the validity object. * * @return The generated validity object or null if the * component is currently not cacheable. */ public SourceValidity generateValidity() { return this.grammarSource.getValidity(); } /** * Recycle this component. * All instance variables are set to null. */ public void recycle() { if ((this.resolver!=null) && (this.grammarSource!=null)) { this.resolver.release(this.grammarSource); this.grammarSource = null; } this.automaton = null; } /** * The dispose operation is called at the end of a * components lifecycle. */ public void dispose() { if ((this.resolver!=null) && (this.grammarSource!=null)) { this.resolver.release(this.grammarSource); this.grammarSource = null; } this.manager = null; } /** * This class represent a entry in a store to cache * the parser automaton. */ public class ParserAutomatonEntry implements Serializable { private SourceValidity validity = null; private ParserAutomaton automaton = null; /** * Create a new entry. * * @param automaton Parser automaton. * @param validity Validity for the grammar file. */ public ParserAutomatonEntry(ParserAutomaton automaton, SourceValidity validity) { this.automaton = automaton; this.validity = validity; } /** * Return the validity of the grammar file. * * @return Validity of the grammar file. */ public SourceValidity getValidity() { return this.validity; } /** * Return the parser automaton. * * @return Parser automaton. */ public ParserAutomaton getParserAutomaton() { return this.automaton; } } } 1.1 xml-cocoon2/src/blocks/chaperon/java/org/apache/cocoon/transformation/PatternTransformer.java Index: PatternTransformer.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ package org.apache.cocoon.transformation; import org.apache.avalon.excalibur.pool.Recyclable; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.SAXConfigurationHandler; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.parameters.ParameterException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.components.source.SourceUtil; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.transformation.AbstractTransformer; import org.apache.cocoon.xml.EmbeddedXMLPipe; import org.apache.cocoon.xml.XMLConsumer; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; import org.apache.excalibur.source.SourceValidity; import org.apache.excalibur.store.Store; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.ContentHandler; import org.xml.sax.helpers.AttributesImpl; import java.io.IOException; import java.io.Serializable; import java.util.Map; import net.sourceforge.chaperon.adapter.avalon.LexiconFactory; import net.sourceforge.chaperon.adapter.sax.LexicalHandlerAdapter; import net.sourceforge.chaperon.adapter.sax.LexicalProcessorAdapter; import net.sourceforge.chaperon.build.LexicalAutomatonBuilder; import net.sourceforge.chaperon.common.Decoder; import net.sourceforge.chaperon.model.lexicon.Lexicon; import net.sourceforge.chaperon.process.LexicalAutomaton; import net.sourceforge.chaperon.process.PatternProcessor; /** * This transfomer transforms text pattern of a XML * file into lexemes by using a lexicon file. * *

Input:

*
   * <section>
   *  Text 123 bla
   * </section>
   * 
* *

can be transformed into the following output:

*
   * <section>
   *  Text
   *  <lexeme symbol="number" text="123"/>
   *  bla
   * </section>
   * 
* * @author Stephan Michels * @version CVS $Id: PatternTransformer.java,v 1.1 2003/02/03 19:15:34 stephan Exp $ */ public class PatternTransformer extends AbstractTransformer implements LogEnabled, Composable, Recyclable, Disposable, CacheableProcessingComponent { /** Namespace for the SAX events. */ public final static String NS = "http://chaperon.sourceforge.net/schema/lexemes/1.0"; private String lexicon = null; private Source lexiconSource = null; private Logger logger = null; private ComponentManager manager = null; private SourceResolver resolver = null; private LexicalAutomaton automaton = null; private PatternProcessor processor = new PatternProcessor(); private StringBuffer buffer = new StringBuffer(); private StringBuffer output = new StringBuffer(); /** * Provide component with a logger. * * @param logger the logger */ public void enableLogging(Logger logger) { this.logger = logger; } /** * Pass the ComponentManager to the composer. The Composable * implementation should use the specified ComponentManager * to acquire the components it needs for execution. * * @param manager The ComponentManager which this Composable uses. */ public void compose(ComponentManager manager) { this.manager = manager; } /** * Set the SourceResolver, objectModel Map, the source and sitemap * Parameters used to process the request. * * @param resolver Source resolver * @param objectmodel Object model * @param src Source * @param parameters Parameters * * @throws IOException * @throws ProcessingException * @throws SAXException */ public void setup(SourceResolver resolver, Map objectmodel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { this.resolver = resolver; Store store = null; try { this.lexicon = src; this.lexiconSource = resolver.resolveURI(this.lexicon); // Retrieve the lexical automaton from the transient store store = (Store) this.manager.lookup(Store.TRANSIENT_STORE); LexicalAutomatonEntry entry = (LexicalAutomatonEntry) store.get(this.lexiconSource.getURI()); // If the lexicon has changed, rebuild the lexical automaton if ((entry==null) || (entry.getValidity()==null) || (entry.getValidity().isValid(this.lexiconSource.getValidity())<= 0)) { this.logger.info("(Re)building the automaton from '"+ this.lexiconSource.getURI()+"'"); SAXConfigurationHandler confighandler = new SAXConfigurationHandler(); if (this.lexiconSource.getInputStream()==null) { throw new ProcessingException("Source '"+ this.lexiconSource.getURI()+ "' not found"); } SourceUtil.toSAX(this.lexiconSource, confighandler, this.manager); Configuration config = confighandler.getConfiguration(); Lexicon lexicon = LexiconFactory.createLexicon(config); LexicalAutomatonBuilder builder = new LexicalAutomatonBuilder(lexicon, this.logger); this.automaton = builder.getLexicalAutomaton(); this.logger.info("Store automaton into store for '"+ this.lexiconSource.getURI()+"'"); store.store(this.lexiconSource.getURI(), new LexicalAutomatonEntry(this.automaton, this.lexiconSource.getValidity())); } else { this.logger.info("Getting automaton from store for '"+ this.lexiconSource.getURI()+"'"); this.automaton = entry.getLexicalAutomaton(); } } catch (ConfigurationException confige) { throw new ProcessingException("Error during retrieving the lexicon", confige); } catch (SourceException se) { throw new ProcessingException("Error during resolving of '"+src+ "'.", se); } catch (ComponentException ce) { throw new ProcessingException("Could not lookup for component", ce); } finally { if (store!=null) { this.manager.release(store); } } } /** * Generate the unique key. * This key must be unique inside the space of this component. * * @return The generated key hashes the src */ public Serializable generateKey() { return this.lexiconSource.getURI(); } /** * Generate the validity object. * * @return The generated validity object or null if the * component is currently not cacheable. */ public SourceValidity generateValidity() { return this.lexiconSource.getValidity(); } /** * Recycle this component. * All instance variables are set to null. */ public void recycle() { if ((this.resolver!=null) && (this.lexiconSource!=null)) { this.resolver.release(this.lexiconSource); this.lexiconSource = null; } this.automaton = null; } /** * The dispose operation is called at the end of a * components lifecycle. */ public void dispose() { if ((this.resolver!=null) && (this.lexiconSource!=null)) { this.resolver.release(this.lexiconSource); this.lexiconSource = null; } this.manager = null; } /** * Receive notification of the beginning of an element. * * @param uri The Namespace URI, or the empty string if the element has no * Namespace URI or if Namespace * processing is not being performed. * @param loc The local name (without prefix), or the empty string if * Namespace processing is not being performed. * @param raw The raw XML 1.0 name (with prefix), or the empty string if * raw names are not available. * @param a The attributes attached to the element. If there are no * attributes, it shall be an empty Attributes object. * * @throws SAXException */ public void startElement(String uri, String loc, String raw, Attributes a) throws SAXException { search(); if (contentHandler!=null) { contentHandler.startElement(uri, loc, raw, a); } } /** * Receive notification of the end of an element. * * @param uri The Namespace URI, or the empty string if the element has no * Namespace URI or if Namespace * processing is not being performed. * @param loc The local name (without prefix), or the empty string if * Namespace processing is not being performed. * @param raw The raw XML 1.0 name (with prefix), or the empty string if * raw names are not available. * * @throws SAXException */ public void endElement(String uri, String loc, String raw) throws SAXException { search(); if (contentHandler!=null) { contentHandler.endElement(uri, loc, raw); } } /** * Receive notification of character data. * * @param c The characters from the XML document. * @param start The start position in the array. * @param len The number of characters to read from the array. * * @throws SAXException */ public void characters(char c[], int start, int len) throws SAXException { buffer.append(c, start, len); } /** * Receive notification of ignorable whitespace in element content. * * @param c The characters from the XML document. * @param start The start position in the array. * @param len The number of characters to read from the array. * * @throws SAXException */ public void ignorableWhitespace(char c[], int start, int len) throws SAXException { buffer.append(c, start, len); } /** * Receive notification of a processing instruction. * * @param target The processing instruction target. * @param data The processing instruction data, or null if none was * supplied. * * @throws SAXException */ public void processingInstruction(String target, String data) throws SAXException { search(); if (contentHandler!=null) { contentHandler.processingInstruction(target, data); } } /** * Report an XML comment anywhere in the document. * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param len The number of characters to use from the array. * * @throws SAXException */ public void comment(char ch[], int start, int len) throws SAXException { search(); if (lexicalHandler!=null) { lexicalHandler.comment(ch, start, len); } } /** * * * @throws SAXException */ private void search() throws SAXException { if (buffer.length()<=0) { return; } char[] text = buffer.toString().toCharArray(); String lexemesymbol, lexemetext; int lexemeindex = 0; int position = 0; output.setLength(0); do { lexemesymbol = null; lexemetext = null; for (lexemeindex = automaton.getLexemeCount()-1; lexemeindex>=0; lexemeindex--) { processor.setPatternAutomaton(automaton.getLexemeDefinition(lexemeindex)); if ((processor.match(text, position)) && ((lexemetext==null) || (processor.getGroup().length()>=lexemetext.length()))) { lexemesymbol = automaton.getLexemeSymbol(lexemeindex); lexemetext = processor.getGroup(); } } if (lexemetext!=null) { if (lexemesymbol!=null) { if (logger!=null) { logger.debug("Recognize token "+lexemesymbol+ " with '"+Decoder.decode(lexemetext)+ "'"); } if (output.length()>0) { contentHandler.characters(output.toString().toCharArray(), 0, output.length()); } output.setLength(0); contentHandler.startPrefixMapping("", NS); AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "symbol", "symbol", "CDATA", lexemesymbol); atts.addAttribute("", "text", "text", "CDATA", lexemetext); contentHandler.startElement(NS, "lexeme", "lexeme", atts); contentHandler.endElement(NS, "lexeme", "lexeme"); contentHandler.endPrefixMapping(""); } else if (logger!=null) { logger.debug("Ignore lexeme with '"+ Decoder.decode(lexemetext)+"'"); } /*if (locator!=null) { int column = locator.getColumnNumber(); int line = locator.getLineNumber(); for (int i = position; i<(position+lexemetext.length()); i++) { if ((text[i]=='\n') && ((i==0) || (text[i-1]!='\r'))) { column = 1; line++; } else if ((text[i]=='\r') && ((i==text.length-1) || (text[i+1]!='\n'))) { column = 1; line++; } else column++; } locator.setColumnNumber(column); locator.setLineNumber(line); }*/ position += lexemetext.length(); } else { output.append(text[position]); position++; } } while (position0) { contentHandler.characters(output.toString().toCharArray(), 0, output.length()); } buffer.setLength(0); } /** * This class represent a entry in a store to cache the lexical automaton. */ public class LexicalAutomatonEntry implements Serializable { private SourceValidity validity = null; private LexicalAutomaton automaton = null; /** * Create a new entry. * * @param automaton Lexical automaton. * @param validity Validity of the lexicon file. */ public LexicalAutomatonEntry(LexicalAutomaton automaton, SourceValidity validity) { this.automaton = automaton; this.validity = validity; } /** * Return the validity of the lexicon file. * * @return Validity of the lexicon file. */ public SourceValidity getValidity() { return this.validity; } /** * Return the lexical automaton. * * @return Lexical automaton. */ public LexicalAutomaton getLexicalAutomaton() { return this.automaton; } } } 1.1 xml-cocoon2/src/blocks/chaperon/java/org/apache/cocoon/xml/TextXMLizer.java Index: TextXMLizer.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ package org.apache.cocoon.xml; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.avalon.framework.component.Component; import org.apache.excalibur.xml.sax.SAXParser; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.LocatorImpl; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.LineNumberReader; /** * This XMLizer creates a SAX stream of a plain text document. The * text will be embedded in a text element. * * @author Stephan Michels * @version CVS $Id: TextXMLizer.java,v 1.1 2003/02/03 19:15:34 stephan Exp $ */ public class TextXMLizer implements SAXParser, ThreadSafe, Component { /** The URI of the text element */ public final static String URI = "http://chaperon.sourceforge.net/schema/text/1.0"; /** * Parse the {@link InputSource} and send * SAX events to the consumer. * * @param source Input source. * @param contentHandler Content handler. * @param lexicalHandler Lexical handler. */ public void parse(InputSource source, ContentHandler contentHandler, LexicalHandler lexicalHandler) throws SAXException, IOException { parse(source, contentHandler); } /** * Parse the {@link InputSource} and send * SAX events to the consumer. * Attention: the consumer can implement the * {@link LexicalHandler} as well. * The parse should take care of this. * * @param source * @param contentHandler */ public void parse(InputSource source, ContentHandler contentHandler) throws SAXException, IOException { LocatorImpl locator = new LocatorImpl(); locator.setPublicId(source.getPublicId()); locator.setSystemId(source.getSystemId()); locator.setLineNumber(1); locator.setColumnNumber(1); contentHandler.setDocumentLocator(locator); contentHandler.startDocument(); contentHandler.startPrefixMapping("", URI); AttributesImpl atts = new AttributesImpl(); contentHandler.startElement(URI, "text", "text", atts); LineNumberReader reader = null; if (source.getCharacterStream()!=null) { reader = new LineNumberReader(source.getCharacterStream()); } else { reader = new LineNumberReader(new InputStreamReader(source.getByteStream())); } String line, newline = null; String separator = System.getProperty("line.separator"); while (true) { if (newline==null) { line = reader.readLine(); } else { line = newline; } if (line==null) { break; } newline = reader.readLine(); line = (newline!=null) ? line+separator : line; locator.setLineNumber(reader.getLineNumber()); locator.setColumnNumber(1); contentHandler.characters(line.toCharArray(), 0, line.length()); if (newline==null) { break; } } contentHandler.endElement(URI, "text", "text"); contentHandler.endPrefixMapping(""); contentHandler.endDocument(); } } 1.2 +128 -65 xml-cocoon2/src/blocks/chaperon/samples/sitemap.xmap Index: sitemap.xmap =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/samples/sitemap.xmap,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- sitemap.xmap 31 Jan 2003 19:20:01 -0000 1.1 +++ sitemap.xmap 3 Feb 2003 19:15:34 -0000 1.2 @@ -16,46 +16,61 @@ - + - + true false + org.apache.xalan.xsltc.trax.TransformerFactoryImpl - + - - - + + + + + - - - + + src="org.apache.cocoon.serialization.XMLSerializer"> + yes + 1024 + + + + + + + + + @@ -66,32 +81,65 @@ - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + - - + + @@ -104,69 +152,84 @@ - - - - - - - - - - - - - - - + + + + + + + + + + - - - + + + + - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + + + + + - + 1.2 +134 -380 xml-cocoon2/src/blocks/chaperon/samples/grammars/wiki.grm Index: wiki.grm =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/samples/grammars/wiki.grm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- wiki.grm 31 Jan 2003 19:20:02 -0000 1.1 +++ wiki.grm 3 Feb 2003 19:15:34 -0000 1.2 @@ -1,380 +1,134 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +%token LINE "\-\-\-(\-)+"; + +%token QUOTE ":"; +%token BULLETED "(\*)+"; + +%token NUMBERED3 "\#\#\#"; +%token NUMBERED2 "\#\#"; +%token NUMBERED1 "\#"; + +%token HEAD "(\!)+"; + +%right ITALIC "\""; +%right BOLD "__"; +%right UNDERLINE "_"; + +%token LINK "(http|ftp|mailto|news):(/){1,3}[A-Za-z0-9\.\_\-]*"; + +%token BOPEN "\["; +%token BCLOSE "\]"; + +%token TEXT "[A-Za-z0-9\,\'\.\?\:]+[A-Za-z0-9\ \t\,\'\.\?\!\:]*"; + +%right EMPTY "\r\n [\ \t]* \r\n | + \r [\ \t]* \r | + \n [\ \t]* \n "; + +%token EOL "(\r(\n)?|\n)"; + + +%start wiki; + +%ignore "[\ \r\n]+"; // whitespace + +%% + +wiki : wiki paragraphs + | paragraphs + ; + +paragraphs : paragraphs paragraph + | paragraph + ; + +paragraph : bulletedlist + | numberedlist1 + | textitem + | headitem + | footnote + | LINE EOL + | EMPTY + ; + +bulletedlist : bulletedlist bulletedlistitem + | bulletedlistitem + ; + +bulletedlistitem : BULLETED textblock textsequence + | BULLETED textblock + ; + +numberedlist1 : numberedlist1 numberedlistitem1 + | numberedlistitem1 + | numberedlist1 numberedlist2 + | numberedlist2 + ; + +numberedlistitem1 : NUMBERED1 textblock textsequence + | NUMBERED1 textblock + ; + +numberedlist2 : numberedlist2 numberedlistitem2 + | numberedlistitem2 + | numberedlist2 numberedlist3 + | numberedlist3 + ; + +numberedlistitem2 : NUMBERED2 textblock textsequence + | NUMBERED2 textblock + ; + +numberedlist3 : numberedlist3 numberedlistitem3 + | numberedlistitem3 + ; + +numberedlistitem3 : NUMBERED3 textblock textsequence + | NUMBERED3 textblock + ; + +textitem : firstblock textblock textsequence + | firstblock textblock + | firstblock + ; + +headitem : HEAD textblock textsequence + | HEAD textblock + ; + +footnote : note textblock textsequence + | note textblock + ; + +textsequence : textsequence EOL + | EOL + | textsequence textblock + | textblock + ; + +textblock : LINK + | boldblock + | italicblock + | underlineblock + | TEXT + | note + ; + +firstblock : LINK + | boldblock + | italicblock + | underlineblock + | TEXT + ; + +italicblock : ITALIC TEXT ITALIC + ; + +boldblock : BOLD TEXT BOLD + ; + +underlineblock : UNDERLINE TEXT UNDERLINE + ; + +note : BOPEN TEXT BCLOSE + | BOPEN LINK BCLOSE + ; 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/grammar-v20.dtd Index: grammar-v20.dtd =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/grm.xgrm Index: grm.xgrm =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/grm.xlex Index: grm.xlex =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/java.xgrm Index: java.xgrm =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/java.xlex Index: java.xlex =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/javadoc.xgrm Index: javadoc.xgrm =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/javadoc.xlex Index: javadoc.xlex =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/lexicon-v20.dtd Index: lexicon-v20.dtd =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/mathexp.xgrm Index: mathexp.xgrm =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/mathexp.xlex Index: mathexp.xlex =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/regex.xgrm Index: regex.xgrm =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/grammars/regex.xlex Index: regex.xlex =================================================================== 1.2 +178 -66 xml-cocoon2/src/blocks/chaperon/samples/misc/java.css Index: java.css =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/samples/misc/java.css,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- java.css 31 Jan 2003 19:20:02 -0000 1.1 +++ java.css 3 Feb 2003 19:15:35 -0000 1.2 @@ -1,66 +1,178 @@ - -body { background-color: #FFFFFF; } - -body { color: #000000} - -#Header { color: #ffffff; background-color:#8697a5 } - -#CharacerLiteral { color: #FF00FF; } -#StringLiteral { color: #FF00FF; } -#SingleLineComment { color: #008000; } -#FormalComment { color: #008000; } -#MultiLineComment { color: #008000; } -#ABSTRACT { color: #0000FF ; font-weight: bold } -#BOOLEAN { color: #0000FF ; font-weight: bold } -#BREAK { color: #0000FF ; font-weight: bold } -#BYTE { color: #0000FF ; font-weight: bold } -#CASE { color: #0000FF ; font-weight: bold } -#CATCH { color: #0000FF ; font-weight: bold } -#CHAR { color: #0000FF ; font-weight: bold } -#CLASS { color: #0000FF ; font-weight: bold } -#CONST { color: #0000FF ; font-weight: bold } -#CONTINUE { color: #0000FF ; font-weight: bold } -#DEFAULT { color: #0000FF ; font-weight: bold } -#DO { color: #0000FF ; font-weight: bold } -#DOUBLE { color: #0000FF ; font-weight: bold } -#ELSE { color: #0000FF ; font-weight: bold } -#EXTENDS { color: #0000FF ; font-weight: bold } -#FALSE { color: #0000FF ; font-weight: bold } -#FINAL { color: #0000FF ; font-weight: bold } -#FINALLY { color: #0000FF ; font-weight: bold } -#FLOAT { color: #0000FF ; font-weight: bold } -#FOR { color: #0000FF ; font-weight: bold } -#GOTO { color: #0000FF ; font-weight: bold } -#IF { color: #0000FF ; font-weight: bold } -#IMPLEMENTS { color: #0000FF ; font-weight: bold } -#IMPORT { color: #0000FF ; font-weight: bold } -#INSTANCEOF { color: #0000FF ; font-weight: bold } -#INT { color: #0000FF ; font-weight: bold } -#INTERFACE { color: #0000FF ; font-weight: bold } -#LONG { color: #0000FF ; font-weight: bold } -#NATIVE { color: #0000FF ; font-weight: bold } -#NEW { color: #0000FF ; font-weight: bold } -#PACKAGE { color: #0000FF ; font-weight: bold } -#PRIVATE { color: #0000FF ; font-weight: bold } -#PROTECTED { color: #0000FF ; font-weight: bold } -#PUBLIC { color: #0000FF ; font-weight: bold } -#RETURN { color: #0000FF ; font-weight: bold } -#SHORT { color: #0000FF ; font-weight: bold } -#STATIC { color: #0000FF ; font-weight: bold } -#SUPER { color: #0000FF ; font-weight: bold } -#SWITCH { color: #0000FF ; font-weight: bold } -#SYCHRONIZED { color: #0000FF ; font-weight: bold } -#THIS { color: #0000FF ; font-weight: bold } -#THROW { color: #0000FF ; font-weight: bold } -#THROWS { color: #0000FF ; font-weight: bold } -#TRANSIENT { color: #0000FF ; font-weight: bold } -#TRUE { color: #0000FF ; font-weight: bold } -#TRY { color: #0000FF ; font-weight: bold } -#VOID { color: #0000FF ; font-weight: bold } -#VOLATILE { color: #0000FF ; font-weight: bold } -#WHILE { color: #0000FF ; font-weight: bold } -#StrictFP { color: #0000FF ; font-weight: bold } -#LITERAL { color: #b27b8c } -#IDENTIFIER { color: #000000 } - - +BODY { + FONT-FAMILY: verdana, arial, sans-serif +} + +a:link { + color: #1F354D; + FONT-SIZE: 12px; +} + +a:visited { + color: #1F354D; + FONT-SIZE: 12px; +} + +a:hover { + color: #FF5A00; + FONT-SIZE: 12px; +} + +a:active { + color: #FF5A00; + FONT-SIZE: 12px; +} + +TABLE { + FONT-SIZE: 9px +} + +TD.titleText { + BACKGROUND: #eff7ff; PADDING-left: 5px; +} + +TABLE.view { + FONT-SIZE: 12px; + /*BORDER:#aca9ac 1px solid;*/ +} + +TD.headerTitle { + BACKGROUND: #d5e2ee; + BORDER: #aca9ac 1px solid; + WIDTH: 100%; +} + +TD.headerLeft { + BACKGROUND: #f6f6f6; + BORDER-LEFT: #aca9ac 1px solid; + BORDER-BOTTOM: #aca9ac 1px solid; +} + +TD.header { + BACKGROUND: #f6f6f6; + BORDER-LEFT: #aca9ac 1px solid; + BORDER-BOTTOM: #aca9ac 1px solid; +} +TD.headerRight { + BACKGROUND: #f6f6f6; + BORDER-LEFT: #aca9ac 1px solid; + BORDER-BOTTOM: #aca9ac 1px solid; + BORDER-RIGHT: #aca9ac 1px solid; + WIDTH: 100%; +} + +TD.itemLeft { + BACKGROUND: #ffffff; + BORDER-LEFT: #aca9ac 1px solid; + BORDER-BOTTOM: #aca9ac 1px solid; + vertical-align:top; +} + +TD.item { + BACKGROUND: #ffffff; + BORDER-LEFT: #aca9ac 1px solid; + BORDER-BOTTOM: #aca9ac 1px solid; + vertical-align:top; +} + +TD.itemRight { + BACKGROUND: #ffffff; + BORDER-LEFT: #aca9ac 1px solid; + BORDER-BOTTOM: #aca9ac 1px solid; + BORDER-RIGHT: #aca9ac 1px solid; + WIDTH: 100%; + vertical-align:top; +} + +FONT.current { + padding: 2px; + font-weight: bold; + color: #FFFFFF; + background-color:#00008B; +} + +TABLE.srcView { + FONT-SIZE: 12px; BORDER-LEFT:#dcdcdc 1px solid;BORDER-RIGHT:#dcdcdc 1px solid; BORDER-BOTTOM:#dcdcdc 1px solid; +} + +TD.lineCount { + BACKGROUND: #f6f6f6; + BORDER-LEFT: #aca9ac 1px solid; + BORDER-BOTTOM: #aca9ac 1px solid; + BORDER-RIGHT: #aca9ac 1px solid; + PADDING-RIGHT: 3px; + FONT-SIZE: 12px; +} + +TD.srcLine { + WIDTH: 100%; + BORDER-BOTTOM: #aca9ac 1px solid; + BORDER-RIGHT: #aca9ac 1px solid; +} + +PRE.srcLine { + BACKGROUND: #ffffff; MARGIN-BOTTOM: 0px; FONT-SIZE: 12px; +} + +TD.footer { + BORDER-TOP:#dcdcdc 1px solid; FONT-SIZE: 9px +} + +/* Token Colours */ +FONT.CharacerLiteral { color: #FF00FF; } +FONT.StringLiteral { color: #FF00FF; } +FONT.SingleLineComment { color: #008000; } +FONT.FormalComment { color: #008000; } +FONT.MultiLineComment { color: #008000; } +FONT.ABSTRACT { color: #2020BF ; font-weight: normal } +FONT.BOOLEAN { color: #2020BF ; font-weight: normal } +FONT.BREAK { color: #2020BF ; font-weight: normal } +FONT.BYTE { color: #2020BF ; font-weight: normal } +FONT.CASE { color: #2020BF ; font-weight: normal } +FONT.CATCH { color: #2020BF ; font-weight: normal } +FONT.CHAR { color: #2020BF ; font-weight: normal } +FONT.CLASS { color: #2020BF ; font-weight: normal } +FONT.CONST { color: #2020BF ; font-weight: normal } +FONT.CONTINUE { color: #2020BF ; font-weight: normal } +FONT.DEFAULT { color: #2020BF ; font-weight: normal } +FONT.DO { color: #2020BF ; font-weight: normal } +FONT.DOUBLE { color: #2020BF ; font-weight: normal } +FONT.ELSE { color: #2020BF ; font-weight: normal } +FONT.EXTENDS { color: #2020BF ; font-weight: normal } +FONT.FALSE { color: #2020BF ; font-weight: normal } +FONT.FINAL { color: #2020BF ; font-weight: normal } +FONT.FINALLY { color: #2020BF ; font-weight: normal } +FONT.FLOAT { color: #2020BF ; font-weight: normal } +FONT.FOR { color: #2020BF ; font-weight: normal } +FONT.GOTO { color: #2020BF ; font-weight: normal } +FONT.IF { color: #2020BF ; font-weight: normal } +FONT.IMPLEMENTS { color: #2020BF ; font-weight: normal } +FONT.IMPORT { color: #2020BF ; font-weight: normal } +FONT.INSTANCEOF { color: #2020BF ; font-weight: normal } +FONT.INT { color: #2020BF ; font-weight: normal } +FONT.INTERFACE { color: #2020BF ; font-weight: normal } +FONT.LONG { color: #2020BF ; font-weight: normal } +FONT.NATIVE { color: #2020BF ; font-weight: normal } +FONT.NEW { color: #2020BF ; font-weight: normal } +FONT.PACKAGE { color: #2020BF ; font-weight: normal } +FONT.PRIVATE { color: #2020BF ; font-weight: normal } +FONT.PROTECTED { color: #2020BF ; font-weight: normal } +FONT.PUBLIC { color: #2020BF ; font-weight: normal } +FONT.RETURN { color: #2020BF ; font-weight: normal } +FONT.SHORT { color: #2020BF ; font-weight: normal } +FONT.STATIC { color: #2020BF ; font-weight: normal } +FONT.SUPER { color: #2020BF ; font-weight: normal } +FONT.SWITCH { color: #2020BF ; font-weight: normal } +FONT.SYCHRONIZED { color: #2020BF ; font-weight: normal } +FONT.THIS { color: #2020BF ; font-weight: normal } +FONT.THROW { color: #2020BF ; font-weight: normal } +FONT.THROWS { color: #2020BF ; font-weight: normal } +FONT.TRANSIENT { color: #2020BF ; font-weight: normal } +FONT.TRUE { color: #2020BF ; font-weight: normal } +FONT.TRY { color: #2020BF ; font-weight: normal } +FONT.VOID { color: #2020BF ; font-weight: normal } +FONT.VOLATILE { color: #2020BF ; font-weight: normal } +FONT.WHILE { color: #2020BF ; font-weight: normal } +FONT.StrictFP { color: #2020BF ; font-weight: normal } +FONT.LITERAL { color: #b27b8c } +FONT.IDENTIFIER { color: #000000 } + 1.2 +2 -2 xml-cocoon2/src/blocks/chaperon/samples/misc/mathexp.xsp Index: mathexp.xsp =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/samples/misc/mathexp.xsp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- mathexp.xsp 31 Jan 2003 19:20:02 -0000 1.1 +++ mathexp.xsp 3 Feb 2003 19:15:35 -0000 1.2 @@ -13,8 +13,8 @@

Mathexp Example

- +

1.2 +4 -3 xml-cocoon2/src/blocks/chaperon/samples/misc/samples.xml Index: samples.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/samples/misc/samples.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- samples.xml 31 Jan 2003 19:20:02 -0000 1.1 +++ samples.xml 3 Feb 2003 19:15:35 -0000 1.2 @@ -16,11 +16,12 @@ - The parser also be used to colorize - some source code. (Need once 2-3min, for the parser table generation process) + The parser can also be used to colorize + some source code. - Another example. + This example show a another view + of a java class, similar to javadoc.(Need once 2-3min, for the parser table generation process) 1.2 +1 -1 xml-cocoon2/src/blocks/chaperon/samples/misc/wiki.xsp Index: wiki.xsp =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/samples/misc/wiki.xsp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- wiki.xsp 31 Jan 2003 19:20:02 -0000 1.1 +++ wiki.xsp 3 Feb 2003 19:15:35 -0000 1.2 @@ -232,7 +232,7 @@

Preview
- +

1.1 xml-cocoon2/src/blocks/chaperon/samples/misc/test/Grammar.java Index: Grammar.java =================================================================== /* * Copyright (C) Chaperon. All rights reserved. * ------------------------------------------------------------------------- * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE file. */ package net.sourceforge.chaperon.model.grammar; import java.io.Serializable; import java.util.Hashtable; import java.util.Enumeration; import java.util.Vector; import net.sourceforge.chaperon.common.IntegerList; import net.sourceforge.chaperon.model.Violations; import net.sourceforge.chaperon.model.symbol.Symbol; import net.sourceforge.chaperon.model.symbol.SymbolList; import net.sourceforge.chaperon.model.symbol.SymbolSet; import net.sourceforge.chaperon.model.symbol.Nonterminal; import net.sourceforge.chaperon.model.symbol.Terminal; /** * This class represents a model for a grammar. The content of * the grammar includes the productions, start symbol, associativities * and priorities. * * @author Stephan Michels * @version CVS $Id: Grammar.java,v 1.1 2003/02/03 19:15:35 stephan Exp $ */ public class Grammar implements Serializable, Cloneable { // Start symbol private Nonterminal startsymbol = null; // Productions private Vector productions = new Vector(); private Hashtable priorities = new Hashtable(); private Hashtable associativities = new Hashtable(); private String location = null; /** * Creates an empty grammar. */ public Grammar() { } /** * Add a production to this grammar. * * @param production Production, which should be added. * * @return Index of the production in this grammar. */ public int addProduction(Production production) { if (production==null) throw new NullPointerException(); productions.addElement(production); return productions.size()-1; } /** * Add a list of productions to this grammar. * * @param list Array of productions. */ public void addProduction(Production[] list) { for (int i = 0; iproductions.size())) throw new IndexOutOfBoundsException(); productions.setElementAt(production, index); } /** * Return a production giving by an index. * * @param index Index of the Production. * * @return The production. */ public Production getProduction(int index) { if ((index<0) || (index>productions.size())) throw new IndexOutOfBoundsException(); return (Production) productions.elementAt(index); } /** * Returns all production for given nonterminal symbol as * a list of indices. * * @param ntsymbol Nonterminal symbol * * @return List of indices from the productions */ public IntegerList getProductionList(Symbol ntsymbol) { IntegerList list = new IntegerList(); int i; for (i = 0; i=0; i--) if (definition.getSymbol(i) instanceof Terminal) { int priority = getPriority((Terminal) definition.getSymbol(i)); return priority; } return getProductionCount()-indexOf(production); } /** * Set the associativity of a terminal symbol. * * @param terminal Terminal symbol. * @param assoc Associativity of the symbol. */ public void setAssociativity(Terminal terminal, Associativity assoc) { if (terminal==null) throw new NullPointerException(); associativities.put(terminal, assoc); } /** * Return the associativity of a terminal symbol. * * @param terminal Terminal symbol. * * @return Associativity of the symbol. */ public Associativity getAssociativity(Terminal terminal) { Associativity assoc = (Associativity) associativities.get(terminal); if (assoc==null) return Associativity.NONASSOC; return assoc; } /** * Return the associativity of a production in this grammar. * * @param production Production. * * @return Associativity of the production. */ public Associativity getAssociativity(Production production) { if (!contains(production)) return Associativity.NONASSOC; if (production.getPrecedence()!=null) return getAssociativity(production.getPrecedence()); SymbolList definition = production.getDefinition(); for (int i = definition.getSymbolCount()-1; i>=0; i--) if (definition.getSymbol(i) instanceof Terminal) return getAssociativity((Terminal) definition.getSymbol(i)); return Associativity.NONASSOC; } /** * Return all used symbol in this grammar. * * @return Set of symbols, which were used. */ public SymbolSet getSymbols() { SymbolSet set = new SymbolSet(); for (int i = 0; iStephan Michels * @version CVS $Id: PatternProcessor.java,v 1.1 2003/02/03 19:15:35 stephan Exp $ */ public class PatternProcessor { private PatternAutomaton automaton; private IntegerList states = new IntegerList(); private IntegerList statekeys = new IntegerList(); private IntegerList newstates = new IntegerList(); private IntegerList newstatekeys = new IntegerList(); // for storing the traversed states private IntegerList historystates = new IntegerList(); private IntegerList dependencies = new IntegerList(); // for storing the group, which were found private String[] groups = new String[10]; private int[] groupstarts = new int[10]; private int[] groupends = new int[10]; private int groupcount = 0; /** * Create a new pattern processor. */ public PatternProcessor() { } /** * Create a new pattern processor. * * @param automaton Automaton, which the processor should use. */ public PatternProcessor(PatternAutomaton automaton) { setPatternAutomaton(automaton); } /** * Set the pattern automaton. * * @param automaton Automaton, which the processor should use. */ public void setPatternAutomaton(PatternAutomaton automaton) { if (automaton==null) throw new NullPointerException(); this.automaton = automaton; if (groupstarts.length<=(automaton.getGroupCount())) { groups = new String[automaton.getGroupCount()+1]; groupstarts = new int[automaton.getGroupCount()+1]; groupends = new int[automaton.getGroupCount()+1]; } } /** * Search a postion, where the processor is successful. * * @param text Text. * * @return Next first position where the parser is successfull * otherwise -1. */ public boolean search(char[] text) { return search(text, 0); } /** * Search a postion, where the processor is successful. * * @param text Text. * @param start Start position within the text. * * @return Next first position where the parser is successfull * otherwise -1. */ public boolean search(char[] text, int start) { for (int position = start; position<=text.length; position++) if (match(text, position)) return true; return false; } private boolean verbose = false; public void setVerbose(boolean verbose) { this.verbose = verbose; } /** * Matches for pattern. * * @param text Text. * * @return True, if the processor matches successfully. */ public boolean match(char[] text) { return match(text, 0); } /** * Matches for pattern at specified position within the text. * * @param text Text * @param start Position within the text. * * @return True, if the processor matches successfully. */ public boolean match(char[] text, int start) { if (automaton==null) throw new NullPointerException("PatternAutomaton is null"); if (automaton.getStateCount()<=0) return false; for (int i = 0; i<=automaton.getGroupCount(); i++) { groupstarts[i] = start; groupends[i] = start; groups[i] = null; } int position = start; int state, key; boolean found = false; int foundkey = 0; int foundPosition = start; states.clear(); states.push(automaton.getFirstState()); newstates.clear(); statekeys.clear(); statekeys.push(0); historystates.clear(); historystates.push(automaton.getFirstState()); dependencies.clear(); dependencies.push(0); while (( !states.isEmpty()) && (position<=text.length)) { state = states.pop(); key = statekeys.pop(); if (automaton.isFinalState(state)) { found = true; foundkey = key; foundPosition = position; } else { switch (automaton.getType(state)) { case PatternAutomaton.TYPE_NOMATCH : pushState(states, statekeys, state, key); break; case PatternAutomaton.TYPE_MATCH : if ((position=text[position])) pushState(newstates, newstatekeys, state, key); break; case PatternAutomaton.TYPE_EXMATCH : if ((positiontext[position]) || (automaton.getIntervalEnd(state)=text.length) pushState(states, statekeys, state, key); else if (((position+1)==text.length) && ((text[position]=='\r') || (text[position]=='\n'))) pushState(states, statekeys, state, key); else if ((text[position]=='\r') || (text[position]=='\n')) pushState(states, statekeys, state, key); break; case PatternAutomaton.TYPE_GROUPSTART : pushState(states, statekeys, state, key); break; case PatternAutomaton.TYPE_GROUPEND : pushState(states, statekeys, state, key); break; } } if (states.isEmpty()) { IntegerList temp = newstates; newstates = states; states = temp; temp = newstatekeys; newstatekeys = statekeys; statekeys = temp; position++; // next character } } position = foundPosition; key = foundkey; while (key!=0) { key = dependencies.get(key); state = historystates.get(key); switch (automaton.getType(state)) { case PatternAutomaton.TYPE_NOMATCH : break; case PatternAutomaton.TYPE_MATCH : position--; break; case PatternAutomaton.TYPE_EXMATCH : break; case PatternAutomaton.TYPE_MATCHANY : position--; break; case PatternAutomaton.TYPE_BOL : break; case PatternAutomaton.TYPE_EOL : break; case PatternAutomaton.TYPE_GROUPSTART : if (groups[automaton.getGroupIndex(state)]==null) { groupstarts[automaton.getGroupIndex(state)] = position; groups[automaton.getGroupIndex(state)] = new String(text, position, groupends[automaton.getGroupIndex(state)]-position); } break; case PatternAutomaton.TYPE_GROUPEND : if (groups[automaton.getGroupIndex(state)]==null) groupends[automaton.getGroupIndex(state)] = position; break; } } groupcount = automaton.getGroupCount(); for (int i = groupcount-1; (i>=0) && (groups[i]==null); i--) groupcount--; return found; } /** * Push a state into the history. * * @param states The traversed states. * @param keys Keys of the traversed paths. * @param state Current state. * @param key Current key. */ private void pushState(IntegerList states, IntegerList keys, int state, int key) { states.push(automaton.getTransitions(state)); historystates.push(automaton.getTransitions(state)); for (int i = automaton.getTransitions(state).length; i>0; i--) { keys.push(dependencies.getCount()); dependencies.push(key); } } /** * Return the text, which in last match was found. * * @return Text. */ public String getGroup() { return groups[0]; } /** * Return the text of the specifed group, which in * last match was found. * * @param group Index of group; * * @return Text */ public String getGroup(int group) { return groups[group]; } /** * Return count of groups. * * @return Count of groups. */ public int getGroupCount() { return groupcount; } /** * Return the start position of the last match. * * @return Start position. */ public int getGroupStart() { return groupstarts[0]; } /** * Return the start position of a group * from the last match. * * @param group Index of group. * * @return Start position. */ public int getGroupStart(int group) { return groupstarts[group]; } /** * Return the end position of the last match. * * @return End position. */ public int getGroupEnd() { return groupends[0]; } /** * Return the end position of a group * from the last match. * * @param group Index of group. * * @return End position. */ public int getGroupEnd(int group) { return groupends[group]; } } 1.2 +311 -630 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/java2html.xsl Index: java2html.xsl =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/samples/stylesheets/java2html.xsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- java2html.xsl 31 Jan 2003 19:20:02 -0000 1.1 +++ java2html.xsl 3 Feb 2003 19:15:35 -0000 1.2 @@ -1,858 +1,539 @@ + xmlns:lex="http://chaperon.sourceforge.net/schema/lexemes/1.0"> - - MethodDeclaration + + - + cocoon/samples/chaperon/ + + + Java2HTML - java2html example - + + - - - - -
  - java2html example + +

+ + + + + + + +
+ Packages +
+ +
+

+

+ + + + + + + +
+ Classes +
+ +
+

- -
  -     
  -    
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - +

+ + + + +
+ Package    + Class    + File +
+

+ +

+ + + + + + + + +
 Source file: .java 
+

  +             
  +            
  +           
+
+
+
+

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - +

+ + + + + +
 
+

- - + + - - + +
- - + +
- - + + 1 + 1  + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + - - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - - - - - - - - + + - - - - - - - - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + - - + + - - + + /*/ - - + + + - - + + - - + + - - + + - - + + - - + + - - - + - +
1.2 +5 -5 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/mathexp2html.xsl Index: mathexp2html.xsl =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/samples/stylesheets/mathexp2html.xsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- mathexp2html.xsl 31 Jan 2003 19:20:02 -0000 1.1 +++ mathexp2html.xsl 3 Feb 2003 19:15:36 -0000 1.2 @@ -1,10 +1,10 @@ + xmlns:st="http://chaperon.sourceforge.net/schema/syntaxtree/1.0" + version="1.0"> - + @@ -16,7 +16,7 @@
- + @@ -28,7 +28,7 @@
- + 1.2 +51 -51 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/wiki2html.xsl Index: wiki2html.xsl =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/samples/stylesheets/wiki2html.xsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- wiki2html.xsl 31 Jan 2003 19:20:02 -0000 1.1 +++ wiki2html.xsl 3 Feb 2003 19:15:36 -0000 1.2 @@ -1,20 +1,20 @@ - +
- + + - +

- +

- - + + - - + + - +
- +
    - +
- +
  • - +
  • - +
      - +
    - +
  • - +
  • - +
      - +
    - +
  • - +
  • - +
      - +
    - +
  • - +
  • - + - +

    - +

    - +

    - +

    - +

    - - - [] - + + + [] + - + - + - + - + - + - + - + - - - [] + + + [] - + 1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/class2html.xsl Index: class2html.xsl =================================================================== cocoon/samples/chaperon/ Java2HTML

    Packages

    Classes

     



     Summary 
     Package   Type   Name   Description 
     

     Field Summary 
     Modifier   Type   Name   Description 

     Constructor Summary 
     Modifier   Name   Description 

     Method Summary 
     Modifier   Type   Name   Description 

            (  ,   )     (  ,   )  

        (  ,   )
    Parameters:
    -
    Returns:
    -

    1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/grm2xgrm.xsl Index: grm2xgrm.xsl =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/grm2xlex.xsl Index: grm2xlex.xsl =================================================================== left right 10 13 9 # 1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/index4java.xsl Index: index4java.xsl =================================================================== . . 1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/mathexp.xsl Index: mathexp.xsl =================================================================== 3*a-5*6/7 + ( b-c)*5- b 1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/package2html.xsl Index: package2html.xsl =================================================================== cocoon/samples/chaperon/ Java2HTML

    Packages

    Classes

    Package    Class    File

     Package  
    Classes Description

     



     
    1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/remove4class.xsl Index: remove4class.xsl =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/text4javadoc.xsl Index: text4javadoc.xsl =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/text4javadoc2.xsl Index: text4javadoc2.xsl =================================================================== 1.1 xml-cocoon2/src/blocks/chaperon/samples/stylesheets/text4regex.xsl Index: text4regex.xsl =================================================================== 1.24 +5 -0 xml-cocoon2/src/webapp/WEB-INF/web.xml Index: web.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/src/webapp/WEB-INF/web.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- web.xml 30 Jan 2003 07:07:38 -0000 1.23 +++ web.xml 3 Feb 2003 19:15:36 -0000 1.24 @@ -376,4 +376,9 @@ text/plain + + grm + text/plain + + ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org