cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/xml/util DOMBuilder.java DOMFactory.java DOMStreamer.java DocumentHandlerAdapter.java DocumentHandlerWrapper.java NamespacesTable.java XPathAPI.java package.html
Date Sat, 22 Jul 2000 20:42:08 GMT
giacomo     00/07/22 13:42:07

  Modified:    .        Tag: xml-cocoon2 build.xml
               conf     Tag: xml-cocoon2 cocoon.xconf
               src      Tag: xml-cocoon2 Manifest.mf
               src/org/apache/cocoon Tag: xml-cocoon2 Cocoon.java
                        ProcessingException.java Processor.java
                        Request.java Response.java
               src/org/apache/cocoon/components/classloader Tag:
                        xml-cocoon2 ClassLoaderManager.java
                        ClassLoaderManagerImpl.java
                        RepositoryClassLoader.java
               src/org/apache/cocoon/components/language Tag: xml-cocoon2
                        LanguageException.java
               src/org/apache/cocoon/components/language/generator Tag:
                        xml-cocoon2 ProgramGenerator.java
                        ProgramGeneratorImpl.java
               src/org/apache/cocoon/components/language/markup Tag:
                        xml-cocoon2 AbstractMarkupLanguage.java
                        Logicsheet.java LogicsheetCodeGenerator.java
                        MarkupCodeGenerator.java MarkupLanguage.java
                        NamedLogicsheet.java
               src/org/apache/cocoon/components/language/markup/sitemap
                        Tag: xml-cocoon2 SitemapMarkupLanguage.java
               src/org/apache/cocoon/components/language/markup/sitemap/java
                        Tag: xml-cocoon2 sitemap.xsl
               src/org/apache/cocoon/components/language/markup/xsp Tag:
                        xml-cocoon2 Constants.java XSPGenerator.java
                        XSPMarkupLanguage.java XSPObjectHelper.java
                        XSPRequestHelper.java XSPResponseHelper.java
               src/org/apache/cocoon/components/language/markup/xsp/java
                        Tag: xml-cocoon2 request.xsl response.xsl xsp.xsl
               src/org/apache/cocoon/components/language/programming Tag:
                        xml-cocoon2 AbstractProgrammingLanguage.java
                        CodeFormatter.java CompiledProgrammingLanguage.java
                        CompilerError.java LanguageCompiler.java
                        ProgrammingLanguage.java
               src/org/apache/cocoon/components/language/programming/java
                        Tag: xml-cocoon2 AbstractJavaCompiler.java
                        JavaLanguage.java Javac.java Jikes.java
                        JstyleFormatter.java
               src/org/apache/cocoon/components/language/programming/javascript
                        Tag: xml-cocoon2 JavascriptLanguage.java
               src/org/apache/cocoon/components/parser Tag: xml-cocoon2
                        Parser.java XercesParser.java
               src/org/apache/cocoon/components/store Tag: xml-cocoon2
                        FilesystemStore.java MemoryStore.java Store.java
               src/org/apache/cocoon/environment Tag: xml-cocoon2
                        Environment.java
               src/org/apache/cocoon/environment/http Tag: xml-cocoon2
                        HttpEnvironment.java HttpRequest.java
                        HttpResponse.java
               src/org/apache/cocoon/generation Tag: xml-cocoon2
                        AbstractGenerator.java AbstractServerPage.java
                        ComposerGenerator.java DirectoryGenerator.java
                        FileGenerator.java Generator.java
                        ImageDirectoryGenerator.java PhpGenerator.java
                        RequestGenerator.java ServerPagesGenerator.java
                        StatusGenerator.java
               src/org/apache/cocoon/matching Tag: xml-cocoon2
                        AuthenticationMatcher.java
                        BrowserMatcherFactory.java
                        FileAuthenticationMatcher.java Matcher.java
                        MatcherFactory.java RegexpURIMatcherFactory.java
                        WildcardURIMatcherFactory.java
               src/org/apache/cocoon/matching/helpers Tag: xml-cocoon2
                        WildcardURIMatcher.java
               src/org/apache/cocoon/selection Tag: xml-cocoon2
                        BrowserSelectorFactory.java Selector.java
                        SelectorFactory.java
               src/org/apache/cocoon/serialization Tag: xml-cocoon2
                        AbstractSerializer.java FO2PDFSerializer.java
                        HTMLSerializer.java ImageSerializer.java
                        SVGSerializer.java Serializer.java
                        XMLSerializer.java
               src/org/apache/cocoon/servlet Tag: xml-cocoon2
                        CocoonServlet.java CocoonServletRequest.java
                        CocoonServletResponse.java
               src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        AbstractSitemapComponent.java LinkResolver.java
                        LinkTranslator.java Matcher.java
                        ResourcePipeline.java Sitemap.java
                        SitemapComponent.java SitemapHandler.java
                        SitemapManager.java XSLTMatcherFactoryLoader.java
                        XSLTSelectorFactoryLoader.java
               src/org/apache/cocoon/sitemap/patterns Tag: xml-cocoon2
                        PatternException.java PatternMatcher.java
                        PatternTranslator.java
               src/org/apache/cocoon/transformation Tag: xml-cocoon2
                        AbstractTransformer.java LogTransformer.java
                        SQLTransformer.java Transformer.java
                        XIncludeTransformer.java XalanTransformer.java
               src/org/apache/cocoon/util Tag: xml-cocoon2 ClassUtils.java
                        DOMUtils.java IOUtils.java StringUtils.java
                        Tokenizer.java
               src/org/apache/cocoon/xml Tag: xml-cocoon2
                        AbstractXMLConsumer.java AbstractXMLProducer.java
                        XMLConsumer.java XMLProducer.java package.html
               src/org/apache/cocoon/xml/util Tag: xml-cocoon2
                        DOMBuilder.java DOMFactory.java DOMStreamer.java
                        DocumentHandlerAdapter.java
                        DocumentHandlerWrapper.java NamespacesTable.java
                        XPathAPI.java package.html
  Added:       conf     Tag: xml-cocoon2 cocoon.xconf.old
  Removed:     src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        AbstractSitemapProcessor.java GenericProcessor.java
                        ResourceProcessor.java SitemapPartition.java
                        SitemapProcessor.java
  Log:
  First alpha-alpha release of the new sitemap engine.
  
  This commit break the system! You have to do a 'build.sh clean package webapp'
  to get a correct system.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.15  +1 -1      xml-cocoon/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/build.xml,v
  retrieving revision 1.6.2.14
  retrieving revision 1.6.2.15
  diff -u -r1.6.2.14 -r1.6.2.15
  --- build.xml	2000/07/12 00:09:47	1.6.2.14
  +++ build.xml	2000/07/22 20:41:27	1.6.2.15
  @@ -88,7 +88,7 @@
       <property name="build.compiler" value="classic"/>
       <property name="debug"          value="on"/>
       <property name="optimize"       value="on"/>
  -    <property name="deprecation"    value="on"/>
  +    <property name="deprecation"    value="off"/>
   
       <property name="src.dir"     value="./src"/>
       <property name="lib.dir"     value="./lib"/>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.12  +57 -152   xml-cocoon/conf/Attic/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/conf/Attic/cocoon.xconf,v
  retrieving revision 1.1.2.11
  retrieving revision 1.1.2.12
  diff -u -r1.1.2.11 -r1.1.2.12
  --- cocoon.xconf	2000/07/12 22:15:05	1.1.2.11
  +++ cocoon.xconf	2000/07/22 20:41:28	1.1.2.12
  @@ -1,152 +1,57 @@
  -<?xml version="1.0"?>
  -<cocoon version="2.0">
  -
  -<!-- ===================== General Components =========================== -->
  -
  -  <component role="parser" class="org.apache.cocoon.components.parser.XercesParser"/>
  -  <component role="store" class="org.apache.cocoon.components.store.MemoryStore"/>
  -
  -  <component role="factory" class="org.apache.avalon.NamedComponentManagerImpl">
  -    <component-type name="programming-language">
  -      <component-instance name="java" class="org.apache.cocoon.components.language.programming.java.JavaLanguage">
  -        <parameter name="compiler" value="org.apache.cocoon.components.language.programming.java.Javac"/>
  -        <parameter name="code-formatter" value="org.apache.cocoon.components.language.programming.java.JstyleFormatter"/>
  -        <parameter name="class-loader" value="org.apache.cocoon.components.classloader.ClassLoaderManagerImpl"/>
  -      </component-instance>
  -    </component-type>
  -
  -    <component-type name="markup-language">
  -      <component-instance name="xsp" class="org.apache.cocoon.components.language.markup.xsp.XSPMarkupLanguage">
  -        <parameter name="prefix" value="xsp"/>
  -        <parameter name="uri" value="http://xml.apache.org/cocoon/xsp"/>
  -  
  -        <target-language name="java">
  -          <parameter name="core-logicsheet" value="resource://org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl"/>
  -
  -          <builtin-logicsheet>
  -            <parameter name="prefix" value="xsp-request"/>
  -            <parameter name="uri" value="http://xml.apache.org/cocoon/xsp/request"/>
  -            <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/java/request.xsl"/>
  -          </builtin-logicsheet>
  -
  -          <builtin-logicsheet>
  -            <parameter name="prefix" value="xsp-response"/>
  -            <parameter name="uri" value="http://xml.apache.org/cocoon/xsp/response"/>
  -            <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/java/request.xsl"/>
  -          </builtin-logicsheet>
  -        </target-language>
  -      </component-instance>
  -
  -      <component-instance name="sitemap" class="org.apache.cocoon.components.language.markup.sitemap.SitemapMarkupLanguage">
  -        <parameter name="prefix" value="map"/>
  -        <parameter name="uri" value="http://xml.apache.org/cocoon/sitemap"/>
  -  
  -        <target-language name="java">
  -          <parameter name="core-logicsheet" value="resource://org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl"/>
  -        </target-language>
  -      </component-instance>
  -    </component-type>
  -  </component>
  -
  -  <component role="program-generator" class="org.apache.cocoon.components.language.generator.ProgramGeneratorImpl">
  -    <parameter name="repository" value="/tmp/repository"/>
  -    <parameter name="auto-reload" value="true"/>
  -  </component>
  -
  -<!-- ===================== Pipeline Components =========================== -->
  -
  -  <generator  name="file"      class="org.apache.cocoon.generation.FileGenerator"/>
  -  <generator  name="request"   class="org.apache.cocoon.generation.RequestGenerator"/>
  -  <generator  name="directory" class="org.apache.cocoon.generation.DirectoryGenerator"/>
  -  <generator  name="serverpages" class="org.apache.cocoon.generation.ServerPagesGenerator"/>
  -  <generator  name="status"    class="org.apache.cocoon.generation.StatusGenerator"/>  
  -
  -  <transformer     name="xslt"      class="org.apache.cocoon.transformation.XalanTransformer"/>
  -  <transformer     name="log"       class="org.apache.cocoon.transformation.LogTransformer"/>
  -  <transformer     name="sql"       class="org.apache.cocoon.transformation.SQLTransformer"/>
  -  <transformer     name="xinclude"  class="org.apache.cocoon.transformation.XIncludeTransformer"/>
  -  
  -  <serializer name="xml"       class="org.apache.cocoon.serialization.XMLSerializer"/>
  -  <serializer name="html"      class="org.apache.cocoon.serialization.HTMLSerializer"/>
  -  <serializer name="fo2pdf"    class="org.apache.cocoon.serialization.FO2PDFSerializer"/>
  -  <serializer name="svg2jpg"   class="org.apache.cocoon.serialization.SVGSerializer"/>
  -  <serializer name="image"     class="org.apache.cocoon.serialization.ImageSerializer"/>
  -  
  -<!-- ============================== Sitemap ================================ -->
  -  
  -  <sitemap>
  -    <partition>
  -
  -      <process uri="welcome" source="documents/welcome.xml">
  -        <generator name="file"/>
  -        <transformer name="xslt">
  -          <parameter name="stylesheet" value="stylesheets/simple-welcome2html.xsl"/>
  -        </transformer>
  -        <serializer name="html">
  -          <parameter name="contentType" value="text/html"/>
  -        </serializer>
  -      </process>
  -
  -      <process uri="hello" source="documents/hello-page.xml">
  -        <generator name="file"/>
  -        <transformer name="xslt">
  -          <parameter name="stylesheet" value="stylesheets/simple-page2html.xsl"/>
  -        </transformer>
  -        <serializer name="html">
  -          <parameter name="contentType" value="text/html"/>
  -        </serializer>
  -      </process>
  -
  -      <process uri="java.apache.org" source="documents/java_apache_org.xml">
  -        <generator name="file"/>
  -        <transformer name="xslt">
  -          <parameter name="stylesheet" value="stylesheets/java_apache_org-html.xsl"/>
  -        </transformer>
  -        <serializer name="html">
  -          <parameter name="contentType" value="text/html"/>
  -        </serializer>
  -      </process>
  -
  -      <process uri="jakarta.apache.org" source="documents/jakarta_apache_org.xml">
  -        <generator name="file"/>
  -        <transformer name="xslt">
  -          <parameter name="stylesheet" value="stylesheets/jakarta_apache_org-html.xsl"/>
  -        </transformer>
  -        <serializer name="html">
  -          <parameter name="contentType" value="text/html"/>
  -        </serializer>
  -      </process>
  -
  -      <process uri="simple_dynamic_page" source="documents/simple-dynamic-page.xsp">
  -        <generator name="serverpages"/>
  -        <transformer name="xslt">
  -          <parameter name="stylesheet" value="stylesheets/dynamic-page2html.xsl"/>
  -        </transformer>
  -        <serializer name="html">
  -          <parameter name="contentType" value="text/html"/>
  -        </serializer>
  -      </process>
  -
  -      <process uri="status" source="status">
  -        <generator name="status"/>
  -        <filter name="xslt">
  -          <parameter name="stylesheet" value="stylesheets/simple-status.xsl"/>
  -        </filter>
  -        <serializer name="html">
  -          <parameter name="contentType" value="text/html"/>
  -        </serializer>
  -      </process>      
  -
  -      <process uri="**/" source="**/">
  -        <generator name="directory"/>
  -        <transformer name="xslt">
  -          <parameter name="stylesheet" value="stylesheets/simple-directory2html.xsl"/>
  -        </transformer>
  -        <serializer name="html">
  -          <parameter name="contentType" value="text/html"/>
  -        </serializer>
  -      </process>
  -
  -    </partition>
  -  </sitemap>
  -</cocoon>
  +<?xml version="1.0"?>
  +<cocoon version="2.0">
  +
  +<!-- ===================== General Components =========================== -->
  +
  +  <component role="parser" class="org.apache.cocoon.components.parser.XercesParser"/>
  +  <component role="store" class="org.apache.cocoon.components.store.MemoryStore"/>
  +
  +  <component role="factory" class="org.apache.avalon.NamedComponentManagerImpl">
  +    <component-type name="programming-language">
  +      <component-instance name="java" class="org.apache.cocoon.components.language.programming.java.JavaLanguage">
  +        <parameter name="compiler" value="org.apache.cocoon.components.language.programming.java.Javac"/>
  +        <parameter name="code-formatter" value="org.apache.cocoon.components.language.programming.java.JstyleFormatter"/>
  +        <parameter name="class-loader" value="org.apache.cocoon.components.classloader.ClassLoaderManagerImpl"/>
  +      </component-instance>
  +    </component-type>
  +
  +    <component-type name="markup-language">
  +      <component-instance name="xsp" class="org.apache.cocoon.components.language.markup.xsp.XSPMarkupLanguage">
  +        <parameter name="prefix" value="xsp"/>
  +        <parameter name="uri" value="http://xml.apache.org/cocoon/xsp"/>
  +  
  +        <target-language name="java">
  +          <parameter name="core-logicsheet" value="resource://org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl"/>
  +
  +          <builtin-logicsheet>
  +            <parameter name="prefix" value="xsp-request"/>
  +            <parameter name="uri" value="http://xml.apache.org/cocoon/xsp/request"/>
  +            <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/java/request.xsl"/>
  +          </builtin-logicsheet>
  +
  +          <builtin-logicsheet>
  +            <parameter name="prefix" value="xsp-response"/>
  +            <parameter name="uri" value="http://xml.apache.org/cocoon/xsp/response"/>
  +            <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/java/request.xsl"/>
  +          </builtin-logicsheet>
  +        </target-language>
  +      </component-instance>
  +
  +      <component-instance name="sitemap" class="org.apache.cocoon.components.language.markup.sitemap.SitemapMarkupLanguage">
  +        <parameter name="prefix" value="map"/>
  +        <parameter name="uri" value="http://apache.org/cocoon/sitemap/1.0"/>
  +  
  +        <target-language name="java">
  +          <parameter name="core-logicsheet" value="resource://org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl"/>
  +        </target-language>
  +      </component-instance>
  +    </component-type>
  +  </component>
  +
  +  <component role="program-generator" class="org.apache.cocoon.components.language.generator.ProgramGeneratorImpl">
  +    <parameter name="repository" value="/tmp/repository"/>
  +    <parameter name="auto-reload" value="true"/>
  +  </component>
  +
  +  <sitemap file="/opt/tomcatc2/webapps/cocoon/sitemap.xmap"/> 
  +</cocoon>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +152 -0    xml-cocoon/conf/Attic/cocoon.xconf.old
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +2 -2      xml-cocoon/src/Manifest.mf
  
  Index: Manifest.mf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/Manifest.mf,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- Manifest.mf	1999/11/30 16:30:03	1.1
  +++ Manifest.mf	2000/07/22 20:41:28	1.1.2.1
  @@ -1,2 +1,2 @@
  -Manifest-Version: 1.0
  -Main-Class: org.apache.cocoon.Cocoon
  +Manifest-Version: 1.0
  +Main-Class: org.apache.cocoon.Cocoon
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.12  +225 -273  xml-cocoon/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.4.2.11
  retrieving revision 1.4.2.12
  diff -u -r1.4.2.11 -r1.4.2.12
  --- Cocoon.java	2000/07/20 21:56:53	1.4.2.11
  +++ Cocoon.java	2000/07/22 20:41:29	1.4.2.12
  @@ -1,273 +1,225 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  -
  -import java.io.File;
  -import java.io.FileNotFoundException;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.FileReader;
  -import java.net.URL;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import org.apache.avalon.Component;
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.ComponentManager;
  -import org.apache.avalon.ComponentNotFoundException;
  -import org.apache.avalon.ComponentNotAccessibleException;
  -import org.apache.avalon.Modifiable;
  -import org.apache.avalon.Configurable;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  -import org.apache.avalon.SAXConfigurationBuilder;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.serialization.Serializer;
  -import org.apache.cocoon.sitemap.Sitemap;
  -import org.xml.sax.EntityResolver;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.4.2.11 $ $Date: 2000/07/20 21:56:53 $
  - */
  -public class Cocoon
  -implements Component, Configurable, ComponentManager, Modifiable, Processor,
  -           EntityResolver {
  -
  -    /** The table of role-class */
  -    private Hashtable components=new Hashtable();
  -    /** The table of role-configuration */
  -    private Hashtable configurations=new Hashtable();
  -    /** The configuration file */
  -    private File configurationFile=null;
  -    /** The configuration tree */
  -    private Configuration configuration=null;
  -    /** The sitemap */
  -    private Sitemap sitemap=null;
  -    /** The root uri/path */
  -    private URL root=null;
  -        
  -    private org.apache.cocoon.sitemap.SitemapProcessor processor = null;
  -
  -    /**
  -     * Create a new <code>Cocoon</code> instance.
  -     */
  -    protected Cocoon()
  -    throws ConfigurationException {
  -        super();
  -        // Setup the default parser, for parsing configuration.
  -        // If one need to use a different parser, set the given system property
  -        String parser=null;
  -        parser=System.getProperty("org.apache.cocoon.components.parser.Parser",
  -                            "org.apache.cocoon.components.parser.XercesParser");
  -        this.components.put("parser",this.getClass(parser,null));
  -    }
  -
  -    /**
  -     * Create a new <code>Cocoon</code> object, parsing configuration from
  -     * the specified file.
  -     */
  -    public Cocoon(String configuration)
  -    throws SAXException, IOException, ConfigurationException {
  -        this();
  -        this.configurationFile=new File(configuration).getCanonicalFile();
  -        if (!this.configurationFile.isFile())
  -            throw new FileNotFoundException(configuration);
  -        Parser p=(Parser)this.getComponent("parser");
  -        SAXConfigurationBuilder b=new SAXConfigurationBuilder();
  -        p.setContentHandler(b);
  -        String path = this.configurationFile.getPath();
  -        InputSource is = new InputSource(new FileReader(path));
  -        is.setSystemId(path);
  -        p.parse(is);
  -        this.setConfiguration(b.getConfiguration());
  -        this.root=this.configurationFile.getParentFile().toURL();
  -/*
  -        try {
  -            generateSitemap ("/opt/giacomo/java/CVS/xml-cocoon2/test/xdocs/drafts/sitemap.xmap"); 
  -        } catch (org.apache.cocoon.ProcessingException pe) {
  -            throw new IOException (pe.getMessage());
  -        } */
  -    }
  -
  -    /**
  -     * Set the cocoon root.
  -     * @param root The new Cocoon root.
  -     */
  -    public void setRoot(URL root) {
  -        this.root = root;
  -    }
  - 
  -    /**
  -     * Get the <code>Component</code> associated with the given role.
  -     */
  -    public Component getComponent(String role)
  -    throws ComponentNotFoundException, ComponentNotAccessibleException {
  -        if (role==null) throw new ComponentNotFoundException("Null role");
  -        if (role.equals("cocoon")) return(this);
  -        Class c=(Class)this.components.get(role);
  -        if (c==null)
  -            throw new ComponentNotFoundException("Can't find component "+role);
  -        try {
  -            Component comp=(Component)c.newInstance();
  -            if (comp instanceof Configurable) {
  -                Configuration conf=(Configuration)this.configurations.get(role);
  -                if (conf!=null) ((Configurable)comp).setConfiguration(conf);
  -            }
  -            if (comp instanceof Composer)
  -                ((Composer)comp).setComponentManager(this);
  -            return(comp);
  -        } catch (Exception e) {
  -            throw new ComponentNotAccessibleException("Can't access class "+
  -                        c.getName()+" with role "+role+" due to a "+
  -                        e.getClass().getName()+"("+e.getMessage()+")",e);
  -        }
  -    }
  -
  -    /**
  -     * Configure this <code>Cocoon</code> instance.
  -     */
  -    public void setConfiguration(Configuration conf)
  -     throws ConfigurationException {
  -        this.configuration=conf;
  -        if (!conf.getName().equals("cocoon"))
  -            throw new ConfigurationException("Invalid configuration file",conf);
  -        if (!conf.getAttribute("version").equals("2.0"))
  -            throw new ConfigurationException("Invalid version",conf);
  -        // Set generators, transformers and serializers
  -        String buf[]={"generator","transformer","serializer"};
  -        for (int x=0; x<buf.length; x++) {
  -            Enumeration e=conf.getConfigurations(buf[x]);
  -            while (e.hasMoreElements()) {
  -                Configuration co=(Configuration)e.nextElement();
  -                String na=co.getAttribute("name");
  -                String cl=co.getAttribute("class");
  -                String ro=buf[x]+":"+na;
  -                System.out.println("Adding component: "+ro);
  -                this.components.put(ro,this.getClass(cl,co));
  -                this.configurations.put(ro,co);
  -            }
  -        }
  -        // Set components
  -        Enumeration e=conf.getConfigurations("component");
  -        while (e.hasMoreElements()) {
  -            Configuration co=(Configuration)e.nextElement();
  -            String ro=co.getAttribute("role");
  -            String cl=co.getAttribute("class");
  -            System.out.println("Adding component: "+ro);
  -            this.components.put(ro,this.getClass(cl,co));
  -            this.configurations.put(ro,co);
  -        }
  -        // Create the sitemap
  -        Configuration sconf=conf.getConfiguration("sitemap");
  -        if (sconf==null)
  -            throw new ConfigurationException("No sitemap configuration",conf);
  -        this.sitemap=new Sitemap();
  -        this.sitemap.setComponentManager(this);
  -        this.sitemap.setConfiguration(sconf);
  -    }
  -
  -    /**
  -     * Queries the class to estimate its ergodic period termination.
  -     */
  -    public boolean modifiedSince(long date) {
  -        return(date<this.configurationFile.lastModified());
  -    }
  -
  -    /**
  -     * Process the given <code>Request</code> producing the output to the
  -     * specified <code>Response</code> and <code>OutputStream</code>.
  -     */
  -    public boolean process(Environment environment, OutputStream out) {return true;}
  -    public boolean process(Request req, Response res, OutputStream out)
  -    throws SAXException, IOException, ProcessingException {
  -        return(this.sitemap.process(req,res,out));
  -//        return(this.processor.process(req,res,out));
  -    }
  -
  -    /**
  -     * Resolve an entity.
  -     */
  -    public InputSource resolveEntity(String systemId)
  -    throws SAXException, IOException {
  -        return(this.resolveEntity(null,systemId));
  -    }
  -
  -    /**
  -     * Resolve an entity.
  -     */
  -    public InputSource resolveEntity(String publicId, String systemId)
  -    throws SAXException, IOException {
  -        if (systemId==null) throw new SAXException("Invalid System ID");
  -
  -        if (systemId.length()==0)
  -            return new InputSource(this.root.toExternalForm());
  -        if (systemId.indexOf(":/")>0)
  -            return new InputSource(systemId);
  -        if (systemId.charAt(0)=='/')
  -            return new InputSource(this.root.getProtocol()+":"+systemId);
  -        return(new InputSource(new URL(this.root,systemId).toExternalForm()));
  -    }
  -
  -    /** Get a new class */
  -    private Class getClass(String className, Configuration conf)
  -    throws ConfigurationException {
  -        // This is better than Class.forName() because components should be
  -        // loaded by the same classloader that loaded Cocoon (they should
  -        // be in the same jar file, or directory.
  -        try {
  -            return(this.getClass().getClassLoader().loadClass(className));
  -        } catch (ClassNotFoundException e) {
  -            throw new ConfigurationException("Cannot load class "+className,
  -                conf);
  -        }
  -    }
  -
  -    /** Generate the Sitemap class */
  -    private void generateSitemap (String sitemapName) 
  -            throws java.net.MalformedURLException, IOException, 
  -                   org.apache.cocoon.ProcessingException {
  -
  -        InputSource inputSource = new InputSource (sitemapName);
  -        String systemId = inputSource.getSystemId();
  -        System.out.println ("C2 generateSitemap: "+systemId);
  -
  -        File file = new File(systemId);
  -
  -        if (!file.canRead()) {
  -            throw new IOException("Can't read file: " + systemId);
  -        }
  -
  -        String markupLanguage = "sitemap";
  -        String programmingLanguage = "java";
  -
  -        org.apache.cocoon.components.language.generator.ProgramGenerator programGenerator = null;
  -
  -        System.out.println ("C2 generateSitemap: obtaining programGenerator");
  -        programGenerator = 
  -            (org.apache.cocoon.components.language.generator.ProgramGenerator) getComponent("program-generator");
  -        System.out.println ("C2 generateSitemap: programGenerator obtained");
  -
  -        System.out.println ("C2 generateSitemap: obtaining generator");
  -        try {
  -            processor = (org.apache.cocoon.sitemap.SitemapProcessor)
  -                programGenerator.load(file, markupLanguage, programmingLanguage);
  -            System.out.println ("C2 generateSitemap: generator obtained");
  -            processor.setComponentManager(this);
  -            processor.setConfiguration(null);
  -            System.out.println ("C2 generateSitemap: generator called");
  -        } catch (Exception e) {
  -            e.printStackTrace();
  -            throw new org.apache.cocoon.ProcessingException (e.getMessage());    
  -        }
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  +
  +import java.io.File;
  +import java.io.FileNotFoundException;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.FileReader;
  +import java.net.URL;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +
  +import org.apache.avalon.Component;
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.ComponentManager;
  +import org.apache.avalon.ComponentNotFoundException;
  +import org.apache.avalon.ComponentNotAccessibleException;
  +import org.apache.avalon.Modifiable;
  +import org.apache.avalon.Configurable;
  +import org.apache.avalon.Configuration;
  +import org.apache.avalon.ConfigurationException;
  +import org.apache.avalon.SAXConfigurationBuilder;
  +
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.serialization.Serializer;
  +import org.apache.cocoon.sitemap.SitemapManager;
  +
  +import org.xml.sax.EntityResolver;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.4.2.12 $ $Date: 2000/07/22 20:41:29 $
  + */
  +public class Cocoon
  +implements Component, Configurable, ComponentManager, Modifiable, Processor,
  +           EntityResolver {
  +
  +    /** The table of role-class */
  +    private Hashtable components=new Hashtable();
  +    /** The table of role-configuration */
  +    private Hashtable configurations=new Hashtable();
  +    /** The configuration file */ 
  +    private File configurationFile=null; 
  +    /** The sitemap file */ 
  +    private String sitemapFileName=null; 
  +    /** The configuration tree */
  +    private Configuration configuration=null;
  +    /** The sitemap manager */
  +    private SitemapManager sitemapManager=null;
  +    /** The root uri/path */
  +    private URL root=null;
  +        
  +    /**
  +     * Create a new <code>Cocoon</code> instance.
  +     */
  +    protected Cocoon()
  +    throws ConfigurationException {
  +        super();
  +        // Setup the default parser, for parsing configuration.
  +        // If one need to use a different parser, set the given system property
  +        String parser=null;
  +        parser=System.getProperty("org.apache.cocoon.components.parser.Parser",
  +                            "org.apache.cocoon.components.parser.XercesParser");
  +        this.components.put("parser",this.getClass(parser,null));
  +    }
  +
  +    /**
  +     * Create a new <code>Cocoon</code> object, parsing configuration from
  +     * the specified file.
  +     */
  +    public Cocoon(String configuration)
  +    throws SAXException, IOException, ConfigurationException {
  +        this();
  +        this.configurationFile=new File(configuration).getCanonicalFile();
  +        if (!this.configurationFile.isFile())
  +            throw new FileNotFoundException(configuration);
  +        Parser p=(Parser)this.getComponent("parser");
  +        SAXConfigurationBuilder b=new SAXConfigurationBuilder();
  +        p.setContentHandler(b);
  +        String path = this.configurationFile.getPath();
  +        InputSource is = new InputSource(new FileReader(path));
  +        is.setSystemId(path);
  +        p.parse(is);
  +        this.setConfiguration(b.getConfiguration());
  +        this.root=this.configurationFile.getParentFile().toURL();
  +/*
  +        try {
  +            generateSitemap ("/opt/giacomo/java/CVS/xml-cocoon2/test/xdocs/drafts/sitemap.xmap"); 
  +        } catch (org.apache.cocoon.ProcessingException pe) {
  +            throw new IOException (pe.getMessage());
  +        } */
  +    }
  +
  +    /**
  +     * Set the cocoon root.
  +     * @param root The new Cocoon root.
  +     */
  +    public void setRoot(URL root) {
  +        this.root = root;
  +    }
  + 
  +    /**
  +     * Get the <code>Component</code> associated with the given role.
  +     */
  +    public Component getComponent(String role)
  +    throws ComponentNotFoundException, ComponentNotAccessibleException {
  +        if (role==null) throw new ComponentNotFoundException("Null role");
  +        if (role.equals("cocoon")) return(this);
  +        Class c=(Class)this.components.get(role);
  +        if (c==null)
  +            throw new ComponentNotFoundException("Can't find component "+role);
  +        try {
  +            Component comp=(Component)c.newInstance();
  +            if (comp instanceof Composer)
  +                ((Composer)comp).setComponentManager(this);
  +            if (comp instanceof Configurable) {
  +                Configuration conf=(Configuration)this.configurations.get(role);
  +                if (conf!=null) ((Configurable)comp).setConfiguration(conf);
  +            }
  +            return(comp);
  +        } catch (Exception e) {
  +            throw new ComponentNotAccessibleException("Can't access class "+
  +                        c.getName()+" with role "+role+" due to a "+
  +                        e.getClass().getName()+"("+e.getMessage()+")",e);
  +        }
  +    }
  +
  +    /**
  +     * Configure this <code>Cocoon</code> instance.
  +     */
  +    public void setConfiguration(Configuration conf)
  +     throws ConfigurationException {
  +        this.configuration=conf;
  +        if (!conf.getName().equals("cocoon"))
  +            throw new ConfigurationException("Invalid configuration file",conf);
  +        if (!conf.getAttribute("version").equals("2.0"))
  +            throw new ConfigurationException("Invalid version",conf);
  +        // Set components
  +        Enumeration e=conf.getConfigurations("component");
  +        while (e.hasMoreElements()) {
  +            Configuration co=(Configuration)e.nextElement();
  +            String ro=co.getAttribute("role");
  +            String cl=co.getAttribute("class");
  +            System.out.println("Adding component: "+ro);
  +            this.components.put(ro,this.getClass(cl,co));
  +            this.configurations.put(ro,co);
  +        }
  +        // Create the sitemap
  +        Configuration sconf=conf.getConfiguration("sitemap");
  +        if (sconf==null)
  +            throw new ConfigurationException("No sitemap configuration",conf);
  +        this.sitemapManager=new SitemapManager();
  +        this.sitemapManager.setComponentManager(this);
  +        this.sitemapManager.setConfiguration(conf);
  +        this.sitemapFileName = sconf.getAttribute("file");
  +        System.out.println("The root sitemap is located at \""+this.sitemapFileName+"\"");
  +    }
  +
  +    /**
  +     * Queries the class to estimate its ergodic period termination.
  +     */
  +    public boolean modifiedSince(long date) {
  +        return(date<this.configurationFile.lastModified());
  +    }
  +
  +    /**
  +     * Process the given <code>Environment</code> producing the output to the
  +     * specified <code>OutputStream</code>.
  +     */
  +    public boolean process(Environment environment, OutputStream out) 
  +    throws SAXException, IOException, ProcessingException, 
  +           InterruptedException  {
  +        return (this.sitemapManager.invoke (environment, "",
  +                                    this.sitemapFileName, true, out));
  +    }
  +
  +    /**
  +     * Resolve an entity.
  +     */
  +    public InputSource resolveEntity(String systemId)
  +    throws SAXException, IOException {
  +        return(this.resolveEntity(null,systemId));
  +    }
  +
  +    /**
  +     * Resolve an entity.
  +     */
  +    public InputSource resolveEntity(String publicId, String systemId)
  +    throws SAXException, IOException {
  +        if (systemId==null) throw new SAXException("Invalid System ID");
  +
  +        if (systemId.length()==0)
  +            return new InputSource(this.root.toExternalForm());
  +        if (systemId.indexOf(":/")>0)
  +            return new InputSource(systemId);
  +        if (systemId.charAt(0)=='/')
  +            return new InputSource(this.root.getProtocol()+":"+systemId);
  +        return(new InputSource(new URL(this.root,systemId).toExternalForm()));
  +    }
  +
  +    /** Get a new class */
  +    private Class getClass(String className, Configuration conf)
  +    throws ConfigurationException {
  +        // This is better than Class.forName() because components should be
  +        // loaded by the same classloader that loaded Cocoon (they should
  +        // be in the same jar file, or directory.
  +        try {
  +            return(this.getClass().getClassLoader().loadClass(className));
  +        } catch (ClassNotFoundException e) {
  +            throw new ConfigurationException("Cannot load class "+className,
  +                conf);
  +        }
  +    }
  +}
  
  
  
  1.1.2.5   +23 -23    xml-cocoon/src/org/apache/cocoon/Attic/ProcessingException.java
  
  Index: ProcessingException.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/ProcessingException.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- ProcessingException.java	2000/02/27 01:33:04	1.1.2.4
  +++ ProcessingException.java	2000/07/22 20:41:29	1.1.2.5
  @@ -1,24 +1,24 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/02/27 01:33:04 $
  - */
  -public class ProcessingException extends Exception {
  -
  -    /**
  -     * Construct a new <code>ProcessingException</code> instance.
  -     */
  -    public ProcessingException(String message) {
  -        super(message);
  -    }
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:29 $
  + */
  +public class ProcessingException extends Exception {
  +
  +    /**
  +     * Construct a new <code>ProcessingException</code> instance.
  +     */
  +    public ProcessingException(String message) {
  +        super(message);
  +    }
   }
  
  
  
  1.1.2.4   +30 -33    xml-cocoon/src/org/apache/cocoon/Attic/Processor.java
  
  Index: Processor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/Processor.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- Processor.java	2000/07/20 21:56:54	1.1.2.3
  +++ Processor.java	2000/07/22 20:41:29	1.1.2.4
  @@ -1,33 +1,30 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  -
  -import java.io.IOException;
  -import java.io.OutputStream;
  -
  -import org.xml.sax.SAXException;
  -
  -import org.apache.cocoon.environment.Environment;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/20 21:56:54 $
  - */
  -public interface Processor {
  -    /**
  -     * Process the given <code>Request</code> producing the output to the
  -     * specified <code>Response</code> and <code>OutputStream</code>.
  -     */
  -    public boolean process(Request req, Response res, OutputStream out)
  -    throws SAXException, IOException, ProcessingException;
  -
  -    public boolean process(Environment environment, OutputStream out)
  -    throws SAXException, IOException, ProcessingException;
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  +
  +import java.io.IOException;
  +import java.io.OutputStream;
  +
  +import org.xml.sax.SAXException;
  +
  +import org.apache.cocoon.environment.Environment;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:29 $
  + */
  +public interface Processor {
  +    /**
  +     * Process the given <code>Environment</code> producing the output to the
  +     * specified <code>OutputStream</code>.
  +     */
  +    public boolean process(Environment environment, OutputStream out)
  +    throws SAXException, IOException, ProcessingException, InterruptedException;
  +}
  
  
  
  1.1.2.5   +66 -66    xml-cocoon/src/org/apache/cocoon/Attic/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/Request.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- Request.java	2000/02/27 01:33:05	1.1.2.4
  +++ Request.java	2000/07/22 20:41:29	1.1.2.5
  @@ -1,66 +1,66 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  -
  -import java.util.Enumeration;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/02/27 01:33:05 $
  - */
  -public interface Request {
  -    /**
  -     * Returns the URI as it should be matched by the <code>Sitemap</code>
  -     */
  -    public String getUri();
  -
  -    /**
  -     * Returns the value of the specified parameter, or <code>null</code> if
  -     * the parameter does not exist.
  -     */
  -    public String getParameter(String name);
  -
  -    /**
  -     * Returns the values of the specified parameter for the request as an
  -     * array of strings, or <code>null</code> if the parameter does not exist.
  -     */
  -    public String[] getParameterValues(String name);
  -
  -    /**
  -     * Returns the parameter names for this request as an
  -     * <code>Enumeration</code> of <code>String</code> objects , or an empty
  -     * <code>Enumeration</code> if there are no parameters.
  -     */
  -    public Enumeration getParameterNames();
  -
  -    /**
  -     * Gets the value of the requested header field of this request.
  -     */
  -    public String getHeader(String name);
  -
  -    /**
  -     * Gets the value of the requested header field of this request as an
  -     * integer.
  -     */
  -    public int getIntHeader(String name);
  -
  -    /**
  -     * Gets the value of the requested header field of this request as a
  -     * date.
  -     */
  -    public long getDateHeader(String name);
  -
  -    /**
  -     * Returns the header names for this request as an
  -     * <code>Enumeration</code> of <code>String</code> objects , or an empty
  -     * <code>Enumeration</code> if there are no headers.
  -     */
  -    public Enumeration getHeaderNames();
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  +
  +import java.util.Enumeration;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:29 $
  + */
  +public interface Request {
  +    /**
  +     * Returns the URI as it should be matched by the <code>Sitemap</code>
  +     */
  +    public String getUri();
  +
  +    /**
  +     * Returns the value of the specified parameter, or <code>null</code> if
  +     * the parameter does not exist.
  +     */
  +    public String getParameter(String name);
  +
  +    /**
  +     * Returns the values of the specified parameter for the request as an
  +     * array of strings, or <code>null</code> if the parameter does not exist.
  +     */
  +    public String[] getParameterValues(String name);
  +
  +    /**
  +     * Returns the parameter names for this request as an
  +     * <code>Enumeration</code> of <code>String</code> objects , or an empty
  +     * <code>Enumeration</code> if there are no parameters.
  +     */
  +    public Enumeration getParameterNames();
  +
  +    /**
  +     * Gets the value of the requested header field of this request.
  +     */
  +    public String getHeader(String name);
  +
  +    /**
  +     * Gets the value of the requested header field of this request as an
  +     * integer.
  +     */
  +    public int getIntHeader(String name);
  +
  +    /**
  +     * Gets the value of the requested header field of this request as a
  +     * date.
  +     */
  +    public long getDateHeader(String name);
  +
  +    /**
  +     * Returns the header names for this request as an
  +     * <code>Enumeration</code> of <code>String</code> objects , or an empty
  +     * <code>Enumeration</code> if there are no headers.
  +     */
  +    public Enumeration getHeaderNames();
  +}
  
  
  
  1.1.2.5   +37 -37    xml-cocoon/src/org/apache/cocoon/Attic/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/Response.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- Response.java	2000/02/27 01:33:05	1.1.2.4
  +++ Response.java	2000/07/22 20:41:29	1.1.2.5
  @@ -1,37 +1,37 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/02/27 01:33:05 $
  - */
  -public interface Response {
  -    /**
  -     * Adds a field to the response header with the given name and value.
  -     */
  -    public void setHeader(String name, String value);
  -
  -    /**
  -     * Adds a field to the response header with the given name and int value.
  -     */
  -    public void setIntHeader(String name, int value);
  -
  -    /**
  -     * Adds a field to the response header with the given name and date-valued
  -     * field.
  -     */
  -    public void setDateHeader(java.lang.String name, long date);
  -
  -    /**
  -     * Sets the content type for this response.
  -     */
  -    public void setContentType(String type);
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:29 $
  + */
  +public interface Response {
  +    /**
  +     * Adds a field to the response header with the given name and value.
  +     */
  +    public void setHeader(String name, String value);
  +
  +    /**
  +     * Adds a field to the response header with the given name and int value.
  +     */
  +    public void setIntHeader(String name, int value);
  +
  +    /**
  +     * Adds a field to the response header with the given name and date-valued
  +     * field.
  +     */
  +    public void setDateHeader(java.lang.String name, long date);
  +
  +    /**
  +     * Sets the content type for this response.
  +     */
  +    public void setContentType(String type);
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +46 -46    xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/ClassLoaderManager.java
  
  Index: ClassLoaderManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/ClassLoaderManager.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ClassLoaderManager.java	2000/07/11 03:09:36	1.1.2.2
  +++ ClassLoaderManager.java	2000/07/22 20:41:30	1.1.2.3
  @@ -1,46 +1,46 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.classloader;
  -
  -import org.apache.avalon.Component;
  -
  -import java.io.IOException;
  -
  -/**
  - * A class loader manager acting as a proxy for a <b>single</b>
  - * <code>RepositoryClassLoader</code>.
  - * This class guarantees that a single class loader instance exists so
  - * that it can be safely reinstantiated for dynamic class reloading
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:09:36 $
  - */
  -public interface ClassLoaderManager extends Component {
  -  /**
  -   * Add a directory to the proxied class loader
  -   *
  -   * @param directoryName The repository name
  -   * @exception IOException If the directory is invalid
  -   */
  -  public void addDirectory(String directoryName) throws IOException;
  -
  -  /**
  -   * Load a class through the proxied class loader
  -   *
  -   * @param className The name of the class to be loaded
  -   * @return The loaded class
  -   * @exception ClassNotFoundException If the class is not found
  -   */
  -  public Class loadClass(String className) throws ClassNotFoundException;
  -
  -  /**
  -   * Reinstantiate the proxied class loader to allow for class reloading
  -   *
  -   */
  -  public void reinstantiate();
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.classloader;
  +
  +import org.apache.avalon.Component;
  +
  +import java.io.IOException;
  +
  +/**
  + * A class loader manager acting as a proxy for a <b>single</b>
  + * <code>RepositoryClassLoader</code>.
  + * This class guarantees that a single class loader instance exists so
  + * that it can be safely reinstantiated for dynamic class reloading
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:30 $
  + */
  +public interface ClassLoaderManager extends Component {
  +  /**
  +   * Add a directory to the proxied class loader
  +   *
  +   * @param directoryName The repository name
  +   * @exception IOException If the directory is invalid
  +   */
  +  public void addDirectory(String directoryName) throws IOException;
  +
  +  /**
  +   * Load a class through the proxied class loader
  +   *
  +   * @param className The name of the class to be loaded
  +   * @return The loaded class
  +   * @exception ClassNotFoundException If the class is not found
  +   */
  +  public Class loadClass(String className) throws ClassNotFoundException;
  +
  +  /**
  +   * Reinstantiate the proxied class loader to allow for class reloading
  +   *
  +   */
  +  public void reinstantiate();
  +}
  
  
  
  1.1.2.2   +62 -62    xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/ClassLoaderManagerImpl.java
  
  Index: ClassLoaderManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/ClassLoaderManagerImpl.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ClassLoaderManagerImpl.java	2000/05/23 23:09:53	1.1.2.1
  +++ ClassLoaderManagerImpl.java	2000/07/22 20:41:30	1.1.2.2
  @@ -1,62 +1,62 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.classloader;
  -
  -import java.io.IOException;
  -
  -/**
  - * A singleton-like implementation of <code>ClassLoaderManager</code>
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:53 $
  - */
  -public class ClassLoaderManagerImpl implements ClassLoaderManager {
  -  /**
  -   * The single class loader instance
  -   */
  -  protected static RepositoryClassLoader instance = null;
  -
  -  /**
  -   * A constructor that ensures only a single class loader instance exists
  -   *
  -   */
  -  public ClassLoaderManagerImpl() {
  -    if (instance == null) {
  -      instance = new RepositoryClassLoader();
  -    }
  -  }
  -
  -  /**
  -   * Add a directory to the proxied class loader
  -   *
  -   * @param directoryName The repository name
  -   * @exception IOException If the directory is invalid
  -   */
  -  public void addDirectory(String directoryName) throws IOException {
  -    instance.addDirectory(directoryName);
  -  }
  -
  -  /**
  -   * Load a class through the proxied class loader
  -   *
  -   * @param className The name of the class to be loaded
  -   * @return The loaded class
  -   * @exception ClassNotFoundException If the class is not found
  -   */
  -  public Class loadClass(String className) throws ClassNotFoundException {
  -    return instance.loadClass(className);
  -  }
  -
  -  /**
  -   * Reinstantiate the proxied class loader to allow for class reloading
  -   *
  -   */
  -  public synchronized void reinstantiate() {
  -    instance = new RepositoryClassLoader();
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.classloader;
  +
  +import java.io.IOException;
  +
  +/**
  + * A singleton-like implementation of <code>ClassLoaderManager</code>
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:30 $
  + */
  +public class ClassLoaderManagerImpl implements ClassLoaderManager {
  +  /**
  +   * The single class loader instance
  +   */
  +  protected static RepositoryClassLoader instance = null;
  +
  +  /**
  +   * A constructor that ensures only a single class loader instance exists
  +   *
  +   */
  +  public ClassLoaderManagerImpl() {
  +    if (instance == null) {
  +      instance = new RepositoryClassLoader();
  +    }
  +  }
  +
  +  /**
  +   * Add a directory to the proxied class loader
  +   *
  +   * @param directoryName The repository name
  +   * @exception IOException If the directory is invalid
  +   */
  +  public void addDirectory(String directoryName) throws IOException {
  +    instance.addDirectory(directoryName);
  +  }
  +
  +  /**
  +   * Load a class through the proxied class loader
  +   *
  +   * @param className The name of the class to be loaded
  +   * @return The loaded class
  +   * @exception ClassNotFoundException If the class is not found
  +   */
  +  public Class loadClass(String className) throws ClassNotFoundException {
  +    return instance.loadClass(className);
  +  }
  +
  +  /**
  +   * Reinstantiate the proxied class loader to allow for class reloading
  +   *
  +   */
  +  public synchronized void reinstantiate() {
  +    instance = new RepositoryClassLoader();
  +  }
  +}
  
  
  
  1.1.2.2   +187 -187  xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/RepositoryClassLoader.java
  
  Index: RepositoryClassLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/RepositoryClassLoader.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- RepositoryClassLoader.java	2000/05/23 23:09:54	1.1.2.1
  +++ RepositoryClassLoader.java	2000/07/22 20:41:30	1.1.2.2
  @@ -1,187 +1,187 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.classloader;
  -
  -import java.util.Vector;
  -
  -import java.io.File;
  -import java.io.FileInputStream;
  -
  -import java.io.IOException;
  -
  -import org.apache.cocoon.util.IOUtils;
  -
  -/**
  - * A class loader with a growable list of path search directories
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:54 $
  - */
  -class RepositoryClassLoader extends ClassLoader {
  -  /**
  -   * The list of searchable directories
  -   */
  -  protected Vector repositories;
  -
  -  /**
  -   * Create an empty new class loader.
  -   */
  -  public RepositoryClassLoader() {
  -    this.repositories = new Vector();
  -  }
  -
  -  /**
  -   * Create a class loader from a list of directories
  -   *
  -   * @param repositories List of searchable directories
  -   */
  -  protected RepositoryClassLoader(Vector repositories) {
  -    this.repositories = repositories;
  -  }
  -
  -  /**
  -   * Add a directory to the list of searchable repositories.
  -   * This methods ensures that no directory is specified more than once.
  -   *
  -   * @param directoryName The path directory
  -   * @exception IOException Non-existent, non-readable or non-directory
  -   * repository
  -   */
  -  public void addDirectory(String directoryName) throws IOException {
  -    File repository = new File(directoryName);
  -
  -    // Ensure the same directory isn't specified twice
  -    int count = this.repositories.size();
  -    String fullFilename = IOUtils.getFullFilename(repository);
  -    for (int i = 0; i < count; i++) {
  -      File directory = (File) this.repositories.elementAt(i);
  -      if (fullFilename.equals(IOUtils.getFullFilename(directory))) {
  -        return;
  -      }
  -    }
  -
  -    if (!repository.exists()) {
  -      throw new IOException("Non-existent: " + directoryName);
  -    }
  -
  -    if (!repository.isDirectory()) {
  -      throw new IOException("Not a directory: " + directoryName);
  -    }
  -
  -    if (!(repository.canRead() && repository.canWrite())) {
  -      throw new IOException("Not readable/writable: " + directoryName);
  -    }
  -
  -    this.repositories.addElement(repository);
  -  }
  -
  -  /**
  -   * Load a class using the parent class loader or, failing that,
  -   * from one of the stored repositories in definition order
  -   *
  -   * @param name The class name
  -   * @param resolve Whether the class name must be resolved
  -   * @return The loaded class
  -   * @exception ClassNotFoundException If the class is not found in any of the
  -   * repositories
  -   */
  -  protected Class loadClass (String name, boolean resolve)
  -    throws ClassNotFoundException
  -  {
  -    Class c = findLoadedClass(name);
  -
  -    if (c == null) {
  -      try {
  -        c = findSystemClass(name);
  -      } catch (ClassNotFoundException e) {
  -        byte[] bits = this.loadClassData (name);
  -
  -        if (bits == null) {
  -          // ClassLoader cl = getParent();
  -          ClassLoader cl = this.getClass().getClassLoader();
  -
  -          if (cl != null)  {
  -            c = cl.loadClass (name);
  -          }
  -        } else {
  -          c = defineClass (null, bits, 0, bits.length);
  -
  -          if (resolve) {
  -            resolveClass (c);
  -          }
  -        }
  -      }
  -
  -      if (c == null) {
  -        throw new ClassNotFoundException (name);
  -      }
  -    }
  -
  -    return c;
  -  }
  -
  -  /**
  -   * Load class from a file contained in a repository.
  -   *
  -   * @param className The class name
  -   * @return An array of byes containing the class data or <code>null</code> if
  -   * not founfd
  -   */
  -  protected byte[] loadClassData (String className) {
  -    int count = this.repositories.size();
  -    for (int i = 0; i < count; i++) {
  -      File repository = (File) this.repositories.elementAt(i);
  -      File file = new File(this.getClassFilename(className, repository));
  -
  -      if (file.exists() && file.isFile() && file.canRead()) {
  -        byte[] buffer = null;
  -        FileInputStream in = null;
  -    
  -        int n = 0;
  -        int pos = 0;
  -        buffer = new byte [(int) file.length ()];
  -  
  -        try {
  -          in = new FileInputStream(file);
  -  
  -          while (
  -            pos < buffer.length &&
  -            (n = in.read (buffer, pos, buffer.length - pos)) != -1
  -          ) {
  -            pos += n;
  -          }
  -
  -	  return buffer;
  -	} catch (IOException e) {
  -        } finally {
  -          if (in != null) {
  -            try { in.close(); }
  -            catch (IOException e) { }
  -          }
  -        }
  -      }
  -    }
  -
  -    return null;
  -  }
  -
  -  /**
  -   * Return the filename associated with a given class name in a given
  -   * directory
  -   *
  -   * @param className The class name for which a filename is to be generated
  -   * @param repository The directory containing the class file
  -   * @return The filename associated with a given class name in a given
  -   * directory
  -   */
  -  protected String getClassFilename(String className, File repository) {
  -    return
  -      repository.getAbsolutePath() + File.separator +
  -      className.replace('.', File.separatorChar) + ".class";
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.classloader;
  +
  +import java.util.Vector;
  +
  +import java.io.File;
  +import java.io.FileInputStream;
  +
  +import java.io.IOException;
  +
  +import org.apache.cocoon.util.IOUtils;
  +
  +/**
  + * A class loader with a growable list of path search directories
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:30 $
  + */
  +class RepositoryClassLoader extends ClassLoader {
  +  /**
  +   * The list of searchable directories
  +   */
  +  protected Vector repositories;
  +
  +  /**
  +   * Create an empty new class loader.
  +   */
  +  public RepositoryClassLoader() {
  +    this.repositories = new Vector();
  +  }
  +
  +  /**
  +   * Create a class loader from a list of directories
  +   *
  +   * @param repositories List of searchable directories
  +   */
  +  protected RepositoryClassLoader(Vector repositories) {
  +    this.repositories = repositories;
  +  }
  +
  +  /**
  +   * Add a directory to the list of searchable repositories.
  +   * This methods ensures that no directory is specified more than once.
  +   *
  +   * @param directoryName The path directory
  +   * @exception IOException Non-existent, non-readable or non-directory
  +   * repository
  +   */
  +  public void addDirectory(String directoryName) throws IOException {
  +    File repository = new File(directoryName);
  +
  +    // Ensure the same directory isn't specified twice
  +    int count = this.repositories.size();
  +    String fullFilename = IOUtils.getFullFilename(repository);
  +    for (int i = 0; i < count; i++) {
  +      File directory = (File) this.repositories.elementAt(i);
  +      if (fullFilename.equals(IOUtils.getFullFilename(directory))) {
  +        return;
  +      }
  +    }
  +
  +    if (!repository.exists()) {
  +      throw new IOException("Non-existent: " + directoryName);
  +    }
  +
  +    if (!repository.isDirectory()) {
  +      throw new IOException("Not a directory: " + directoryName);
  +    }
  +
  +    if (!(repository.canRead() && repository.canWrite())) {
  +      throw new IOException("Not readable/writable: " + directoryName);
  +    }
  +
  +    this.repositories.addElement(repository);
  +  }
  +
  +  /**
  +   * Load a class using the parent class loader or, failing that,
  +   * from one of the stored repositories in definition order
  +   *
  +   * @param name The class name
  +   * @param resolve Whether the class name must be resolved
  +   * @return The loaded class
  +   * @exception ClassNotFoundException If the class is not found in any of the
  +   * repositories
  +   */
  +  protected Class loadClass (String name, boolean resolve)
  +    throws ClassNotFoundException
  +  {
  +    Class c = findLoadedClass(name);
  +
  +    if (c == null) {
  +      try {
  +        c = findSystemClass(name);
  +      } catch (ClassNotFoundException e) {
  +        byte[] bits = this.loadClassData (name);
  +
  +        if (bits == null) {
  +          // ClassLoader cl = getParent();
  +          ClassLoader cl = this.getClass().getClassLoader();
  +
  +          if (cl != null)  {
  +            c = cl.loadClass (name);
  +          }
  +        } else {
  +          c = defineClass (null, bits, 0, bits.length);
  +
  +          if (resolve) {
  +            resolveClass (c);
  +          }
  +        }
  +      }
  +
  +      if (c == null) {
  +        throw new ClassNotFoundException (name);
  +      }
  +    }
  +
  +    return c;
  +  }
  +
  +  /**
  +   * Load class from a file contained in a repository.
  +   *
  +   * @param className The class name
  +   * @return An array of byes containing the class data or <code>null</code> if
  +   * not founfd
  +   */
  +  protected byte[] loadClassData (String className) {
  +    int count = this.repositories.size();
  +    for (int i = 0; i < count; i++) {
  +      File repository = (File) this.repositories.elementAt(i);
  +      File file = new File(this.getClassFilename(className, repository));
  +
  +      if (file.exists() && file.isFile() && file.canRead()) {
  +        byte[] buffer = null;
  +        FileInputStream in = null;
  +    
  +        int n = 0;
  +        int pos = 0;
  +        buffer = new byte [(int) file.length ()];
  +  
  +        try {
  +          in = new FileInputStream(file);
  +  
  +          while (
  +            pos < buffer.length &&
  +            (n = in.read (buffer, pos, buffer.length - pos)) != -1
  +          ) {
  +            pos += n;
  +          }
  +
  +	  return buffer;
  +	} catch (IOException e) {
  +        } finally {
  +          if (in != null) {
  +            try { in.close(); }
  +            catch (IOException e) { }
  +          }
  +        }
  +      }
  +    }
  +
  +    return null;
  +  }
  +
  +  /**
  +   * Return the filename associated with a given class name in a given
  +   * directory
  +   *
  +   * @param className The class name for which a filename is to be generated
  +   * @param repository The directory containing the class file
  +   * @return The filename associated with a given class name in a given
  +   * directory
  +   */
  +  protected String getClassFilename(String className, File repository) {
  +    return
  +      repository.getAbsolutePath() + File.separator +
  +      className.replace('.', File.separatorChar) + ".class";
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +23 -23    xml-cocoon/src/org/apache/cocoon/components/language/Attic/LanguageException.java
  
  Index: LanguageException.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/Attic/LanguageException.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- LanguageException.java	2000/05/23 23:09:55	1.1.2.1
  +++ LanguageException.java	2000/07/22 20:41:31	1.1.2.2
  @@ -1,23 +1,23 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language;
  -
  -/**
  - * The language exception.
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:55 $
  - */
  -public class LanguageException extends Exception {
  -  /**
  -   * The default constructor.
  -   */
  -  public LanguageException(String message) {
  -    super(message);
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language;
  +
  +/**
  + * The language exception.
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:31 $
  + */
  +public class LanguageException extends Exception {
  +  /**
  +   * The default constructor.
  +   */
  +  public LanguageException(String message) {
  +    super(message);
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +36 -36    xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGenerator.java
  
  Index: ProgramGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGenerator.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- ProgramGenerator.java	2000/07/11 03:09:37	1.1.2.3
  +++ ProgramGenerator.java	2000/07/22 20:41:31	1.1.2.4
  @@ -1,36 +1,36 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.generator;
  -
  -import java.io.File;
  -import org.apache.avalon.Component;
  -
  -/**
  - * This interface defines a loader for programs automatically built from XML
  - * documents writeen in a <code>MarkupLanguage</code>
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/11 03:09:37 $
  - */
  -public interface ProgramGenerator extends Component {
  -  /**
  -   * Load a program built from an XML document written in a
  -   * <code>MarkupLanguage</code>
  -   *
  -   * @param file The input document's <code>File</code>
  -   * @param markupLanguage The <code>MarkupLanguage</code> in which the input
  -   * document is written
  -   * @param programmingLanguage The <code>ProgrammingLanguage</code> in which
  -   * the program must be written
  -   * @return The loaded object
  -   * @exception Exception If an error occurs during generation or loading
  -   */
  -  public Object load(
  -    File file, String markupLanguage, String programmingLanguage
  -  ) throws Exception;
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.generator;
  +
  +import java.io.File;
  +import org.apache.avalon.Component;
  +
  +/**
  + * This interface defines a loader for programs automatically built from XML
  + * documents writeen in a <code>MarkupLanguage</code>
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:31 $
  + */
  +public interface ProgramGenerator extends Component {
  +  /**
  +   * Load a program built from an XML document written in a
  +   * <code>MarkupLanguage</code>
  +   *
  +   * @param file The input document's <code>File</code>
  +   * @param markupLanguage The <code>MarkupLanguage</code> in which the input
  +   * document is written
  +   * @param programmingLanguage The <code>ProgrammingLanguage</code> in which
  +   * the program must be written
  +   * @return The loaded object
  +   * @exception Exception If an error occurs during generation or loading
  +   */
  +  public Object load(
  +    File file, String markupLanguage, String programmingLanguage
  +  ) throws Exception;
  +}
  
  
  
  1.1.2.5   +220 -220  xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGeneratorImpl.java
  
  Index: ProgramGeneratorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGeneratorImpl.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- ProgramGeneratorImpl.java	2000/07/11 03:09:37	1.1.2.4
  +++ ProgramGeneratorImpl.java	2000/07/22 20:41:31	1.1.2.5
  @@ -1,220 +1,220 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.generator;
  -
  -import java.io.File;
  -import java.io.FileReader;
  -
  -import org.apache.avalon.Modifiable;
  -
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.ComponentManager;
  -import org.apache.avalon.Configurable;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  -import org.apache.avalon.NamedComponentManager;
  -
  -import org.apache.avalon.utils.Parameters;
  -
  -import org.apache.cocoon.components.store.MemoryStore;
  -import org.apache.cocoon.components.store.FilesystemStore;
  -
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -import org.apache.cocoon.components.language.markup.MarkupLanguage;
  -import org.apache.cocoon.components.language.programming.CodeFormatter;
  -import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -
  -import org.apache.cocoon.util.IOUtils;
  -import org.apache.cocoon.util.DOMUtils;
  -
  -import org.w3c.dom.Document;
  -import org.w3c.dom.Document;
  -
  -
  -import org.xml.sax.InputSource;
  -import org.apache.avalon.Component;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -import java.io.FileNotFoundException;
  -
  -/**
  - * The default implementation of <code>ProgramGenerator</code>
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/11 03:09:37 $
  - */
  -public class ProgramGeneratorImpl
  -  implements ProgramGenerator, Composer, Configurable
  -{
  -  /** The in-memory store */
  -  protected MemoryStore cache = new MemoryStore();
  -
  -  /** The filesystem-based store */
  -  protected String repositoryName;
  -
  -  /** The component manager */
  -  protected ComponentManager manager;
  -
  -  /** The named component manager */
  -  protected NamedComponentManager factory;
  -
  -  /** The auto-reloading option */
  -  protected boolean autoReload = true;
  -
  -  /**
  -   * Set the global component manager. This method also sets the
  -   * <code>NamedComponentManager</code> used as language factory for both
  -   * markup and programming languages.
  -   *
  -   * @param manager The global component manager
  -   */
  -  public void setComponentManager(ComponentManager manager) {
  -    this.manager = manager;
  -
  -    this.factory =
  -      (NamedComponentManager) this.manager.getComponent("factory");
  -  }
  -
  -  /**
  -   * Set the sitemap-provided configuration. This method sets the persistent
  -   * code repository and the auto-reload option
  -   *
  -   * @param conf The configuration information
  -   * @exception ConfigurationException Not thrown here
  -   */
  -  public void setConfiguration(Configuration conf)
  -    throws ConfigurationException
  -  {
  -    Parameters params = Parameters.fromConfiguration(conf);
  -
  -    this.repositoryName = params.getParameter("repository", "./repository");
  -    this.autoReload = params.getParameterAsBoolean("auto-reload", true);
  -  }
  -
  -  /**
  -   * Load a program built from an XML document written in a
  -   * <code>MarkupLanguage</code>
  -   *
  -   * @param file The input document's <code>File</code>
  -   * @param markupLanguage The <code>MarkupLanguage</code> in which the input
  -   * document is written
  -   * @param programmingLanguage The <code>ProgrammingLanguage</code> in which
  -   * the program must be written
  -   * @return The loaded program instance
  -   * @exception Exception If an error occurs during generation or loading
  -   */
  -  public Object load(
  -    File file, String markupLanguageName, String programmingLanguageName
  -  ) throws Exception {
  -    // Get markup and programming languages
  -    MarkupLanguage markupLanguage = (MarkupLanguage)
  -      this.factory.getComponent("markup-language", markupLanguageName);
  -
  -    ProgrammingLanguage programmingLanguage = (ProgrammingLanguage)
  -      this.factory.getComponent("programming-language", programmingLanguageName);
  -
  -    // Create filesystem store
  -    FilesystemStore repository = new FilesystemStore(this.repositoryName);
  -
  -    // Set filenames
  -    String filename = IOUtils.getFullFilename(file);
  -    String normalizedName = repository.normalizedFilename(filename);
  -    String sourceExtension = programmingLanguage.getSourceExtension();
  -
  -    // Ensure no 2 requests for the same file overlap
  -    Object program = null;
  -    Object programInstance = null;
  -
  -    synchronized(filename.intern()) {
  -      // Attempt to load program object from cache
  -      program = this.cache.get(filename);
  -  
  -      try {
  -        if (program == null) {
  -          /*
  -	     FIXME: Passing null as encoding may result in invalid
  -	     recompilation under certain circumstances!
  -	  */
  -          program = programmingLanguage.load(
  -            normalizedName, this.repositoryName, null
  -          );
  -  
  -          // Store loaded program in cache
  -          this.cache.store(filename, program);
  -	}
  -
  -	// Instantiate program
  -        programInstance = programmingLanguage.instantiate(program);
  -      } catch (LanguageException e) { }
  -      
  -      /*
  -         FIXME: It's the program (not the instance) that must
  -	 be queried for changes!!!
  -      */
  -      if (
  -	  this.autoReload &&
  -          programInstance != null &&
  -	  programInstance instanceof Modifiable &&
  -	  ((Modifiable) programInstance).modifiedSince(file.lastModified())
  -      )
  -      {
  -        // Unload program
  -        programmingLanguage.unload(
  -	  program, normalizedName, this.repositoryName
  -        );
  -  
  -        // Invalidate previous program/instance pair
  -        program = null;
  -	programInstance = null;
  -      }
  -  
  -      if (program == null) {
  -        // Generate code
  -        Document document =
  -	  DOMUtils.DOMParse(new InputSource(new FileReader(file)));
  -        String encoding = markupLanguage.getEncoding(document);
  -        String code = markupLanguage.generateCode(
  -          document, normalizedName, programmingLanguage
  -        );
  -  
  -	// Format source code if applicable
  -	CodeFormatter codeFormatter = programmingLanguage.getCodeFormatter();
  -	if (codeFormatter != null) {
  -	  code = codeFormatter.format(code, encoding);
  -	}
  -  
  -        // Store generated code
  -        String sourceFilename = filename + "." + sourceExtension;
  -        repository.store(sourceFilename, code);
  -  
  -        // Verify source file generation was successful
  -        File sourceFile = (File) repository.get(sourceFilename);
  -        if (sourceFile == null) {
  -          throw new IOException(
  -	    "Error creating source file: " + sourceFilename
  -	  );
  -        }
  -  
  -        // [Compile]/Load generated program
  -        program = programmingLanguage.load(
  -	  normalizedName, this.repositoryName, encoding
  -	);
  -
  -        // Store generated program in cache
  -        this.cache.store(filename, program);
  -      }
  -
  -      // Instantiate
  -      programInstance = programmingLanguage.instantiate(program);
  -    }
  -
  -    return programInstance;
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.generator;
  +
  +import java.io.File;
  +import java.io.FileReader;
  +
  +import org.apache.avalon.Modifiable;
  +
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.ComponentManager;
  +import org.apache.avalon.Configurable;
  +import org.apache.avalon.Configuration;
  +import org.apache.avalon.ConfigurationException;
  +import org.apache.avalon.NamedComponentManager;
  +
  +import org.apache.avalon.utils.Parameters;
  +
  +import org.apache.cocoon.components.store.MemoryStore;
  +import org.apache.cocoon.components.store.FilesystemStore;
  +
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +import org.apache.cocoon.components.language.markup.MarkupLanguage;
  +import org.apache.cocoon.components.language.programming.CodeFormatter;
  +import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  +
  +import org.apache.cocoon.util.IOUtils;
  +import org.apache.cocoon.util.DOMUtils;
  +
  +import org.w3c.dom.Document;
  +import org.w3c.dom.Document;
  +
  +
  +import org.xml.sax.InputSource;
  +import org.apache.avalon.Component;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +import java.io.FileNotFoundException;
  +
  +/**
  + * The default implementation of <code>ProgramGenerator</code>
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:31 $
  + */
  +public class ProgramGeneratorImpl
  +  implements ProgramGenerator, Composer, Configurable
  +{
  +  /** The in-memory store */
  +  protected MemoryStore cache = new MemoryStore();
  +
  +  /** The filesystem-based store */
  +  protected String repositoryName;
  +
  +  /** The component manager */
  +  protected ComponentManager manager;
  +
  +  /** The named component manager */
  +  protected NamedComponentManager factory;
  +
  +  /** The auto-reloading option */
  +  protected boolean autoReload = true;
  +
  +  /**
  +   * Set the global component manager. This method also sets the
  +   * <code>NamedComponentManager</code> used as language factory for both
  +   * markup and programming languages.
  +   *
  +   * @param manager The global component manager
  +   */
  +  public void setComponentManager(ComponentManager manager) {
  +    this.manager = manager;
  +
  +    this.factory =
  +      (NamedComponentManager) this.manager.getComponent("factory");
  +  }
  +
  +  /**
  +   * Set the sitemap-provided configuration. This method sets the persistent
  +   * code repository and the auto-reload option
  +   *
  +   * @param conf The configuration information
  +   * @exception ConfigurationException Not thrown here
  +   */
  +  public void setConfiguration(Configuration conf)
  +    throws ConfigurationException
  +  {
  +    Parameters params = Parameters.fromConfiguration(conf);
  +
  +    this.repositoryName = params.getParameter("repository", "./repository");
  +    this.autoReload = params.getParameterAsBoolean("auto-reload", true);
  +  }
  +
  +  /**
  +   * Load a program built from an XML document written in a
  +   * <code>MarkupLanguage</code>
  +   *
  +   * @param file The input document's <code>File</code>
  +   * @param markupLanguage The <code>MarkupLanguage</code> in which the input
  +   * document is written
  +   * @param programmingLanguage The <code>ProgrammingLanguage</code> in which
  +   * the program must be written
  +   * @return The loaded program instance
  +   * @exception Exception If an error occurs during generation or loading
  +   */
  +  public Object load(
  +    File file, String markupLanguageName, String programmingLanguageName
  +  ) throws Exception {
  +    // Get markup and programming languages
  +    MarkupLanguage markupLanguage = (MarkupLanguage)
  +      this.factory.getComponent("markup-language", markupLanguageName);
  +
  +    ProgrammingLanguage programmingLanguage = (ProgrammingLanguage)
  +      this.factory.getComponent("programming-language", programmingLanguageName);
  +
  +    // Create filesystem store
  +    FilesystemStore repository = new FilesystemStore(this.repositoryName);
  +
  +    // Set filenames
  +    String filename = IOUtils.getFullFilename(file);
  +    String normalizedName = repository.normalizedFilename(filename);
  +    String sourceExtension = programmingLanguage.getSourceExtension();
  +
  +    // Ensure no 2 requests for the same file overlap
  +    Object program = null;
  +    Object programInstance = null;
  +
  +    synchronized(filename.intern()) {
  +      // Attempt to load program object from cache
  +      program = this.cache.get(filename);
  +  
  +      try {
  +        if (program == null) {
  +          /*
  +	     FIXME: Passing null as encoding may result in invalid
  +	     recompilation under certain circumstances!
  +	  */
  +          program = programmingLanguage.load(
  +            normalizedName, this.repositoryName, null
  +          );
  +  
  +          // Store loaded program in cache
  +          this.cache.store(filename, program);
  +	}
  +
  +	// Instantiate program
  +        programInstance = programmingLanguage.instantiate(program);
  +      } catch (LanguageException e) { }
  +      
  +      /*
  +         FIXME: It's the program (not the instance) that must
  +	 be queried for changes!!!
  +      */
  +      if (
  +	  this.autoReload &&
  +          programInstance != null &&
  +	  programInstance instanceof Modifiable &&
  +	  ((Modifiable) programInstance).modifiedSince(file.lastModified())
  +      )
  +      {
  +        // Unload program
  +        programmingLanguage.unload(
  +	  program, normalizedName, this.repositoryName
  +        );
  +  
  +        // Invalidate previous program/instance pair
  +        program = null;
  +	programInstance = null;
  +      }
  +  
  +      if (program == null) {
  +        // Generate code
  +        Document document =
  +	  DOMUtils.DOMParse(new InputSource(new FileReader(file)));
  +        String encoding = markupLanguage.getEncoding(document);
  +        String code = markupLanguage.generateCode(
  +          document, normalizedName, programmingLanguage
  +        );
  +  
  +	// Format source code if applicable
  +	CodeFormatter codeFormatter = programmingLanguage.getCodeFormatter();
  +	if (codeFormatter != null) {
  +	  code = codeFormatter.format(code, encoding);
  +	}
  +  
  +        // Store generated code
  +        String sourceFilename = filename + "." + sourceExtension;
  +        repository.store(sourceFilename, code);
  +  
  +        // Verify source file generation was successful
  +        File sourceFile = (File) repository.get(sourceFilename);
  +        if (sourceFile == null) {
  +          throw new IOException(
  +	    "Error creating source file: " + sourceFilename
  +	  );
  +        }
  +  
  +        // [Compile]/Load generated program
  +        program = programmingLanguage.load(
  +	  normalizedName, this.repositoryName, encoding
  +	);
  +
  +        // Store generated program in cache
  +        this.cache.store(filename, program);
  +      }
  +
  +      // Instantiate
  +      programInstance = programmingLanguage.instantiate(program);
  +    }
  +
  +    return programInstance;
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +527 -527  xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java
  
  Index: AbstractMarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AbstractMarkupLanguage.java	2000/07/11 03:09:38	1.1.2.2
  +++ AbstractMarkupLanguage.java	2000/07/22 20:41:32	1.1.2.3
  @@ -1,527 +1,527 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  -
  -import java.io.File;
  -import java.net.URL;
  -import java.util.Date;
  -import java.util.Vector;
  -import java.util.Hashtable;
  -import java.util.Enumeration;
  -
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.NamedNodeMap;
  -
  -import org.xml.sax.InputSource;
  -import org.xml.sax.EntityResolver;
  -
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.Component;
  -import org.apache.avalon.ComponentManager;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.avalon.AbstractNamedComponent;
  -
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  -
  -import org.apache.cocoon.util.IOUtils;
  -import org.apache.cocoon.components.store.MemoryStore;
  -
  -import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -import java.net.MalformedURLException;
  -
  -/**
  - * Base implementation of <code>MarkupLanguage</code>. This class uses
  - * logicsheets as the only means of code generation. Code generation should
  - * be decoupled from this context!!! Moreover, this class uses DOM documents
  - * (as opposed to Cocoon2's standard SAX events)
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:09:38 $
  - */
  -public abstract class AbstractMarkupLanguage
  -  extends AbstractNamedComponent
  -  implements MarkupLanguage, Composer
  -{
  -  /**
  -   * The supported language table
  -   */
  -  protected Hashtable languages;
  -
  -  /**
  -   * The in-memory code-generation logicsheet cache
  -   */
  -  protected MemoryStore logicsheetCache;
  -
  -  /**
  -   * The markup language's namespace uri
  -   */
  -  protected String uri;
  -
  -  /**
  -   * The markup language's namespace prefix
  -   */
  -  protected String prefix;
  -
  -  /** The component manager */
  -  protected ComponentManager manager;
  -
  -  /**
  -   * Set the global component manager.
  -   *
  -   * @param manager The sitemap-specified component manager
  -   */
  -  public void setComponentManager(ComponentManager manager) {
  -    this.manager = manager;
  -  }
  -
  -  /**
  -   * The defualt constructor.
  -   */
  -  public AbstractMarkupLanguage() throws SAXException, IOException {
  -    // Initialize language table
  -    this.languages = new Hashtable();
  -
  -    // Initialize logicsheet cache
  -    this.logicsheetCache = new MemoryStore();
  -  }
  -
  -  /**
  -   * Initialize the (required) markup language namespace definition.
  -   *
  -   * @param params The sitemap-supplied parameters
  -   * @exception Exception Not actually thrown
  -   */
  -  protected void setParameters(Parameters params) throws Exception
  -  {
  -    this.uri = getRequiredParameter(params, "uri");
  -    this.prefix = getRequiredParameter(params, "prefix");
  -  }
  -
  -  /**
  -   * Process additional configuration. Load supported programming language
  -   * definitions
  -   *
  -   * @param conf The language configuration
  -   * @exception ConfigurationException If an error occurs loading logichseets
  -   */
  -  protected void setAdditionalConfiguration(Configuration conf)
  -    throws ConfigurationException
  -  {
  -    try {
  -      Enumeration l = conf.getConfigurations("target-language");
  -      while (l.hasMoreElements()) {
  -        Configuration lc = (Configuration) l.nextElement();
  -
  -        LanguageDescriptor language = new LanguageDescriptor();
  -        language.setName(lc.getAttribute("name"));
  -
  -	Parameters lcp = Parameters.fromConfiguration(lc);
  -        String logicsheetLocation =
  -	  getRequiredParameter(lcp, "core-logicsheet");
  -
  -        URL logicsheetURL = IOUtils.getURL(logicsheetLocation);
  -        String logicsheetName = logicsheetURL.toExternalForm();
  -        Logicsheet logicsheet = new Logicsheet();
  -        logicsheet.setInputSource(new InputSource(logicsheetURL.openStream()));
  -        CachedURL entry = new CachedURL(logicsheetURL, logicsheet);
  -        this.logicsheetCache.store(logicsheetName, entry);
  -        language.setLogicsheet(logicsheetName);
  -
  -        Enumeration n = lc.getConfigurations("builtin-logicsheet");
  -        while (n.hasMoreElements()) {
  -          Configuration nc = (Configuration) n.nextElement();
  -	  Parameters ncp = Parameters.fromConfiguration(nc);
  -
  -          String namedLogicsheetPrefix = getRequiredParameter(ncp, "prefix");
  -          String namedLogicsheetUri = getRequiredParameter(ncp, "uri");
  -          String namedLogicsheetLocation = getRequiredParameter(ncp, "href");
  -
  -          // FIXME: This is repetitive; add method for both cases
  -          URL namedLogicsheetURL = IOUtils.getURL(namedLogicsheetLocation);
  -          String namedLogicsheetName = namedLogicsheetURL.toExternalForm();
  -          NamedLogicsheet namedLogicsheet = new NamedLogicsheet();
  -          namedLogicsheet.setInputSource(
  -            new InputSource(namedLogicsheetURL.openStream())
  -          );
  -          namedLogicsheet.setPrefix(namedLogicsheetPrefix);
  -          namedLogicsheet.setUri(namedLogicsheetUri);
  -          CachedURL namedEntry =
  -            new CachedURL(namedLogicsheetURL, namedLogicsheet);
  -          this.logicsheetCache.store(namedLogicsheetName, namedEntry);
  -          language.addNamedLogicsheet(
  -            namedLogicsheetPrefix, namedLogicsheetName
  -          );
  -        }
  -
  -        this.languages.put(language.getName(), language);
  -      }
  -    } catch (Exception e) {
  -e.printStackTrace();
  -      throw new ConfigurationException(e.getMessage(), conf);
  -    }
  -  }
  -
  -  /**
  -   * Return the source document's encoding. This can be <code>null</code> for
  -   * the platform's default encoding. The default implementation returns
  -   * <code>null, but derived classes may override it if encoding applies to
  -   * their concrete languages. FIXME: There should be a way to get the
  -   * XML document's encoding as seen by the parser; unfortunately, this
  -   * information is not returned by current DOM or SAX parsers...
  -   *
  -   * @param document The input document
  -   * @return The document-specified encoding
  -   */
  -  public String getEncoding(Document document) {
  -    return null;
  -  }
  -
  -  /**
  -   * Prepare the document for logicsheet processing and code generation. The
  -   * default implementation does nothing, but derived classes should (at least)
  -   * use the passed programming language to quote <code>Strings</code>
  -   *
  -   * @param document The input document
  -   * @param filename The input source filename
  -   * @param language The target programming language
  -   * @return The augmented document
  -   */
  -  protected Document preprocessDocument(
  -    Document document, String filename, ProgrammingLanguage language
  -  )
  -  {
  -    return document;
  -  }
  -
  -  /**
  -   * Returns a list of logicsheets to be applied to this document for source
  -   * code generation.
  -   *
  -   * @param document The input document
  -   * @return An array of logicsheet <i>names</i>
  -   */
  -  protected abstract String[] getLogicsheets(Document document);
  -
  -  /**
  -   * Add a dependency on an external file to the document for inclusion in
  -   * generated code. This is used by <code>AbstractServerPagesGenerator</code>
  -   * to populate a list of <code>File</code>'s tested for change on each
  -   * invocation; this information, in turn, is used by
  -   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  -   * necessary.
  -   *
  -   * @param PARAM_NAME Param description
  -   * @return the value
  -   * @exception EXCEPTION_NAME If an error occurs
  -   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  -   *      and <code>ServerPagesLoaderImpl</code>
  -   */
  -  protected abstract void addDependency(Document document, String location);
  -
  -  /**
  -   * Generate source code from the input document for the target
  -   * <code>ProgrammingLanguage</code>. After preprocessing the input document,
  -   * this method applies logicsheets in the following order:
  -   * <ul>
  -   *   <li>User-defined logicsheets</li>
  -   *   <li>Namespace-mapped logicsheets</li>
  -   *   <li>Language-specific logicsheet</li>
  -   * </ul>
  -   *
  -   * @param document The input document
  -   * @param filename The input document's original filename
  -   * @param programmingLanguage The target programming language
  -   * @return The generated source code
  -   * @exception Exception If an error occurs during code generation
  -   */
  -  public String generateCode(
  -    Document document, String filename, ProgrammingLanguage programmingLanguage
  -  ) throws Exception {
  -    String languageName = programmingLanguage.getName();
  -
  -    LanguageDescriptor language =
  -      (LanguageDescriptor) this.languages.get(languageName);
  -
  -    if (language == null) {
  -      throw new IllegalArgumentException(
  -        "Unsupported programming language: " + languageName
  -      );
  -    }
  -
  -    // Preprocess document as needed
  -    document = this.preprocessDocument(document, filename, programmingLanguage);
  -
  -    // Create code generator
  -    LogicsheetCodeGenerator codeGenerator = new LogicsheetCodeGenerator(); 
  -
  -    // Add user-defined logicsheets
  -    String[] logicsheetNames = this.getLogicsheets(document);
  -    for (int i = 0; i < logicsheetNames.length; i++) {
  -      this.addLogicsheet(codeGenerator, logicsheetNames[i], document);
  -    }
  -
  -    // Add namespace-mapped logicsheets
  -    Element root = document.getDocumentElement();
  -    NamedNodeMap attrs = root.getAttributes();
  -    int attrCount = attrs.getLength();
  -    for (int i = 0; i < attrCount; i++) {
  -      Attr attr = (Attr) attrs.item(i);
  -      String name = attr.getName();
  -
  -      if (name.startsWith("xmlns:")) {
  -        String prefix = name.substring(6);
  -        String namedLogicsheetName = language.getNamedLogicsheet(prefix);
  -
  -        if (namedLogicsheetName != null) {
  -          this.addLogicsheet(codeGenerator, namedLogicsheetName, document);
  -        }
  -      }
  -    }
  -
  -    // Add language-specific logicsheet (always last!)
  -    this.addLogicsheet(codeGenerator, language.getLogicsheet(), document);
  -
  -    return codeGenerator.generateCode(document, filename);
  -  }
  -
  -  /**
  -   * Add a logicsheet to the code generator.
  -   *
  -   * @param codeGenerator The code generator
  -   * @param logicsheetLocation Location of the logicsheet to be added
  -   * @param document The input document
  -   * @exception MalformedURLException If location is invalid
  -   * @exception IOException IO Error
  -   * @exception SAXException Logicsheet parse error
  -   */
  -  protected void addLogicsheet(
  -    LogicsheetCodeGenerator codeGenerator,
  -    String logicsheetLocation,
  -    Document document
  -  ) throws MalformedURLException, IOException, SAXException
  -  {
  -    String systemId = null;
  -    InputSource inputSource = null;
  -
  -    if (logicsheetLocation.indexOf(":/") < 0) { // Relative to Cocoon root
  -      EntityResolver entityResolver =
  -        (EntityResolver) this.manager.getComponent("cocoon");
  -      inputSource = entityResolver.resolveEntity(null, logicsheetLocation);
  -      systemId = inputSource.getSystemId();
  -    } else { // Fully resolved URL
  -      systemId = logicsheetLocation;
  -      inputSource = new InputSource(systemId);
  -    }
  -
  -    URL url = new URL(systemId);
  -    String logicsheetName = url.toExternalForm();
  -    CachedURL entry = (CachedURL) this.logicsheetCache.get(logicsheetName);
  -
  -    Logicsheet logicsheet = null;
  -
  -    if (entry == null) {
  -      logicsheet = new Logicsheet();
  -      logicsheet.setInputSource(inputSource);
  -      entry = new CachedURL(url, logicsheet);
  -      this.logicsheetCache.store(logicsheetName, entry);
  -    }
  -
  -    logicsheet = entry.getLogicsheet();
  -
  -    if (entry.hasChanged()) {
  -      logicsheet.setInputSource(inputSource);
  -    }
  -
  -    if (entry.isFile()) {
  -      this.addDependency(document, IOUtils.getFullFilename(entry.getFile()));
  -    }
  -
  -    codeGenerator.addLogicsheet(logicsheet);
  -  }
  -
  -  // Inner classes
  -
  -  /**
  -   * This class holds transient information about a target programming
  -   * language.
  -   *
  -   */
  -  protected class LanguageDescriptor {
  -    /**
  -     * The progamming language name
  -     */
  -    protected String name;
  -
  -    /**
  -     * The progamming language core logicsheet
  -     */
  -    protected String logicsheet;
  -
  -    /**
  -     * The list of built-in logicsheets defined for this target language
  -     */
  -    protected Hashtable namedLogicsheets;
  -
  -    /**
  -     * The default constructor
  -     */
  -    protected LanguageDescriptor() {
  -      this.namedLogicsheets = new Hashtable();
  -    }
  -
  -    /**
  -     * Set the programming language's name
  -     *
  -     * @param name The programming language's name
  -     */
  -    protected void setName(String name) {
  -      this.name = name;
  -    }
  -
  -    /**
  -     * Return the programming language's name
  -     *
  -     * @return The programming language's name
  -     */
  -    protected String getName() {
  -      return this.name;
  -    }
  -
  -    /**
  -     * Set the programming language's core logichseet location
  -     *
  -     * @param logicsheet The programming language's core logichseet location
  -     */
  -    protected void setLogicsheet(String logicsheet) {
  -      this.logicsheet = logicsheet;
  -    }
  -
  -    /**
  -     * Return the programming language's core logichseet location
  -     *
  -     * @return The programming language's core logichseet location
  -     */
  -    protected String getLogicsheet() {
  -      return this.logicsheet;
  -    }
  -
  -    /**
  -     * Add a namespace-mapped logicsheet to this language
  -     *
  -     * @param prefix The logichseet's namespace prefix
  -     * @param uri The logichseet's namespace uri
  -     * @param namedLogicsheet The logichseet's location
  -     */
  -    protected void addNamedLogicsheet(String prefix, String namedLogicsheet) {
  -      this.namedLogicsheets.put(
  -        prefix,
  -        namedLogicsheet
  -      );
  -    }
  -
  -    /**
  -     * Return a namespace-mapped logicsheet given its name
  -     *
  -     * @return The namespace-mapped logicsheet
  -     */
  -    protected String getNamedLogicsheet(String prefix) {
  -      return (String) this.namedLogicsheets.get(prefix);
  -    }
  -  }
  -
  -  /**
  -   * This class holds a cached URL entry associated with a logicsheet
  -   *
  -   */
  -  protected class CachedURL {
  -    /**
  -     * The logicsheet URL
  -     */
  -    protected URL url;
  -    /**
  -     * The logicsheet's <code>File</code> if it's actually a file.
  -     * This is used to provide last modification information not
  -     * otherwise available for URL's in Java :-(
  -     */
  -    protected File file;
  -    /**
  -     * The cached logicsheet 
  -     */
  -    protected Logicsheet logicsheet;
  -    /**
  -     * The las time this logicsheet was changed/loaded
  -     */
  -    protected long lastModified;
  -
  -    /**
  -     * The constructor.
  -     */
  -    protected CachedURL(URL url, Logicsheet logicsheet) throws IOException {
  -      this.url = url;
  -      this.logicsheet = logicsheet;
  -
  -      if (this.isFile()) {
  -        this.file = new File(url.getFile());
  -      }
  -
  -      this.lastModified = (new Date()).getTime();
  -    }
  -
  -    /**
  -     * Return this entry's URL
  -     *
  -     * @return The cached logicsheet's URL
  -     */
  -    protected URL getURL() {
  -      return this.url;
  -    }
  -
  -    protected boolean isFile() {
  -      return this.url.getProtocol().equals("file");
  -    }
  -
  -    /**
  -     * Return this entry's <code>File</code>
  -     *
  -     * @return The cached logicsheet's <code>File</code>
  -     */
  -    protected File getFile() {
  -      return this.file;
  -    }
  -
  -    /**
  -     * Return this entry's cached logicsheet
  -     *
  -     * @return The cached logicsheet
  -     */
  -    protected Logicsheet getLogicsheet() {
  -      return this.logicsheet;
  -    }
  -
  -    /**
  -     * Assert whether this entry's logicsheet should be reloaded
  -     *
  -     * @return Whether the cached logicsheet has changed
  -     */
  -    protected boolean hasChanged() {
  -      if (this.file == null) {
  -        return false;
  -      }
  -
  -      return this.lastModified < this.file.lastModified();
  -    }
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  +
  +import java.io.File;
  +import java.net.URL;
  +import java.util.Date;
  +import java.util.Vector;
  +import java.util.Hashtable;
  +import java.util.Enumeration;
  +
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.NamedNodeMap;
  +
  +import org.xml.sax.InputSource;
  +import org.xml.sax.EntityResolver;
  +
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.Component;
  +import org.apache.avalon.ComponentManager;
  +
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.avalon.AbstractNamedComponent;
  +
  +import org.apache.avalon.Configuration;
  +import org.apache.avalon.ConfigurationException;
  +
  +import org.apache.cocoon.util.IOUtils;
  +import org.apache.cocoon.components.store.MemoryStore;
  +
  +import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +import java.net.MalformedURLException;
  +
  +/**
  + * Base implementation of <code>MarkupLanguage</code>. This class uses
  + * logicsheets as the only means of code generation. Code generation should
  + * be decoupled from this context!!! Moreover, this class uses DOM documents
  + * (as opposed to Cocoon2's standard SAX events)
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:32 $
  + */
  +public abstract class AbstractMarkupLanguage
  +  extends AbstractNamedComponent
  +  implements MarkupLanguage, Composer
  +{
  +  /**
  +   * The supported language table
  +   */
  +  protected Hashtable languages;
  +
  +  /**
  +   * The in-memory code-generation logicsheet cache
  +   */
  +  protected MemoryStore logicsheetCache;
  +
  +  /**
  +   * The markup language's namespace uri
  +   */
  +  protected String uri;
  +
  +  /**
  +   * The markup language's namespace prefix
  +   */
  +  protected String prefix;
  +
  +  /** The component manager */
  +  protected ComponentManager manager;
  +
  +  /**
  +   * Set the global component manager.
  +   *
  +   * @param manager The sitemap-specified component manager
  +   */
  +  public void setComponentManager(ComponentManager manager) {
  +    this.manager = manager;
  +  }
  +
  +  /**
  +   * The defualt constructor.
  +   */
  +  public AbstractMarkupLanguage() throws SAXException, IOException {
  +    // Initialize language table
  +    this.languages = new Hashtable();
  +
  +    // Initialize logicsheet cache
  +    this.logicsheetCache = new MemoryStore();
  +  }
  +
  +  /**
  +   * Initialize the (required) markup language namespace definition.
  +   *
  +   * @param params The sitemap-supplied parameters
  +   * @exception Exception Not actually thrown
  +   */
  +  protected void setParameters(Parameters params) throws Exception
  +  {
  +    this.uri = getRequiredParameter(params, "uri");
  +    this.prefix = getRequiredParameter(params, "prefix");
  +  }
  +
  +  /**
  +   * Process additional configuration. Load supported programming language
  +   * definitions
  +   *
  +   * @param conf The language configuration
  +   * @exception ConfigurationException If an error occurs loading logichseets
  +   */
  +  protected void setAdditionalConfiguration(Configuration conf)
  +    throws ConfigurationException
  +  {
  +    try {
  +      Enumeration l = conf.getConfigurations("target-language");
  +      while (l.hasMoreElements()) {
  +        Configuration lc = (Configuration) l.nextElement();
  +
  +        LanguageDescriptor language = new LanguageDescriptor();
  +        language.setName(lc.getAttribute("name"));
  +
  +	Parameters lcp = Parameters.fromConfiguration(lc);
  +        String logicsheetLocation =
  +	  getRequiredParameter(lcp, "core-logicsheet");
  +
  +        URL logicsheetURL = IOUtils.getURL(logicsheetLocation);
  +        String logicsheetName = logicsheetURL.toExternalForm();
  +        Logicsheet logicsheet = new Logicsheet();
  +        logicsheet.setInputSource(new InputSource(logicsheetURL.openStream()));
  +        CachedURL entry = new CachedURL(logicsheetURL, logicsheet);
  +        this.logicsheetCache.store(logicsheetName, entry);
  +        language.setLogicsheet(logicsheetName);
  +
  +        Enumeration n = lc.getConfigurations("builtin-logicsheet");
  +        while (n.hasMoreElements()) {
  +          Configuration nc = (Configuration) n.nextElement();
  +	  Parameters ncp = Parameters.fromConfiguration(nc);
  +
  +          String namedLogicsheetPrefix = getRequiredParameter(ncp, "prefix");
  +          String namedLogicsheetUri = getRequiredParameter(ncp, "uri");
  +          String namedLogicsheetLocation = getRequiredParameter(ncp, "href");
  +
  +          // FIXME: This is repetitive; add method for both cases
  +          URL namedLogicsheetURL = IOUtils.getURL(namedLogicsheetLocation);
  +          String namedLogicsheetName = namedLogicsheetURL.toExternalForm();
  +          NamedLogicsheet namedLogicsheet = new NamedLogicsheet();
  +          namedLogicsheet.setInputSource(
  +            new InputSource(namedLogicsheetURL.openStream())
  +          );
  +          namedLogicsheet.setPrefix(namedLogicsheetPrefix);
  +          namedLogicsheet.setUri(namedLogicsheetUri);
  +          CachedURL namedEntry =
  +            new CachedURL(namedLogicsheetURL, namedLogicsheet);
  +          this.logicsheetCache.store(namedLogicsheetName, namedEntry);
  +          language.addNamedLogicsheet(
  +            namedLogicsheetPrefix, namedLogicsheetName
  +          );
  +        }
  +
  +        this.languages.put(language.getName(), language);
  +      }
  +    } catch (Exception e) {
  +e.printStackTrace();
  +      throw new ConfigurationException(e.getMessage(), conf);
  +    }
  +  }
  +
  +  /**
  +   * Return the source document's encoding. This can be <code>null</code> for
  +   * the platform's default encoding. The default implementation returns
  +   * <code>null, but derived classes may override it if encoding applies to
  +   * their concrete languages. FIXME: There should be a way to get the
  +   * XML document's encoding as seen by the parser; unfortunately, this
  +   * information is not returned by current DOM or SAX parsers...
  +   *
  +   * @param document The input document
  +   * @return The document-specified encoding
  +   */
  +  public String getEncoding(Document document) {
  +    return null;
  +  }
  +
  +  /**
  +   * Prepare the document for logicsheet processing and code generation. The
  +   * default implementation does nothing, but derived classes should (at least)
  +   * use the passed programming language to quote <code>Strings</code>
  +   *
  +   * @param document The input document
  +   * @param filename The input source filename
  +   * @param language The target programming language
  +   * @return The augmented document
  +   */
  +  protected Document preprocessDocument(
  +    Document document, String filename, ProgrammingLanguage language
  +  )
  +  {
  +    return document;
  +  }
  +
  +  /**
  +   * Returns a list of logicsheets to be applied to this document for source
  +   * code generation.
  +   *
  +   * @param document The input document
  +   * @return An array of logicsheet <i>names</i>
  +   */
  +  protected abstract String[] getLogicsheets(Document document);
  +
  +  /**
  +   * Add a dependency on an external file to the document for inclusion in
  +   * generated code. This is used by <code>AbstractServerPagesGenerator</code>
  +   * to populate a list of <code>File</code>'s tested for change on each
  +   * invocation; this information, in turn, is used by
  +   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  +   * necessary.
  +   *
  +   * @param PARAM_NAME Param description
  +   * @return the value
  +   * @exception EXCEPTION_NAME If an error occurs
  +   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  +   *      and <code>ServerPagesLoaderImpl</code>
  +   */
  +  protected abstract void addDependency(Document document, String location);
  +
  +  /**
  +   * Generate source code from the input document for the target
  +   * <code>ProgrammingLanguage</code>. After preprocessing the input document,
  +   * this method applies logicsheets in the following order:
  +   * <ul>
  +   *   <li>User-defined logicsheets</li>
  +   *   <li>Namespace-mapped logicsheets</li>
  +   *   <li>Language-specific logicsheet</li>
  +   * </ul>
  +   *
  +   * @param document The input document
  +   * @param filename The input document's original filename
  +   * @param programmingLanguage The target programming language
  +   * @return The generated source code
  +   * @exception Exception If an error occurs during code generation
  +   */
  +  public String generateCode(
  +    Document document, String filename, ProgrammingLanguage programmingLanguage
  +  ) throws Exception {
  +    String languageName = programmingLanguage.getName();
  +
  +    LanguageDescriptor language =
  +      (LanguageDescriptor) this.languages.get(languageName);
  +
  +    if (language == null) {
  +      throw new IllegalArgumentException(
  +        "Unsupported programming language: " + languageName
  +      );
  +    }
  +
  +    // Preprocess document as needed
  +    document = this.preprocessDocument(document, filename, programmingLanguage);
  +
  +    // Create code generator
  +    LogicsheetCodeGenerator codeGenerator = new LogicsheetCodeGenerator(); 
  +
  +    // Add user-defined logicsheets
  +    String[] logicsheetNames = this.getLogicsheets(document);
  +    for (int i = 0; i < logicsheetNames.length; i++) {
  +      this.addLogicsheet(codeGenerator, logicsheetNames[i], document);
  +    }
  +
  +    // Add namespace-mapped logicsheets
  +    Element root = document.getDocumentElement();
  +    NamedNodeMap attrs = root.getAttributes();
  +    int attrCount = attrs.getLength();
  +    for (int i = 0; i < attrCount; i++) {
  +      Attr attr = (Attr) attrs.item(i);
  +      String name = attr.getName();
  +
  +      if (name.startsWith("xmlns:")) {
  +        String prefix = name.substring(6);
  +        String namedLogicsheetName = language.getNamedLogicsheet(prefix);
  +
  +        if (namedLogicsheetName != null) {
  +          this.addLogicsheet(codeGenerator, namedLogicsheetName, document);
  +        }
  +      }
  +    }
  +
  +    // Add language-specific logicsheet (always last!)
  +    this.addLogicsheet(codeGenerator, language.getLogicsheet(), document);
  +
  +    return codeGenerator.generateCode(document, filename);
  +  }
  +
  +  /**
  +   * Add a logicsheet to the code generator.
  +   *
  +   * @param codeGenerator The code generator
  +   * @param logicsheetLocation Location of the logicsheet to be added
  +   * @param document The input document
  +   * @exception MalformedURLException If location is invalid
  +   * @exception IOException IO Error
  +   * @exception SAXException Logicsheet parse error
  +   */
  +  protected void addLogicsheet(
  +    LogicsheetCodeGenerator codeGenerator,
  +    String logicsheetLocation,
  +    Document document
  +  ) throws MalformedURLException, IOException, SAXException
  +  {
  +    String systemId = null;
  +    InputSource inputSource = null;
  +
  +    if (logicsheetLocation.indexOf(":/") < 0) { // Relative to Cocoon root
  +      EntityResolver entityResolver =
  +        (EntityResolver) this.manager.getComponent("cocoon");
  +      inputSource = entityResolver.resolveEntity(null, logicsheetLocation);
  +      systemId = inputSource.getSystemId();
  +    } else { // Fully resolved URL
  +      systemId = logicsheetLocation;
  +      inputSource = new InputSource(systemId);
  +    }
  +
  +    URL url = new URL(systemId);
  +    String logicsheetName = url.toExternalForm();
  +    CachedURL entry = (CachedURL) this.logicsheetCache.get(logicsheetName);
  +
  +    Logicsheet logicsheet = null;
  +
  +    if (entry == null) {
  +      logicsheet = new Logicsheet();
  +      logicsheet.setInputSource(inputSource);
  +      entry = new CachedURL(url, logicsheet);
  +      this.logicsheetCache.store(logicsheetName, entry);
  +    }
  +
  +    logicsheet = entry.getLogicsheet();
  +
  +    if (entry.hasChanged()) {
  +      logicsheet.setInputSource(inputSource);
  +    }
  +
  +    if (entry.isFile()) {
  +      this.addDependency(document, IOUtils.getFullFilename(entry.getFile()));
  +    }
  +
  +    codeGenerator.addLogicsheet(logicsheet);
  +  }
  +
  +  // Inner classes
  +
  +  /**
  +   * This class holds transient information about a target programming
  +   * language.
  +   *
  +   */
  +  protected class LanguageDescriptor {
  +    /**
  +     * The progamming language name
  +     */
  +    protected String name;
  +
  +    /**
  +     * The progamming language core logicsheet
  +     */
  +    protected String logicsheet;
  +
  +    /**
  +     * The list of built-in logicsheets defined for this target language
  +     */
  +    protected Hashtable namedLogicsheets;
  +
  +    /**
  +     * The default constructor
  +     */
  +    protected LanguageDescriptor() {
  +      this.namedLogicsheets = new Hashtable();
  +    }
  +
  +    /**
  +     * Set the programming language's name
  +     *
  +     * @param name The programming language's name
  +     */
  +    protected void setName(String name) {
  +      this.name = name;
  +    }
  +
  +    /**
  +     * Return the programming language's name
  +     *
  +     * @return The programming language's name
  +     */
  +    protected String getName() {
  +      return this.name;
  +    }
  +
  +    /**
  +     * Set the programming language's core logichseet location
  +     *
  +     * @param logicsheet The programming language's core logichseet location
  +     */
  +    protected void setLogicsheet(String logicsheet) {
  +      this.logicsheet = logicsheet;
  +    }
  +
  +    /**
  +     * Return the programming language's core logichseet location
  +     *
  +     * @return The programming language's core logichseet location
  +     */
  +    protected String getLogicsheet() {
  +      return this.logicsheet;
  +    }
  +
  +    /**
  +     * Add a namespace-mapped logicsheet to this language
  +     *
  +     * @param prefix The logichseet's namespace prefix
  +     * @param uri The logichseet's namespace uri
  +     * @param namedLogicsheet The logichseet's location
  +     */
  +    protected void addNamedLogicsheet(String prefix, String namedLogicsheet) {
  +      this.namedLogicsheets.put(
  +        prefix,
  +        namedLogicsheet
  +      );
  +    }
  +
  +    /**
  +     * Return a namespace-mapped logicsheet given its name
  +     *
  +     * @return The namespace-mapped logicsheet
  +     */
  +    protected String getNamedLogicsheet(String prefix) {
  +      return (String) this.namedLogicsheets.get(prefix);
  +    }
  +  }
  +
  +  /**
  +   * This class holds a cached URL entry associated with a logicsheet
  +   *
  +   */
  +  protected class CachedURL {
  +    /**
  +     * The logicsheet URL
  +     */
  +    protected URL url;
  +    /**
  +     * The logicsheet's <code>File</code> if it's actually a file.
  +     * This is used to provide last modification information not
  +     * otherwise available for URL's in Java :-(
  +     */
  +    protected File file;
  +    /**
  +     * The cached logicsheet 
  +     */
  +    protected Logicsheet logicsheet;
  +    /**
  +     * The las time this logicsheet was changed/loaded
  +     */
  +    protected long lastModified;
  +
  +    /**
  +     * The constructor.
  +     */
  +    protected CachedURL(URL url, Logicsheet logicsheet) throws IOException {
  +      this.url = url;
  +      this.logicsheet = logicsheet;
  +
  +      if (this.isFile()) {
  +        this.file = new File(url.getFile());
  +      }
  +
  +      this.lastModified = (new Date()).getTime();
  +    }
  +
  +    /**
  +     * Return this entry's URL
  +     *
  +     * @return The cached logicsheet's URL
  +     */
  +    protected URL getURL() {
  +      return this.url;
  +    }
  +
  +    protected boolean isFile() {
  +      return this.url.getProtocol().equals("file");
  +    }
  +
  +    /**
  +     * Return this entry's <code>File</code>
  +     *
  +     * @return The cached logicsheet's <code>File</code>
  +     */
  +    protected File getFile() {
  +      return this.file;
  +    }
  +
  +    /**
  +     * Return this entry's cached logicsheet
  +     *
  +     * @return The cached logicsheet
  +     */
  +    protected Logicsheet getLogicsheet() {
  +      return this.logicsheet;
  +    }
  +
  +    /**
  +     * Assert whether this entry's logicsheet should be reloaded
  +     *
  +     * @return Whether the cached logicsheet has changed
  +     */
  +    protected boolean hasChanged() {
  +      if (this.file == null) {
  +        return false;
  +      }
  +
  +      return this.lastModified < this.file.lastModified();
  +    }
  +  }
  +}
  
  
  
  1.1.2.2   +101 -101  xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/Logicsheet.java
  
  Index: Logicsheet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/Logicsheet.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Logicsheet.java	2000/05/23 23:09:56	1.1.2.1
  +++ Logicsheet.java	2000/07/22 20:41:32	1.1.2.2
  @@ -1,101 +1,101 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  -
  -import java.net.URL;
  -import java.util.Vector;
  -
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.NamedNodeMap;
  -
  -import org.xml.sax.InputSource;
  -
  -import org.apache.cocoon.util.DOMUtils;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -import java.net.MalformedURLException;
  -
  -/**
  - * A code-generation logicsheet. This class is actually a wrapper for
  - * a "standard" XSLT stylesheet though this will change shortly: a new markup
  - * language will be used for logicsheet authoring; logicsheets written in this
  - * language will be transformed into an equivalent XSLT stylesheet anyway...
  - * This class should probably be based on an interface...
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:56 $
  - */
  -public class Logicsheet {
  -  /**
  -   * The wrapped XSLT stylesheet
  -   */
  -  protected Document stylesheet;
  -
  -  /**
  -   * The list of preserved namespaces
  -   */
  -  protected Vector namespaces;
  -  /**
  -   * A time-saving trick: this is actually the namespace's vector size()
  -   */
  -  protected int namespaceCount;
  -
  -  /**
  -   * The constructor. This method scans the logicsheet collecting namespaces to
  -   * be preserved on output; this ensures that no namespaces will be dropped
  -   * from the original document
  -   *
  -   * @param inputSource The stylesheet's input source
  -   * @exception IOException IOError processing input source
  -   * @exception SAXException Input source parse error
  -   */
  -  public void setInputSource(InputSource inputSource)
  -    throws SAXException, IOException
  -  {
  -    this.stylesheet = DOMUtils.DOMParse(inputSource);
  -    this.namespaces = DOMUtils.namespaces(this.stylesheet.getDocumentElement());
  -    this.namespaceCount = this.namespaces.size();
  -  }
  -
  -  /**
  -   * Apply this logicsheet to an input document. This method does additional
  -   * namesapace preserving as stylsheet processing may drop namespaces required
  -   * by further code-generation steps
  -   *
  -   * @param input Param The input document
  -   * @return The transformed document
  -   * @exception SAXException If a stylesheet processing error occurs
  -   */
  -  public Document apply(Document input) throws SAXException {
  -    // Save original namespaces
  -    Vector inputNamespaces = DOMUtils.namespaces(input.getDocumentElement());
  -    int inputCount = inputNamespaces.size();
  -
  -    // Transform input document
  -    Document output = DOMUtils.transformDocument(input, this.stylesheet);
  -
  -    // Restore original namespaces
  -    Element root = output.getDocumentElement();
  -
  -    for (int i = 0; i < inputCount; i++) {
  -      String[] pair = (String[]) inputNamespaces.elementAt(i);
  -      root.setAttribute(pair[0], pair[1]);
  -    }
  -
  -    // Restore stylesheet namespaces
  -    for (int i = 0; i < this.namespaceCount; i++) {
  -      String[] pair = (String[]) this.namespaces.elementAt(i);
  -      root.setAttribute(pair[0], pair[1]);
  -    }
  -
  -    return output;
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  +
  +import java.net.URL;
  +import java.util.Vector;
  +
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.NamedNodeMap;
  +
  +import org.xml.sax.InputSource;
  +
  +import org.apache.cocoon.util.DOMUtils;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +import java.net.MalformedURLException;
  +
  +/**
  + * A code-generation logicsheet. This class is actually a wrapper for
  + * a "standard" XSLT stylesheet though this will change shortly: a new markup
  + * language will be used for logicsheet authoring; logicsheets written in this
  + * language will be transformed into an equivalent XSLT stylesheet anyway...
  + * This class should probably be based on an interface...
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:32 $
  + */
  +public class Logicsheet {
  +  /**
  +   * The wrapped XSLT stylesheet
  +   */
  +  protected Document stylesheet;
  +
  +  /**
  +   * The list of preserved namespaces
  +   */
  +  protected Vector namespaces;
  +  /**
  +   * A time-saving trick: this is actually the namespace's vector size()
  +   */
  +  protected int namespaceCount;
  +
  +  /**
  +   * The constructor. This method scans the logicsheet collecting namespaces to
  +   * be preserved on output; this ensures that no namespaces will be dropped
  +   * from the original document
  +   *
  +   * @param inputSource The stylesheet's input source
  +   * @exception IOException IOError processing input source
  +   * @exception SAXException Input source parse error
  +   */
  +  public void setInputSource(InputSource inputSource)
  +    throws SAXException, IOException
  +  {
  +    this.stylesheet = DOMUtils.DOMParse(inputSource);
  +    this.namespaces = DOMUtils.namespaces(this.stylesheet.getDocumentElement());
  +    this.namespaceCount = this.namespaces.size();
  +  }
  +
  +  /**
  +   * Apply this logicsheet to an input document. This method does additional
  +   * namesapace preserving as stylsheet processing may drop namespaces required
  +   * by further code-generation steps
  +   *
  +   * @param input Param The input document
  +   * @return The transformed document
  +   * @exception SAXException If a stylesheet processing error occurs
  +   */
  +  public Document apply(Document input) throws SAXException {
  +    // Save original namespaces
  +    Vector inputNamespaces = DOMUtils.namespaces(input.getDocumentElement());
  +    int inputCount = inputNamespaces.size();
  +
  +    // Transform input document
  +    Document output = DOMUtils.transformDocument(input, this.stylesheet);
  +
  +    // Restore original namespaces
  +    Element root = output.getDocumentElement();
  +
  +    for (int i = 0; i < inputCount; i++) {
  +      String[] pair = (String[]) inputNamespaces.elementAt(i);
  +      root.setAttribute(pair[0], pair[1]);
  +    }
  +
  +    // Restore stylesheet namespaces
  +    for (int i = 0; i < this.namespaceCount; i++) {
  +      String[] pair = (String[]) this.namespaces.elementAt(i);
  +      root.setAttribute(pair[0], pair[1]);
  +    }
  +
  +    return output;
  +  }
  +}
  
  
  
  1.1.2.2   +68 -68    xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/LogicsheetCodeGenerator.java
  
  Index: LogicsheetCodeGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/LogicsheetCodeGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- LogicsheetCodeGenerator.java	2000/05/23 23:09:56	1.1.2.1
  +++ LogicsheetCodeGenerator.java	2000/07/22 20:41:33	1.1.2.2
  @@ -1,68 +1,68 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  -
  -import java.util.Vector;
  -
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Document;
  -import org.xml.sax.InputSource;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * A logicsheet-based implementation of <code>MarkupGenerator</code>
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:56 $
  - */
  -public class LogicsheetCodeGenerator implements MarkupCodeGenerator {
  -  /**
  -   * Ordered list of logicsheet to be used in code generation
  -   */
  -  protected Vector logicsheets;
  -
  -  /**
  -   * The default constructor
  -   */
  -  public LogicsheetCodeGenerator() {
  -    this.logicsheets = new Vector();
  -  }
  -
  -  /**
  -   * Add a logicsheet to the logicsheet list
  -   *
  -   * @param logicsheet The logicsheet to be added
  -   */
  -  public void addLogicsheet(Logicsheet logicsheet) {
  -    this.logicsheets.addElement(logicsheet);
  -  }
  -
  -  /**
  -   * Generate source code from the input document. Filename information is
  -   * ignored in the logicsheet-based code generation approach
  -   *
  -   * @param input The input document
  -   * @param filename The input source original filename
  -   * @return The generated source code
  -   * @exception Exception If an error occurs during code generation
  -   */
  -  public String generateCode(Document input, String filename) throws Exception {
  -    int count = this.logicsheets.size();
  -    for (int i = 0; i < count; i++) {
  -      Logicsheet logicsheet = (Logicsheet) this.logicsheets.elementAt(i);
  -      input = logicsheet.apply(input);
  -    }
  -
  -    Element result = input.getDocumentElement();
  -    result.normalize();
  -
  -    return result.getFirstChild().getNodeValue();
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  +
  +import java.util.Vector;
  +
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Document;
  +import org.xml.sax.InputSource;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * A logicsheet-based implementation of <code>MarkupGenerator</code>
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:33 $
  + */
  +public class LogicsheetCodeGenerator implements MarkupCodeGenerator {
  +  /**
  +   * Ordered list of logicsheet to be used in code generation
  +   */
  +  protected Vector logicsheets;
  +
  +  /**
  +   * The default constructor
  +   */
  +  public LogicsheetCodeGenerator() {
  +    this.logicsheets = new Vector();
  +  }
  +
  +  /**
  +   * Add a logicsheet to the logicsheet list
  +   *
  +   * @param logicsheet The logicsheet to be added
  +   */
  +  public void addLogicsheet(Logicsheet logicsheet) {
  +    this.logicsheets.addElement(logicsheet);
  +  }
  +
  +  /**
  +   * Generate source code from the input document. Filename information is
  +   * ignored in the logicsheet-based code generation approach
  +   *
  +   * @param input The input document
  +   * @param filename The input source original filename
  +   * @return The generated source code
  +   * @exception Exception If an error occurs during code generation
  +   */
  +  public String generateCode(Document input, String filename) throws Exception {
  +    int count = this.logicsheets.size();
  +    for (int i = 0; i < count; i++) {
  +      Logicsheet logicsheet = (Logicsheet) this.logicsheets.elementAt(i);
  +      input = logicsheet.apply(input);
  +    }
  +
  +    Element result = input.getDocumentElement();
  +    result.normalize();
  +
  +    return result.getFirstChild().getNodeValue();
  +  }
  +}
  
  
  
  1.1.2.2   +30 -30    xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/MarkupCodeGenerator.java
  
  Index: MarkupCodeGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/MarkupCodeGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- MarkupCodeGenerator.java	2000/05/23 23:09:56	1.1.2.1
  +++ MarkupCodeGenerator.java	2000/07/22 20:41:33	1.1.2.2
  @@ -1,30 +1,30 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  -
  -import org.w3c.dom.Document;
  -
  -/**
  - * This interfaces defines the functionality of a source code generator
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:56 $
  - */
  -public interface MarkupCodeGenerator {
  -  /**
  -   * Generate source code from the input document. Filename information may be
  -   * needed by certain code-generation approaches and programming languages
  -   *
  -   * @param input The input document
  -   * @param filename The input source original filename
  -   * @return The generated source code
  -   * @exception Exception If an error occurs during code generation
  -   */
  -  public String generateCode(Document document, String filename)
  -    throws Exception;
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  +
  +import org.w3c.dom.Document;
  +
  +/**
  + * This interfaces defines the functionality of a source code generator
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:33 $
  + */
  +public interface MarkupCodeGenerator {
  +  /**
  +   * Generate source code from the input document. Filename information may be
  +   * needed by certain code-generation approaches and programming languages
  +   *
  +   * @param input The input document
  +   * @param filename The input source original filename
  +   * @return The generated source code
  +   * @exception Exception If an error occurs during code generation
  +   */
  +  public String generateCode(Document document, String filename)
  +    throws Exception;
  +}
  
  
  
  1.1.2.3   +45 -45    xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/MarkupLanguage.java
  
  Index: MarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/MarkupLanguage.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- MarkupLanguage.java	2000/07/11 03:09:38	1.1.2.2
  +++ MarkupLanguage.java	2000/07/22 20:41:33	1.1.2.3
  @@ -1,45 +1,45 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  -
  -import org.w3c.dom.Document;
  -import org.apache.avalon.NamedComponent;
  -
  -import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -
  -/**
  - * This interface defines a markup language whose instance documents are to be
  - * translated into an executable program capable or rebuilding the original
  - * document augmenting it with dynamic content
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:09:38 $
  - */
  -public interface MarkupLanguage extends NamedComponent {
  -  /**
  -   * Return the input document's encoding or <code>null</code> if it is the
  -   * platform's default encoding
  -   *
  -   * @return The document's encoding
  -   */
  -  public String getEncoding(Document document);
  -
  -  /**
  -   * Generate source code from the input document for the target
  -   * <code>ProgrammingLanguage</code>.
  -   *
  -   * @param document The input document
  -   * @param filename The input document's original filename
  -   * @param programmingLanguage The target programming language
  -   * @return The generated source code
  -   * @exception Exception If an error occurs during code generation
  -   */
  -  public String generateCode(
  -    Document document, String filename, ProgrammingLanguage programmingLanguage
  -  ) throws Exception;
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  +
  +import org.w3c.dom.Document;
  +import org.apache.avalon.NamedComponent;
  +
  +import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  +
  +/**
  + * This interface defines a markup language whose instance documents are to be
  + * translated into an executable program capable or rebuilding the original
  + * document augmenting it with dynamic content
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:33 $
  + */
  +public interface MarkupLanguage extends NamedComponent {
  +  /**
  +   * Return the input document's encoding or <code>null</code> if it is the
  +   * platform's default encoding
  +   *
  +   * @return The document's encoding
  +   */
  +  public String getEncoding(Document document);
  +
  +  /**
  +   * Generate source code from the input document for the target
  +   * <code>ProgrammingLanguage</code>.
  +   *
  +   * @param document The input document
  +   * @param filename The input document's original filename
  +   * @param programmingLanguage The target programming language
  +   * @return The generated source code
  +   * @exception Exception If an error occurs during code generation
  +   */
  +  public String generateCode(
  +    Document document, String filename, ProgrammingLanguage programmingLanguage
  +  ) throws Exception;
  +}
  
  
  
  1.1.2.2   +70 -70    xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/NamedLogicsheet.java
  
  Index: NamedLogicsheet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/NamedLogicsheet.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- NamedLogicsheet.java	2000/05/23 23:09:56	1.1.2.1
  +++ NamedLogicsheet.java	2000/07/22 20:41:33	1.1.2.2
  @@ -1,70 +1,70 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  -
  -import org.xml.sax.InputSource;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * An extension to <code>Logicsheet</code> that is associated with a namespace.
  - * Named logicsheets are implicitly declared (and automagically applied) when
  - * the markup language document's root element declares the same logichseet's
  - * namespace 
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:56 $
  - */
  -public class NamedLogicsheet extends Logicsheet {
  -  /**
  -   * The namespace uri
  -   */
  -  protected String uri;
  -
  -  /**
  -   * The namespace prefix
  -   */
  -  protected String prefix;
  -
  -  /**
  -   * Set the logichseet's namespace prefix
  -   *
  -   * @param prefix The namespace prefix
  -   */
  -  public void setPrefix(String prefix) {
  -    this.prefix = prefix;
  -  }
  -
  -  /**
  -   * Return the logicsheet's namespace prefix
  -   *
  -   * @return The logicsheet's namespace prefix
  -   */
  -  public String getPrefix() {
  -    return this.prefix;
  -  }
  -
  -  /**
  -   * Set the logichseet's namespace uri
  -   *
  -   * @param prefix The namespace uri
  -   */
  -  public void setUri(String uri) {
  -    this.uri = uri;
  -  }
  -
  -  /**
  -   * Return the logicsheet's namespace uri
  -   *
  -   * @return The logicsheet's namespace uri
  -   */
  -  public String getUri() {
  -    return this.uri;
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup;
  +
  +import org.xml.sax.InputSource;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * An extension to <code>Logicsheet</code> that is associated with a namespace.
  + * Named logicsheets are implicitly declared (and automagically applied) when
  + * the markup language document's root element declares the same logichseet's
  + * namespace 
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:33 $
  + */
  +public class NamedLogicsheet extends Logicsheet {
  +  /**
  +   * The namespace uri
  +   */
  +  protected String uri;
  +
  +  /**
  +   * The namespace prefix
  +   */
  +  protected String prefix;
  +
  +  /**
  +   * Set the logichseet's namespace prefix
  +   *
  +   * @param prefix The namespace prefix
  +   */
  +  public void setPrefix(String prefix) {
  +    this.prefix = prefix;
  +  }
  +
  +  /**
  +   * Return the logicsheet's namespace prefix
  +   *
  +   * @return The logicsheet's namespace prefix
  +   */
  +  public String getPrefix() {
  +    return this.prefix;
  +  }
  +
  +  /**
  +   * Set the logichseet's namespace uri
  +   *
  +   * @param prefix The namespace uri
  +   */
  +  public void setUri(String uri) {
  +    this.uri = uri;
  +  }
  +
  +  /**
  +   * Return the logicsheet's namespace uri
  +   *
  +   * @return The logicsheet's namespace uri
  +   */
  +  public String getUri() {
  +    return this.uri;
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +258 -258  xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java
  
  Index: SitemapMarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- SitemapMarkupLanguage.java	2000/07/17 21:06:10	1.1.2.3
  +++ SitemapMarkupLanguage.java	2000/07/22 20:41:34	1.1.2.4
  @@ -1,258 +1,258 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.sitemap;
  -
  -import java.io.File;
  -import java.util.Date;
  -import java.util.Vector;
  -import java.util.Hashtable;
  -
  -import org.w3c.dom.Node;
  -import org.w3c.dom.Text;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.ProcessingInstruction;
  -
  -import org.apache.cocoon.util.DOMUtils;
  -import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
  -
  -import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * This class implements <code>MarkupLanguage</code> for Cocoon's
  - * <a href="http://xml.apache.org/cocoon/sitemap.html">Sitemap</a>.
  - *
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/17 21:06:10 $
  - */
  -public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
  -  /**
  -   * The default constructor.
  -   */
  -  public SitemapMarkupLanguage() throws SAXException, IOException {
  -    super();
  -  }
  -
  -  /**
  -   * Return the Sitemap language name: <i>map</i> :-)
  -   *
  -   * @return The <i>map</i> constant
  -   */
  -  public String getName() {
  -    return "map";
  -  }
  -
  -  /**
  -   * Return the document-declared encoding or <code>null</code> if it's the
  -   * platform's default encoding
  -   *
  -   * @param document The input document
  -   * @return The document-declared encoding
  -   */
  -  public String getEncoding(Document document) {
  -    String encoding = document.getDocumentElement().getAttribute("encoding");
  -
  -    if (encoding.length() > 0) {
  -      return encoding;
  -    }
  -
  -    return null;
  -  }
  -
  -  /**
  -   * Prepare the document for logicsheet processing and code generation. This
  -   * method sets the base filename, file path and creation date as root element
  -   * attibutes and encodes text nodes as strings.
  -   *
  -   * @param document The input document
  -   * @param filename The input source filename
  -   * @param language The target programming language
  -   * @return The augmented document
  -   */
  -  protected Document preprocessDocument(
  -    Document document, String filename, ProgrammingLanguage language
  -  )
  -  {
  -    // Store path and file name
  -    int pos = filename.lastIndexOf(File.separatorChar);
  -    String name = filename.substring(pos + 1);
  -    String path = filename.substring(0, pos).replace(File.separatorChar, '/');
  -
  -    Element root = document.getDocumentElement();
  -
  -    root.setAttribute("file-name", name);
  -    root.setAttribute("file-path", path);
  -    root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
  -
  -    this.quoteStrings(document, language);
  -
  -    return document;
  -  }
  -
  -  /**
  -   * Encode text nodes as strings according to the target programming languages
  -   * string constant escaping rules.
  -   *
  -   * @param node The node to be escaped
  -   * @param language The target programming language
  -   */
  -  protected void quoteStrings(Node node, ProgrammingLanguage language) {
  -    switch (node.getNodeType()) {
  -      case Node.PROCESSING_INSTRUCTION_NODE:
  -        ProcessingInstruction pi = (ProcessingInstruction) node;
  -	if (!pi.getTarget().equals("xml-logicsheet")) {
  -          pi.setData(language.quoteString(pi.getData()));
  -	}
  -        break;
  -      case Node.TEXT_NODE:
  -        if (true) break; // the sitemap shouldn't have any text node
  -        Element parent = (Element) node.getParentNode();
  -
  -        String tagName = parent.getTagName();
  -
  -        if (
  -          tagName.equals("xsp:expr") ||
  -          tagName.equals("xsp:logic") ||
  -          tagName.equals("xsp:structure") ||
  -          tagName.equals("xsp:include")
  -        ) {
  -          return;
  -        }
  -
  -        String value = language.quoteString(node.getNodeValue());
  -        Text textNode = node.getOwnerDocument().createTextNode(value);
  -
  -        Element textElement = node.getOwnerDocument().createElement("xsp:text");
  -
  -        textElement.appendChild(textNode);
  -        parent.replaceChild(textElement, node);
  -
  -        break;
  -      case Node.ELEMENT_NODE:
  -        ((Element) node).normalize();
  -        // Fall through
  -      default:
  -        NodeList childList = node.getChildNodes();
  -        int childCount = childList.getLength();
  -
  -        for (int i = 0; i < childCount; i++) {
  -          this.quoteStrings(childList.item(i), language);
  -        }
  -
  -        break;
  -    }
  -  }
  -
  -  /**
  -   * Returns a list of logicsheets to be applied to this document for source
  -   * code generation. This method scans the input document for
  -   * &lt;?xml-logicsheet?&gt; processing instructions and top-level
  -   * &lt;xsp:logicsheet&gt; elements. Logicsheet declarations are removed from
  -   * the input document.
  -   *
  -   * @param document The input document
  -   * @return An array of logicsheet <i>names</i>
  -   */
  -  protected String[] getLogicsheets(Document document) {
  -    Vector removedNodes = new Vector();
  -    Vector logicsheetList = new Vector();
  -    Element root = document.getDocumentElement();
  -
  -    // Retrieve logicsheets declared by processing-instruction
  -    NodeList nodeList = document.getChildNodes();
  -    int count = nodeList.getLength();
  -    for (int i = 0; i < count; i++) {
  -      Node node = nodeList.item(i);
  -      if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
  -	ProcessingInstruction pi = (ProcessingInstruction) node;
  -
  -	if (pi.getTarget().equals("xml-logicsheet")) {
  -          Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
  -	  logicsheetList.addElement(attrs.get("href"));
  -
  -	  removedNodes.addElement(pi);
  -	}
  -      }
  -    }
  -
  -    // Retrieve logicsheets declared by top-level elements
  -    nodeList = root.getElementsByTagName("map:logicsheet");
  -    count = nodeList.getLength();
  -
  -    for (int i = 0; i < count; i++) {
  -      Element logicsheetElement = (Element) nodeList.item(i);
  -      removedNodes.addElement(logicsheetElement);
  -      logicsheetList.addElement(logicsheetElement.getAttribute("location"));
  -    }
  -
  -    String[] logicsheetLocations = new String[logicsheetList.size()];
  -    logicsheetList.copyInto(logicsheetLocations);
  -
  -
  -    // Remove logicsheet directives
  -    count = removedNodes.size();
  -    for (int i = 0; i < count; i++) {
  -      Node node = (Node) removedNodes.elementAt(i); 
  -      Node parent = node.getParentNode();
  -      parent.removeChild(node);
  -    }
  -
  -    return logicsheetLocations;
  -  }
  -
  -  /**
  -   * Add a dependency on an external file to the document for inclusion in
  -   * generated code. This is used by <code>AbstractServerPagesGenerator</code>
  -   * to populate a list of <code>File</code>'s tested for change on each
  -   * invocation; this information, in turn, is used by
  -   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  -   * necessary. XSP uses &lt;xsp:dependency&gt; elements for this purpose
  -   *
  -   * @param PARAM_NAME Param description
  -   * @return the value
  -   * @exception EXCEPTION_NAME If an error occurs
  -   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  -   *      and <code>ServerPagesLoaderImpl</code>
  -   */
  -/** Sitemaps don't (yet) have dependencies */
  -  protected void addDependency(Document document, String location) {
  -    Element root = document.getDocumentElement();
  -    Element dependency = document.createElement("xsp:dependency");
  -    dependency.appendChild(document.createTextNode(location));
  -    root.appendChild(dependency);
  -  }
  -/* */
  -
  -  /**
  -   * Scan top-level document elements for non-xsp tag names returning the first
  -   * (and hopefully <i>only</i>) user-defined element
  -   *
  -   * @param document The input document
  -   * @return The first non-xsp element
  -   */
  -/** Sitemaps don't have a user root
  -  protected Element getUserRoot(Document document) {
  -    Element root = document.getDocumentElement();
  -    NodeList elements = root.getElementsByTagName("*");
  -    int elementCount = elements.getLength();
  -    for (int i = 0; i < elementCount; i++) {
  -      Element userRoot = (Element) elements.item(i);
  -      if (!userRoot.getTagName().startsWith("map:")) {
  -        return userRoot;
  -      }
  -    }
  -
  -    return null;
  -  }
  -*/
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.sitemap;
  +
  +import java.io.File;
  +import java.util.Date;
  +import java.util.Vector;
  +import java.util.Hashtable;
  +
  +import org.w3c.dom.Node;
  +import org.w3c.dom.Text;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.ProcessingInstruction;
  +
  +import org.apache.cocoon.util.DOMUtils;
  +import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
  +
  +import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  +
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * This class implements <code>MarkupLanguage</code> for Cocoon's
  + * <a href="http://xml.apache.org/cocoon/sitemap.html">Sitemap</a>.
  + *
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:34 $
  + */
  +public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
  +  /**
  +   * The default constructor.
  +   */
  +  public SitemapMarkupLanguage() throws SAXException, IOException {
  +    super();
  +  }
  +
  +  /**
  +   * Return the Sitemap language name: <i>map</i> :-)
  +   *
  +   * @return The <i>map</i> constant
  +   */
  +  public String getName() {
  +    return "map";
  +  }
  +
  +  /**
  +   * Return the document-declared encoding or <code>null</code> if it's the
  +   * platform's default encoding
  +   *
  +   * @param document The input document
  +   * @return The document-declared encoding
  +   */
  +  public String getEncoding(Document document) {
  +    String encoding = document.getDocumentElement().getAttribute("encoding");
  +
  +    if (encoding.length() > 0) {
  +      return encoding;
  +    }
  +
  +    return null;
  +  }
  +
  +  /**
  +   * Prepare the document for logicsheet processing and code generation. This
  +   * method sets the base filename, file path and creation date as root element
  +   * attibutes and encodes text nodes as strings.
  +   *
  +   * @param document The input document
  +   * @param filename The input source filename
  +   * @param language The target programming language
  +   * @return The augmented document
  +   */
  +  protected Document preprocessDocument(
  +    Document document, String filename, ProgrammingLanguage language
  +  )
  +  {
  +    // Store path and file name
  +    int pos = filename.lastIndexOf(File.separatorChar);
  +    String name = filename.substring(pos + 1);
  +    String path = filename.substring(0, pos).replace(File.separatorChar, '/');
  +
  +    Element root = document.getDocumentElement();
  +
  +    root.setAttribute("file-name", name);
  +    root.setAttribute("file-path", path);
  +    root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
  +
  +    this.quoteStrings(document, language);
  +
  +    return document;
  +  }
  +
  +  /**
  +   * Encode text nodes as strings according to the target programming languages
  +   * string constant escaping rules.
  +   *
  +   * @param node The node to be escaped
  +   * @param language The target programming language
  +   */
  +  protected void quoteStrings(Node node, ProgrammingLanguage language) {
  +    switch (node.getNodeType()) {
  +      case Node.PROCESSING_INSTRUCTION_NODE:
  +        ProcessingInstruction pi = (ProcessingInstruction) node;
  +	if (!pi.getTarget().equals("xml-logicsheet")) {
  +          pi.setData(language.quoteString(pi.getData()));
  +	}
  +        break;
  +      case Node.TEXT_NODE:
  +        if (true) break; // the sitemap shouldn't have any text node
  +        Element parent = (Element) node.getParentNode();
  +
  +        String tagName = parent.getTagName();
  +
  +        if (
  +          tagName.equals("xsp:expr") ||
  +          tagName.equals("xsp:logic") ||
  +          tagName.equals("xsp:structure") ||
  +          tagName.equals("xsp:include")
  +        ) {
  +          return;
  +        }
  +
  +        String value = language.quoteString(node.getNodeValue());
  +        Text textNode = node.getOwnerDocument().createTextNode(value);
  +
  +        Element textElement = node.getOwnerDocument().createElement("xsp:text");
  +
  +        textElement.appendChild(textNode);
  +        parent.replaceChild(textElement, node);
  +
  +        break;
  +      case Node.ELEMENT_NODE:
  +        ((Element) node).normalize();
  +        // Fall through
  +      default:
  +        NodeList childList = node.getChildNodes();
  +        int childCount = childList.getLength();
  +
  +        for (int i = 0; i < childCount; i++) {
  +          this.quoteStrings(childList.item(i), language);
  +        }
  +
  +        break;
  +    }
  +  }
  +
  +  /**
  +   * Returns a list of logicsheets to be applied to this document for source
  +   * code generation. This method scans the input document for
  +   * &lt;?xml-logicsheet?&gt; processing instructions and top-level
  +   * &lt;xsp:logicsheet&gt; elements. Logicsheet declarations are removed from
  +   * the input document.
  +   *
  +   * @param document The input document
  +   * @return An array of logicsheet <i>names</i>
  +   */
  +  protected String[] getLogicsheets(Document document) {
  +    Vector removedNodes = new Vector();
  +    Vector logicsheetList = new Vector();
  +    Element root = document.getDocumentElement();
  +
  +    // Retrieve logicsheets declared by processing-instruction
  +    NodeList nodeList = document.getChildNodes();
  +    int count = nodeList.getLength();
  +    for (int i = 0; i < count; i++) {
  +      Node node = nodeList.item(i);
  +      if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
  +	ProcessingInstruction pi = (ProcessingInstruction) node;
  +
  +	if (pi.getTarget().equals("xml-logicsheet")) {
  +          Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
  +	  logicsheetList.addElement(attrs.get("href"));
  +
  +	  removedNodes.addElement(pi);
  +	}
  +      }
  +    }
  +
  +    // Retrieve logicsheets declared by top-level elements
  +    nodeList = root.getElementsByTagName("map:logicsheet");
  +    count = nodeList.getLength();
  +
  +    for (int i = 0; i < count; i++) {
  +      Element logicsheetElement = (Element) nodeList.item(i);
  +      removedNodes.addElement(logicsheetElement);
  +      logicsheetList.addElement(logicsheetElement.getAttribute("location"));
  +    }
  +
  +    String[] logicsheetLocations = new String[logicsheetList.size()];
  +    logicsheetList.copyInto(logicsheetLocations);
  +
  +
  +    // Remove logicsheet directives
  +    count = removedNodes.size();
  +    for (int i = 0; i < count; i++) {
  +      Node node = (Node) removedNodes.elementAt(i); 
  +      Node parent = node.getParentNode();
  +      parent.removeChild(node);
  +    }
  +
  +    return logicsheetLocations;
  +  }
  +
  +  /**
  +   * Add a dependency on an external file to the document for inclusion in
  +   * generated code. This is used by <code>AbstractServerPagesGenerator</code>
  +   * to populate a list of <code>File</code>'s tested for change on each
  +   * invocation; this information, in turn, is used by
  +   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  +   * necessary. XSP uses &lt;xsp:dependency&gt; elements for this purpose
  +   *
  +   * @param PARAM_NAME Param description
  +   * @return the value
  +   * @exception EXCEPTION_NAME If an error occurs
  +   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  +   *      and <code>ServerPagesLoaderImpl</code>
  +   */
  +/** Sitemaps don't (yet) have dependencies */
  +  protected void addDependency(Document document, String location) {
  +    Element root = document.getDocumentElement();
  +    Element dependency = document.createElement("xsp:dependency");
  +    dependency.appendChild(document.createTextNode(location));
  +    root.appendChild(dependency);
  +  }
  +/* */
  +
  +  /**
  +   * Scan top-level document elements for non-xsp tag names returning the first
  +   * (and hopefully <i>only</i>) user-defined element
  +   *
  +   * @param document The input document
  +   * @return The first non-xsp element
  +   */
  +/** Sitemaps don't have a user root
  +  protected Element getUserRoot(Document document) {
  +    Element root = document.getDocumentElement();
  +    NodeList elements = root.getElementsByTagName("*");
  +    int elementCount = elements.getLength();
  +    for (int i = 0; i < elementCount; i++) {
  +      Element userRoot = (Element) elements.item(i);
  +      if (!userRoot.getTagName().startsWith("map:")) {
  +        return userRoot;
  +      }
  +    }
  +
  +    return null;
  +  }
  +*/
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.12  +575 -571  xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
  
  Index: sitemap.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
  retrieving revision 1.1.2.11
  retrieving revision 1.1.2.12
  diff -u -r1.1.2.11 -r1.1.2.12
  --- sitemap.xsl	2000/07/20 21:56:58	1.1.2.11
  +++ sitemap.xsl	2000/07/22 20:41:35	1.1.2.12
  @@ -1,575 +1,579 @@
  -<?xml version="1.0"?>
  -<!-- Sitemap Core logicsheet for the Java language -->
  -
  -<xsl:stylesheet version="1.0"
  -  xmlns:map="http://apache.org/cocoon/sitemap/1.0" 
  -  xmlns:java="http://xml.apache.org/xslt/java"
  -  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  ->
  -
  -  <xsl:output method="text"/>
  -
  -  <xsl:variable name="prefix">map</xsl:variable>
  -  <xsl:variable name="matcher-factory-loader" select="java:org.apache.cocoon.sitemap.XSLTMatcherFactoryLoader.new()"/>
  -  <xsl:variable name="selector-factory-loader" select="java:org.apache.cocoon.sitemap.XSLTSelectorFactoryLoader.new()"/>
  -
  -  <xsl:template match="/">
  -    <code xml:space="preserve">
  -      <xsl:apply-templates/>
  -    </code>
  -  </xsl:template>
  -  
  -  <xsl:template match="map:sitemap"> 
  -    package <xsl:value-of select="translate(@file-path, '/', '.')"/>;
  - 
  -    import java.io.OutputStream;
  -    import java.io.IOException;
  -
  -    import java.util.ArrayList; 
  -
  -    import org.apache.avalon.Configuration;
  -    import org.apache.avalon.ConfigurationException;
  -    import org.apache.avalon.SAXConfigurationBuilder;
  -    import org.apache.avalon.utils.Parameters; 
  -
  -    import org.apache.cocoon.environment.Environment;
  -    import org.apache.cocoon.generation.Generator;
  -    import org.apache.cocoon.matching.Matcher;
  -    import org.apache.cocoon.reading.Reader;
  -    import org.apache.cocoon.selection.Selector;
  -    import org.apache.cocoon.serialization.Serializer;
  -    import org.apache.cocoon.sitemap.AbstractSitemapProcessor;
  -    import org.apache.cocoon.sitemap.ProcessingException;
  -    import org.apache.cocoon.sitemap.ResourcePipeline;
  -    import org.apache.cocoon.sitemap.SitemapProcessor;
  -    import org.apache.cocoon.transformation.Transformer;
  -
  -    import org.xml.sax.SAXException;
  -    import org.xml.sax.helpers.AttributesImpl;
  -
  +<?xml version="1.0"?>
  +<!-- Sitemap Core logicsheet for the Java language -->
  +
  +<xsl:stylesheet version="1.0"
  +  xmlns:map="http://apache.org/cocoon/sitemap/1.0" 
  +  xmlns:java="http://xml.apache.org/xslt/java"
  +  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  +>
  +
  +  <xsl:output method="text"/>
  +
  +  <xsl:variable name="prefix">map</xsl:variable>
  +  <xsl:variable name="matcher-factory-loader" select="java:org.apache.cocoon.sitemap.XSLTMatcherFactoryLoader.new()"/>
  +  <xsl:variable name="selector-factory-loader" select="java:org.apache.cocoon.sitemap.XSLTSelectorFactoryLoader.new()"/>
  +
  +  <xsl:template match="/">
  +    <code xml:space="preserve">
  +      <xsl:apply-templates/>
  +    </code>
  +  </xsl:template>
  +  
  +  <xsl:template match="map:sitemap"> 
  +    package <xsl:value-of select="translate(@file-path, '/', '.')"/>;
  + 
  +    import java.io.OutputStream;
  +    import java.io.IOException;
  +
  +    import java.util.List; 
  +    import java.util.ArrayList; 
  +
  +    import org.apache.avalon.Configurable;
  +    import org.apache.avalon.Configuration;
  +    import org.apache.avalon.ConfigurationException;
  +    import org.apache.avalon.SAXConfigurationBuilder;
  +    import org.apache.avalon.utils.Parameters; 
  +
  +    import org.apache.cocoon.ProcessingException;
  +    import org.apache.cocoon.environment.Environment;
  +    import org.apache.cocoon.generation.Generator;
  +    import org.apache.cocoon.matching.Matcher;
  +    import org.apache.cocoon.reading.Reader;
  +    import org.apache.cocoon.selection.Selector;
  +    import org.apache.cocoon.serialization.Serializer;
  +    import org.apache.cocoon.sitemap.AbstractSitemap;
  +    import org.apache.cocoon.sitemap.ResourcePipeline;
  +    import org.apache.cocoon.sitemap.Sitemap;
  +    import org.apache.cocoon.sitemap.SitemapManager;
  +    import org.apache.cocoon.transformation.Transformer;
  +
  +    import org.xml.sax.SAXException;
  +    import org.xml.sax.helpers.AttributesImpl;
  +<!--
   /**
  + *
  + * @author &lt;a href="mailto:Giacomo.Pati@pwr.ch"&gt;Giacomo Pati&lt;/a&gt;
  + * @version CVS $Revision: 1.1.2.12 $ $Date: 2000/07/22 20:41:35 $
    *
  - * @author &lt;a href="mailto:Giacomo.Pati@pwr.ch"&gt;Giacomo Pati&lt;/a&gt;
  - * @version CVS $Revision: 1.1.2.11 $ $Date: 2000/07/20 21:56:58 $
  - */
  -public class <xsl:value-of select="@file-name"/> extends AbstractSitemapProcessor {
  -    
  -    Parameters emptyParam = new Parameters(); 
  -
  -    private Generator generator_error_handler = null;
  -
  -    <!-- generate variables for all components -->
  -    /** The generators */
  -    <xsl:for-each select="/map:sitemap/map:components/map:generators/map:generator">
  -      private Generator generator_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  -    </xsl:for-each>
  -    
  -    /** The transformers */
  -    <xsl:for-each select="/map:sitemap/map:components/map:transformers/map:transformer">
  -      private Transformer transformer_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  -    </xsl:for-each>
  -    
  -    /** The readers */
  -    <xsl:for-each select="/map:sitemap/map:components/map:readers/map:reader">
  -      private Reader reader_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  -    </xsl:for-each>
  -    
  -    /** The serializers */
  -    <xsl:for-each select="/map:sitemap/map:components/map:serializers/map:serializer">
  -      private Serializer serializer_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  -    </xsl:for-each>
  -    
  -    /** The matchers */
  -    <xsl:for-each select="/map:sitemap/map:components/map:matchers/map:matcher[@src]">
  -      private Matcher matcher_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  -    </xsl:for-each>
  -      
  -    /** The selectors */  
  -    <xsl:for-each select="/map:sitemap/map:components/map:selectors/map:selector[@src]">
  -      private Selector selector_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  -    </xsl:for-each>
  -      
  -    /** The sub sitemaps */  
  -    <xsl:for-each select="/map:sitemap/map:pipelines//map:mount">  
  -      SitemapProcessor sitemap_<xsl:value-of select="translate(./@uri-prefix, '- /{}', '___')"/> = null;
  -    </xsl:for-each>
  -
  -    /** The generated matchers */
  -    <xsl:for-each select="/map:sitemap/map:components/map:matchers/map:matcher[@factory]">
  -      <xsl:variable name="factory" select="@factory"/>
  -      <xsl:variable name="type" select="@name"/>
  -      <xsl:variable name="default"><xsl:if test="$type = ../@default">true</xsl:if></xsl:variable>
  -      <xsl:variable name="config"><xsl:copy-of select="."/></xsl:variable>
  -      <xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:match[@type=$type or (not(@type) and $default!='')]">
  -        <xsl:variable name="matcher-name1" select="translate(@pattern,'/- *?@:{}()[].#^\\$|&#33;','_')"/>
  -        <xsl:variable name="matcher-name">matcher_<xsl:value-of select='translate($matcher-name1,"&#39;","")'/></xsl:variable>
  -        <xsl:value-of select="java:getSource($matcher-factory-loader, string('class'), string($factory), string($matcher-name), string(@pattern), $config)"/>
  -        private List <xsl:value-of select="$matcher-name"/> (String pattern, Environment environment) {
  -          <xsl:value-of select="java:getSource($matcher-factory-loader, string('method'), string($factory), string($matcher-name), string(@pattern), $config)"/>
  -        }
  -      </xsl:for-each>
  -    </xsl:for-each>
  -
  -    /** The generated selectors */
  -    <xsl:for-each select="/map:sitemap/map:components/map:selectors/map:selector[@factory]">
  -      <xsl:variable name="factory" select="@factory"/>
  -      <xsl:variable name="type" select="@name"/>
  -      <xsl:variable name="default"><xsl:if test="$type = ../@default">true</xsl:if></xsl:variable>
  -      <xsl:variable name="config"><xsl:copy-of select="."/></xsl:variable>
  -      <xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:when[../map:select/@type=$type or (not(../map:select/@type) and $default!='')]">
  -        <xsl:variable name="selector-name1" select="translate(@test,'/- *?@:{}()[].#^\\$|&#33;','_')"/>
  -        <xsl:variable name="selector-name">selector_<xsl:value-of select='translate($selector-name1,"&#39;","")'/></xsl:variable>
  -        <xsl:value-of select="java:getSource($selector-factory-loader, string('class'), string($factory), string($selector-name), string(@test), $config)"/>
  -        private boolean <xsl:value-of select="$selector-name"/> (String test, Environment environment) {
  -          <xsl:value-of select="java:getSource($selector-factory-loader, string('method'), string($factory), string($selector-name), string(@test), $config)"/>
  -        }
  -      </xsl:for-each>
  -    </xsl:for-each>
  -
  -<!--
  -    /** The generated mounter */
  -    <xsl:for-each select="/map:sitemap/map:mounts/map:mount">
  -      <xsl:variable name="mounter-name1" select="translate(@uri-expr,'/- *?@:{}()[].#^\\$|&#33;','_')"/>
  -      <xsl:variable name="mounter-name">mounter_<xsl:value-of select='translate($mounter-name1,"&#39;","")'/></xsl:variable>
  -      <xsl:variable name="config"><xsl:copy-of select="."/></xsl:variable>
  -      <xsl:value-of select="java:getSource($matcher-factory-loader, string('class'), 'org.apache.cocoon.matching.RegexpURIMatcherFactory', string($mounter-name), string(@uri-expr), $config)"/>
  -      private boolean <xsl:value-of select="$mounter-name"/> (String pattern, Environment environment) {
  -        <xsl:value-of select="java:getSource($matcher-factory-loader, string('method'), 'org.apache.cocoon.matching.RegexpURIMatcherFactory', string($mounter-name), string(@uri-expr), $config)"/>
  -      }
  -    </xsl:for-each>
  +/
   -->
  -
  -    /**
  -     * Pass a &lt;code&gt;Configuration&lt;/code&gt; instance to this
  -     * &lt;code&gt;Configurable&lt;/code&gt; class.
  -     */
  -    public void setConfiguration(Configuration xconf) 
  -    throws ConfigurationException {
  -      SAXConfigurationBuilder confBuilder = new SAXConfigurationBuilder ();
  -      AttributesImpl attr = new AttributesImpl();
  -
  -    <!-- configure all components -->
  -    /* Configure generators */
  -    <xsl:call-template name="config-components">
  -      <xsl:with-param name="name">generator</xsl:with-param>
  -      <xsl:with-param name="interface">Generator</xsl:with-param>
  -      <xsl:with-param name="components" 
  -          select="/map:sitemap/map:components/map:generators/map:generator"/>
  -    </xsl:call-template>    
  -
  -    /* Configure transformers */
  -    <xsl:call-template name="config-components">
  -      <xsl:with-param name="name">transformer</xsl:with-param>
  -      <xsl:with-param name="interface">Transformer</xsl:with-param>
  -      <xsl:with-param name="components" 
  -          select="/map:sitemap/map:components/map:transformers/map:transformer"/>
  -    </xsl:call-template>    
  -
  -    /* Configure readers */
  -    <xsl:call-template name="config-components">
  -      <xsl:with-param name="name">reader</xsl:with-param>
  -      <xsl:with-param name="interface">Reader</xsl:with-param>
  -      <xsl:with-param name="components" 
  -          select="/map:sitemap/map:components/map:readers/map:reader"/>
  -    </xsl:call-template>    
  -    
  -    /* Configure serializers */
  -    <xsl:call-template name="config-components">
  -      <xsl:with-param name="name">serializer</xsl:with-param>
  -      <xsl:with-param name="interface">Serializer</xsl:with-param>
  -      <xsl:with-param name="components" 
  -          select="/map:sitemap/map:components/map:serializers/map:serializer"/>
  -    </xsl:call-template>    
  -
  -    /* Configure matchers */
  -    <xsl:call-template name="config-components">
  -      <xsl:with-param name="name">matcher</xsl:with-param>
  -      <xsl:with-param name="interface">Matcher</xsl:with-param>
  -      <xsl:with-param name="components" 
  -          select="/map:sitemap/map:components/map:matchers/map:matcher[@src]"/>
  -    </xsl:call-template>
  -    
  -    /* Configure selectors */
  -    <xsl:call-template name="config-components">
  -      <xsl:with-param name="name">selector</xsl:with-param>
  -      <xsl:with-param name="interface">Selector</xsl:with-param>
  -      <xsl:with-param name="components" 
  -          select="/map:sitemap/map:components/map:selectors/map:selector[@src]"/>
  -    </xsl:call-template>
  -
  -    /* Configure mounted sitemaps */
  -    /* SitemapManager sm = SitemapManager.getInstance(); */
  -    /* sm.beginRegistration (this); */
  -    <xsl:for-each select="/map:sitemap/map:pipelines//map:mount">  
  -      /* sitemap_<xsl:value-of select="translate(./@uri-prefix, '- /{}', '___')"/> = sm.registerSitemap (this, substitute(listOfLists,"<xsl:value-of select="@src"/>")); */
  -      sitemap_<xsl:value-of select="translate(./@uri-prefix, '- /{}', '___')"/>.setConfiguration (null);
  -    </xsl:for-each>
  -    /* sm.endRegistration (this); */
  +public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
  +    
  +    private Parameters emptyParam = new Parameters(); 
  +
  +    private Generator generator_error_handler = null;
  +
  +    <!-- generate variables for all components -->
  +    /** The generators */
  +    <xsl:for-each select="/map:sitemap/map:components/map:generators/map:generator">
  +      private Generator generator_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  +    </xsl:for-each>
  +    
  +    /** The transformers */
  +    <xsl:for-each select="/map:sitemap/map:components/map:transformers/map:transformer">
  +      private Transformer transformer_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  +    </xsl:for-each>
  +    
  +    /** The readers */
  +    <xsl:for-each select="/map:sitemap/map:components/map:readers/map:reader">
  +      private Reader reader_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  +    </xsl:for-each>
  +    
  +    /** The serializers */
  +    <xsl:for-each select="/map:sitemap/map:components/map:serializers/map:serializer">
  +      private Serializer serializer_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  +    </xsl:for-each>
  +    
  +    /** The matchers */
  +    <xsl:for-each select="/map:sitemap/map:components/map:matchers/map:matcher[@src]">
  +      private Matcher matcher_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  +    </xsl:for-each>
  +      
  +    /** The selectors */  
  +    <xsl:for-each select="/map:sitemap/map:components/map:selectors/map:selector[@src]">
  +      private Selector selector_<xsl:value-of select="translate(./@name, '- ', '__')"/> = null;
  +    </xsl:for-each>
  +      
  +    /** The generated matchers */
  +    <xsl:for-each select="/map:sitemap/map:components/map:matchers/map:matcher[@factory]">
  +      <xsl:variable name="factory" select="@factory"/>
  +      <xsl:variable name="type" select="@name"/>
  +      <xsl:variable name="default"><xsl:if test="$type = ../@default">true</xsl:if></xsl:variable>
  +      <xsl:variable name="config"><xsl:copy-of select="."/></xsl:variable>
  +      <xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:match[@type=$type or (not(@type) and $default!='')]">
  +        <xsl:variable name="matcher-name1" select="translate(@pattern,'/- *?@:{}()[].#^\\$|&#33;','_')"/>
  +        <xsl:variable name="matcher-name">matcher_<xsl:value-of select='translate($matcher-name1,"&#39;","")'/></xsl:variable>
  +        <xsl:value-of select="java:getSource($matcher-factory-loader, string('class'), string($factory), string($matcher-name), string(@pattern), $config)"/>
  +        private List <xsl:value-of select="$matcher-name"/> (String pattern, Environment environment) {
  +          <xsl:value-of select="java:getSource($matcher-factory-loader, string('method'), string($factory), string($matcher-name), string(@pattern), $config)"/>
  +        }
  +      </xsl:for-each>
  +    </xsl:for-each>
  +
  +    /** The generated selectors */
  +    <xsl:for-each select="/map:sitemap/map:components/map:selectors/map:selector[@factory]">
  +      <xsl:variable name="factory" select="@factory"/>
  +      <xsl:variable name="type" select="@name"/>
  +      <xsl:variable name="default"><xsl:if test="$type = ../@default">true</xsl:if></xsl:variable>
  +      <xsl:variable name="config"><xsl:copy-of select="."/></xsl:variable>
  +      <xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:when[../map:select/@type=$type or (not(../map:select/@type) and $default!='')]">
  +        <xsl:variable name="selector-name1" select="translate(@test,'/- *?@:{}()[].#^\\$|&#33;','_')"/>
  +        <xsl:variable name="selector-name">selector_<xsl:value-of select='translate($selector-name1,"&#39;","")'/></xsl:variable>
  +        <xsl:value-of select="java:getSource($selector-factory-loader, string('class'), string($factory), string($selector-name), string(@test), $config)"/>
  +        private boolean <xsl:value-of select="$selector-name"/> (String test, Environment environment) {
  +          <xsl:value-of select="java:getSource($selector-factory-loader, string('method'), string($factory), string($selector-name), string(@test), $config)"/>
  +        }
  +      </xsl:for-each>
  +    </xsl:for-each>
  +
  +    /**
  +     * Pass a &lt;code&gt;Configuration&lt;/code&gt; instance to this
  +     * &lt;code&gt;Configurable&lt;/code&gt; class.
  +     */
  +    public void setConfiguration(Configuration conf) 
  +    throws ConfigurationException /*, SAXException, ClassNotFoundException,
  +           InstantiationException, IllegalAccessException */ {
  +      SAXConfigurationBuilder confBuilder = new SAXConfigurationBuilder (); 
  +      Configuration cconf = null; 
  +      AttributesImpl attr = new AttributesImpl();
  +
  +      this.sitemapManager = new SitemapManager();
  +      this.sitemapManager.setComponentManager(this.manager);
  +      this.sitemapManager.setConfiguration(conf);
  +
     try {
  +      <!-- configure all components -->
  +      /* Configure generators */
  +      <xsl:call-template name="config-components">
  +        <xsl:with-param name="name">generator</xsl:with-param>
  +        <xsl:with-param name="interface">Generator</xsl:with-param>
  +        <xsl:with-param name="components" 
  +            select="/map:sitemap/map:components/map:generators/map:generator"/>
  +      </xsl:call-template>    
  +
  +      /* Configure transformers */
  +      <xsl:call-template name="config-components">
  +        <xsl:with-param name="name">transformer</xsl:with-param>
  +        <xsl:with-param name="interface">Transformer</xsl:with-param>
  +        <xsl:with-param name="components" 
  +            select="/map:sitemap/map:components/map:transformers/map:transformer"/>
  +      </xsl:call-template>    
  +
  +      /* Configure readers */
  +      <xsl:call-template name="config-components">
  +        <xsl:with-param name="name">reader</xsl:with-param>
  +        <xsl:with-param name="interface">Reader</xsl:with-param>
  +        <xsl:with-param name="components" 
  +            select="/map:sitemap/map:components/map:readers/map:reader"/>
  +      </xsl:call-template>    
  +    
  +      /* Configure serializers */
  +      <xsl:call-template name="config-components">
  +        <xsl:with-param name="name">serializer</xsl:with-param>
  +        <xsl:with-param name="interface">Serializer</xsl:with-param>
  +        <xsl:with-param name="components" 
  +            select="/map:sitemap/map:components/map:serializers/map:serializer"/>
  +      </xsl:call-template>    
  +
  +      /* Configure matchers */
  +      <xsl:call-template name="config-components">
  +        <xsl:with-param name="name">matcher</xsl:with-param>
  +        <xsl:with-param name="interface">Matcher</xsl:with-param>
  +        <xsl:with-param name="components" 
  +            select="/map:sitemap/map:components/map:matchers/map:matcher[@src]"/>
  +      </xsl:call-template>
  +    
  +      /* Configure selectors */
  +      <xsl:call-template name="config-components">
  +        <xsl:with-param name="name">selector</xsl:with-param>
  +        <xsl:with-param name="interface">Selector</xsl:with-param>
  +        <xsl:with-param name="components" 
  +            select="/map:sitemap/map:components/map:selectors/map:selector[@src]"/>
  +      </xsl:call-template>
  +      } catch (Exception e) {
  +        throw new ConfigurationException (e.toString(), cconf);
  +      }
       }
  -
  -    <xsl:for-each select="/map:sitemap/map:resources/map:resource">
  -      private boolean resource_<xsl:value-of select="translate(@name, '- ', '__')"/> (ResourcePipeline pipeline, 
  -          ArrayList listOfLists, Environment environment, OutputStream out) 
  -      throws SAXException, IOException, ProcessingException { 
  -        List list = null;
  -        Parameters param = null; 
  -        <xsl:apply-templates select="./*"/>
  -      }
  -    </xsl:for-each>
  - 
  -    /** 
  -     * Process the given <code>Request</code> producing the output to the 
  -     * specified <code>Response</code> and <code>OutputStream</code>. 
  -     */ 
  -    public boolean process(Environment environment, OutputStream out)  
  -    throws SAXException, IOException, ProcessingException { 
  -      ResourcePipeline pipeline = new ResourcePipeline ();
  -      ArrayList listOfLists = new ArrayList();
  -      ArrayList list = null;
  -      Parameters param = null; 
  -      <xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline">
  -        try {
  -          <xsl:apply-templates select="./*"/>
  -        } catch (Exception e) {
  -          <xsl:choose>
  -            <xsl:when test="not (./map:handle-errors)">
  -             throw e;
  -            </xsl:when>
  -            <xsl:otherwise>
  -              pipeline.setGenerator (generator_error_handler, e.getMessage(), emptyParam);
  -              <xsl:apply-templates select="./map:handle-error/*"/>
  -              return pipeline.process (Environment environment, out);
  -            </xsl:otherwise>
  -          </xsl:choose>
  -        }
  -      </xsl:for-each>
  -    }
  -}
  -
  -  </xsl:template> <!-- match="map:sitemap" -->
  -
  -  <xsl:template match="map:match">
  -    <xsl:variable name="matcher-type">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="parname">type</xsl:with-param>
  -        <xsl:with-param name="default"><xsl:value-of select="/map:sitemap/map:components/map:matchers/@default"/></xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -    <xsl:variable name="pattern-value">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="parname">pattern</xsl:with-param>
  -        <xsl:with-param name="required">true</xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -    <xsl:variable name="matcher-name1" select="translate(@pattern,'/- *?@:{}()[].#^\\$|&#33;','_')"/>
  -    <xsl:variable name="matcher-name2" select='translate($matcher-name1,"&#39;","")'/>
  -    <xsl:variable name="matcher-name">
  -      <xsl:for-each select="/map:sitemap/map:components/map:matchers/map:matcher[@name=$matcher-type]">
  -        <xsl:choose>
  -          <xsl:when test="(./@src)">
  -            matcher_<xsl:value-of select="translate($matcher-type, '- ', '__')"/>.match
  -          </xsl:when>
  -          <xsl:when test="(./@factory)">
  -            matcher_<xsl:value-of select="$matcher-name2"/>
  -          </xsl:when>
  -          <xsl:otherwise>
  -            <xsl:call-template name="error">
  -              <xsl:with-param name="message">cannot choose a matcher name <xsl:value-of select="$matcher-type"/></xsl:with-param>
  -            </xsl:call-template>
  -          </xsl:otherwise>
  -        </xsl:choose>
  -      </xsl:for-each>
  -    </xsl:variable>
  -    if ((list = <xsl:value-of select="$matcher-name"/> ("<xsl:value-of select="$pattern-value"/>", environment)) != null) {
  -       listOfLists.add (list);  
  -       <xsl:apply-templates/>
  -    }
  -  </xsl:template> <!-- match="map:match" -->
  -
  -  <xsl:template match="map:select">
  -    <xsl:variable name="selector-type">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="parname">type</xsl:with-param>
  -        <xsl:with-param name="default"><xsl:value-of select="/map:sitemap/map:components/map:selectors/@default"/></xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -    <xsl:for-each select="./map:when">
  -      <xsl:variable name="test-value">
  -        <xsl:call-template name="get-parameter">
  -          <xsl:with-param name="parname">test</xsl:with-param>
  -          <xsl:with-param name="required">true</xsl:with-param>
  -        </xsl:call-template>
  -      </xsl:variable>
  -      <xsl:variable name="selector-name1" select="translate($test-value,'/- *?@:{}()[].#^\\$|&#33;','_')"/>
  -      <xsl:variable name="selector-name2" select='translate($selector-name1,"&#39;","")'/>
  -      <xsl:variable name="selector-name">
  -        <xsl:for-each select="/map:sitemap/map:components/map:selectors/map:selector[@name=$selector-type]">
  -          <xsl:choose>
  -            <xsl:when test="(./@src)">
  -              selector_<xsl:value-of select="translate($selector-type, '- ', '__')"/>.select
  -            </xsl:when>
  -            <xsl:when test="(./@factory)">
  -              selector_<xsl:value-of select="$selector-name2"/>
  -            </xsl:when>
  -            <xsl:otherwise>
  -              <xsl:call-template name="error">
  -                <xsl:with-param name="message">cannot choose a selector name <xsl:value-of select="$selector-type"/></xsl:with-param>
  -              </xsl:call-template>
  -            </xsl:otherwise>
  -          </xsl:choose>
  -        </xsl:for-each>
  -      </xsl:variable>
  -      if (<xsl:value-of select="$selector-name"/> ("<xsl:value-of select="$test-value"/>", environment)) {
  -       <xsl:apply-templates/>
  -      }
  -    </xsl:for-each>
  -
  -    <xsl:for-each select="./map:otherwise">
  -      else {
  -      <xsl:apply-templates/>
  -      }
  -    </xsl:for-each>
  -  </xsl:template> <!-- match="/map:sitemap/map:select" -->
  -
  -  <xsl:template match="map:generate">
  -    <xsl:call-template name="setup-component">
  -      <xsl:with-param name="default-component" select="/map:sitemap/map:components/map:generators/@default"/>
  -      <xsl:with-param name="method">setGenerator</xsl:with-param>
  -      <xsl:with-param name="prefix">generator</xsl:with-param>
  -    </xsl:call-template>
  -  </xsl:template> <!-- match="map:generate" -->
  -
  -  <xsl:template match="map:transform">
  -    <xsl:call-template name="setup-component">
  -      <xsl:with-param name="default-component" select="/map:sitemap/map:components/map:transformers/@default"/>
  -      <xsl:with-param name="method">addTransformer</xsl:with-param>
  -      <xsl:with-param name="prefix">transformer</xsl:with-param>
  -    </xsl:call-template>
  -  </xsl:template> <!-- match="map:transormer" -->
  -
  -  <xsl:template match="map:serialize">
  -    <xsl:call-template name="setup-component">
  -      <xsl:with-param name="default-component" select="/map:sitemap/map:components/map:serializers/@default"/>
  -      <xsl:with-param name="method">setSerializer</xsl:with-param>
  -      <xsl:with-param name="prefix">serializer</xsl:with-param>
  -    </xsl:call-template> 
  -    return pipeline.process (environment, out);
  -  </xsl:template> <!-- match="map:serialize" --> 
  -
  -  <xsl:template match="map:read">
  -    <xsl:call-template name="setup-component">
  -      <xsl:with-param name="default-component" select="/map:sitemap/map:components/map:readers/@default"/>
  -      <xsl:with-param name="method">setReader</xsl:with-param>
  -      <xsl:with-param name="prefix">reader</xsl:with-param>
  -    </xsl:call-template> 
  -    return reader_<xsl:value-of select="translate(./@name, '- ', '__')"/>.process (environment, out);
  -  </xsl:template> <!-- match="map:read" --> 
  -
  -  <xsl:template match="map:mount">
  -    <xsl:variable name="src" select="@src"/>
  -    <xsl:variable name="pos"><xsl:value-of select="translate(./@uri-prefix, '- /{}', '___')"/></xsl:variable>
  -    environment.addUriPrefix (substitute(listOfLists,"<xsl:value-of select="./@uri-prefix"/>")); 
  -    return sitemapManager.invoke (substitute(listOfLists,"<xsl:value-of select="@src"/>"), "<xsl:value-of select="@check-reload"/>", environment, out);
  -  </xsl:template> <!-- match="map:mount" -->
  -
  -  <xsl:template match="map:redirect-to">
  -    <xsl:choose>
  -      <xsl:when test="@resource">
  -        return resource_<xsl:value-of select="translate(@resource, '- ', '__')"/>(pipeline, listOfLists, environment, out);
  -      </xsl:when>
  -      <xsl:when test="@uri">
  -        // request.setUri ("<xsl:value-of select="@uri"/>");
  -        // this.process(environment, out);
  -      </xsl:when>
  -      <xsl:otherwise>
  -        <xsl:call-template name="error">
  -          <xsl:with-param name="message">Missing attribute uri= or resource= to element redirect-to</xsl:with-param>
  -        </xsl:call-template>
  -      </xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template> <!-- match="map:redirect-to" -->
  -
  -  <xsl:template match="map:param">
  -    param.setParameter ("<xsl:value-of select="@name"/>", "<xsl:value-of select="@map:value"/>");
  -  </xsl:template> <!-- match="map:param" -->
  -
  -  <!-- Sitemap Utility templates --> 
  -
  -  <xsl:template name="config-components"> 
  -    <xsl:param name="name"/>  
  -    <xsl:param name="interface"/> 
  -    <xsl:param name="components"/>  
  - 
  -    <xsl:variable name="qname"> 
  -      <xsl:value-of select="concat($prefix, ':value')"/> 
  -    </xsl:variable> 
  -
  -    <xsl:variable name="ns" select="namespace-uri(.)"/> 
  -    <xsl:for-each select="$components"> 
  -      confBuilder.startDocument ();
  -      <xsl:call-template name="nested-config-components">
  -        <xsl:with-param name="name" select="$name"/>
  -        <xsl:with-param name="config-name"><xsl:value-of select="concat(local-name(.),'/',@name)"/></xsl:with-param>
  -        <xsl:with-param name="interface" select="$interface"/>
  -        <xsl:with-param name="components" select="*"/>
  -        <xsl:with-param name="type" select="@name"/>
  -        <xsl:with-param name="ns" select="$ns"/>
  -      </xsl:call-template>
  -      confBuilder.endDocument ();
  -      <xsl:value-of select="$name"/>_<xsl:value-of select="translate(@name, '- ', '__')"/> = 
  -        (<xsl:value-of select="$interface"/>)load_component ("<xsl:value-of select="@src"/>", 
  -            confBuilder.getConfiguration());
  -    </xsl:for-each> 
  -  </xsl:template> 
  -
  -  <xsl:template name="nested-config-components"> 
  -    <xsl:param name="name"/>  
  -    <xsl:param name="config-name"/>  
  -    <xsl:param name="interface"/> 
  -    <xsl:param name="components"/>  
  -    <xsl:param name="type"/>  
  -    <xsl:param name="ns"/>  
  -    <xsl:param name="subname"/>  
  - 
  -    <xsl:variable name="qname"> 
  -      <xsl:value-of select="concat($prefix, ':value')"/> 
  -    </xsl:variable> 
  -
  -    <!-- process content -->
  -    <xsl:for-each select="$components">
  -      <xsl:if test="$ns!=namespace-uri(.)">
  -        confBuilder.startPrefixMapping("","<xsl:value-of select="namespace-uri(.)"/>"); 
  -      </xsl:if>
  -      attr.clear();  
  -      <xsl:for-each select="attribute::*[name(.)!=$qname]">
  -        attr.addAttribute ("", "<xsl:value-of select="local-name(.)"/>", "<xsl:value-of select="name(.)"/>", "CDATA", "<xsl:value-of select="."/>"); 
  -      </xsl:for-each>
  -      confBuilder.startElement("<xsl:value-of select="namespace-uri(.)"/>", "<xsl:value-of select="local-name(.)"/>", "<xsl:value-of select="name(.)"/>", attr); 
  -      <xsl:for-each select="attribute::*[name(.)=$qname]">
  -        confBuilder.characters("<xsl:value-of select="."/>".toCharArray(), 0, <xsl:value-of select="string-length(.)"/>); 
  -      </xsl:for-each>
  -      <xsl:if test="normalize-space(text())">
  -        confBuilder.characters("<xsl:value-of select="text()"/>".toCharArray(), 0, <xsl:value-of select="string-length(text())"/>); 
  -      </xsl:if>
  -      <xsl:variable name="newsubname">
  -        <xsl:choose>
  -          <xsl:when test="not($subname)"><xsl:value-of select="position()"/></xsl:when>
  -          <xsl:otherwise><xsl:value-of select="concat($subname,position())"/></xsl:otherwise>
  -        </xsl:choose>
  -      </xsl:variable>
  -      <xsl:call-template name="nested-config-components"> 
  -        <xsl:with-param name="name"><xsl:value-of select="$name"/></xsl:with-param> 
  -        <xsl:with-param name="config-name"><xsl:value-of select="local-name(.)"/></xsl:with-param> 
  -        <xsl:with-param name="interface"><xsl:value-of select="$interface"/></xsl:with-param> 
  -        <xsl:with-param name="components" select="./*"/> 
  -        <xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param>
  -        <xsl:with-param name="ns"><xsl:value-of select="namespace-uri(.)"/></xsl:with-param>
  -        <xsl:with-param name="subname"><xsl:value-of select="$newsubname"/></xsl:with-param>
  -      </xsl:call-template> 
  -      confBuilder.endElement("<xsl:value-of select="namespace-uri(.)"/>", "<xsl:value-of select="local-name(.)"/>", "<xsl:value-of select="name(.)"/>"); 
  -      <xsl:if test="$ns!=namespace-uri(.)">
  -        confBuilder.endPrefixMapping(""); 
  -      </xsl:if>
  -    </xsl:for-each> 
  -  </xsl:template> 
  -
  -  <xsl:template name="setup-component">
  -    <xsl:param name="default-component"/>
  -    <xsl:param name="method"/>
  -    <xsl:param name="prefix"/>
  -    <xsl:variable name="component-type"> 
  -      <xsl:call-template name="get-parameter"> 
  -        <xsl:with-param name="parname">type</xsl:with-param> 
  -        <xsl:with-param name="default"><xsl:value-of select="$default-component"/></xsl:with-param> 
  -      </xsl:call-template> 
  -    </xsl:variable> 
  -    <xsl:variable name="component-source"> 
  -      <xsl:call-template name="get-parameter"> 
  -        <xsl:with-param name="parname">src</xsl:with-param> 
  -        <xsl:with-param name="default">null</xsl:with-param> 
  -      </xsl:call-template> 
  -    </xsl:variable> 
  -    <xsl:if test="descendant::map:param">
  -      param = new Parameters (); 
  -    </xsl:if>
  -    <xsl:variable name="component-param">
  -      <xsl:choose>
  -        <xsl:when test="descendant::map:param">
  -          param
  -        </xsl:when>
  -        <xsl:otherwise>
  -          emptyParam
  -        </xsl:otherwise>
  -      </xsl:choose>
  -    </xsl:variable>
  -    <xsl:apply-templates select="./map:param"/> 
  -    <xsl:choose> 
  -      <xsl:when test="$component-source='null'"> 
  -        pipeline.<xsl:value-of select="$method"/> (<xsl:value-of select="$prefix"/>_<xsl:value-of select="$component-type"/>, 
  -            null, <xsl:value-of select="$component-param"/>); 
  -      </xsl:when> 
  -      <xsl:otherwise> 
  -        pipeline.<xsl:value-of select="$method"/> (<xsl:value-of select="$prefix"/>_<xsl:value-of select="$component-type"/>,  
  -                               "<xsl:value-of select="$component-source"/>", <xsl:value-of select="$component-param"/>); 
  -      </xsl:otherwise> 
  -    </xsl:choose> 
  -  </xsl:template>
  -
  -  <!-- Utility templates -->
  -
  -  <xsl:template name="get-parameter">
  -    <xsl:param name="parname"/>
  -    <xsl:param name="default"/>
  -    <xsl:param name="required">false</xsl:param>
  -
  -    <xsl:variable name="qname">
  -      <xsl:value-of select="concat($prefix, ':param')"/>
  -    </xsl:variable>
  -
  -    <xsl:choose>
  -      <xsl:when test="@*[name(.) = $parname]"><xsl:value-of select="@*[name(.) = $parname]"/>	</xsl:when>
  -      <xsl:when test="(*[name(.) = $qname])[@name = $parname]">
  -        <xsl:call-template name="get-nested-content">
  -          <xsl:with-param name="content"
  -                          select="(*[name(.) = $qname])[@name = $parname]"/>
  -        </xsl:call-template>
  -      </xsl:when>
  -      <xsl:otherwise>
  -        <xsl:choose>
  -          <xsl:when test="string-length($default) = 0">
  -            <xsl:choose>
  -              <xsl:when test="$required = 'true'">
  -                <xsl:call-template name="error">
  -                  <xsl:with-param name="message">[Logicsheet processor]
  -Parameter '<xsl:value-of select="$parname"/>' missing in dynamic tag &lt;<xsl:value-of select="name(.)"/>&gt;
  -                  </xsl:with-param>
  -                </xsl:call-template>
  -              </xsl:when>
  -              <xsl:otherwise>""</xsl:otherwise>
  -            </xsl:choose>
  -          </xsl:when>
  -          <xsl:otherwise><xsl:copy-of select="$default"/></xsl:otherwise>
  -        </xsl:choose>
  -      </xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template name="get-nested-content">
  -    <xsl:param name="content"/>
  -    <xsl:choose>
  -      <xsl:when test="$content/*">
  -        <xsl:apply-templates select="$content/*"/>
  -      </xsl:when>
  -      <xsl:otherwise><xsl:value-of select="$content"/></xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template name="error">
  -    <xsl:param name="message"/>
  -    <xsl:message terminate="yes"><xsl:value-of select="$message"/></xsl:message>
  -  </xsl:template>
  -
  -  <!-- Ignored elements -->
  -  <xsl:template match="map:logicsheet|map:dependency|map:handle-errors"/>
  -
  -</xsl:stylesheet>
  +
  +    <xsl:for-each select="/map:sitemap/map:resources/map:resource">
  +      private boolean resource_<xsl:value-of select="translate(@name, '- ', '__')"/> (ResourcePipeline pipeline, 
  +          List listOfLists, Environment environment, OutputStream out) 
  +      throws SAXException, IOException, ProcessingException { 
  +        List list = null;
  +        Parameters param = null; 
  +        <xsl:apply-templates select="./*"/>
  +      }
  +    </xsl:for-each>
  + 
  +    /** 
  +     * Process to producing the output to the specified &gt;code&lt;OutputStream&gt;/code&lt;. 
  +     */ 
  +    public boolean process(Environment environment, OutputStream out)  
  +    throws SAXException, IOException, ProcessingException { 
  +      ResourcePipeline pipeline = new ResourcePipeline ();
  +      List listOfLists = (List)(new ArrayList());
  +      List list = null;
  +      Parameters param = null; 
  +      <xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline">
  +        try {
  +          <xsl:apply-templates select="./*"/>
  +        } catch (Exception e) {
  +          <xsl:choose>
  +            <xsl:when test="not (./map:handle-errors)">
  +             System.out.println (e.toString());
  +             e.printStackTrace(System.out);
  +            </xsl:when>
  +            <xsl:otherwise>
  +              pipeline.setGenerator (generator_error_handler, e.getMessage(), emptyParam);
  +              <xsl:apply-templates select="./map:handle-error/*"/>
  +              return pipeline.process (environment, out);
  +            </xsl:otherwise>
  +          </xsl:choose>
  +        }
  +      </xsl:for-each>
  +      return false;
  +    }
  +}
  +
  +  </xsl:template> <!-- match="map:sitemap" -->
  +
  +  <xsl:template match="map:match">
  +    <xsl:variable name="matcher-type">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="parname">type</xsl:with-param>
  +        <xsl:with-param name="default"><xsl:value-of select="/map:sitemap/map:components/map:matchers/@default"/></xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +    <xsl:variable name="pattern-value">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="parname">pattern</xsl:with-param>
  +        <xsl:with-param name="required">true</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +    <xsl:variable name="matcher-name1" select="translate(@pattern,'/- *?@:{}()[].#^\\$|&#33;','_')"/>
  +    <xsl:variable name="matcher-name2" select='translate($matcher-name1,"&#39;","")'/>
  +    <xsl:variable name="matcher-name">
  +      <xsl:for-each select="/map:sitemap/map:components/map:matchers/map:matcher[@name=$matcher-type]">
  +        <xsl:choose>
  +          <xsl:when test="(./@src)">
  +            matcher_<xsl:value-of select="translate($matcher-type, '- ', '__')"/>.match
  +          </xsl:when>
  +          <xsl:when test="(./@factory)">
  +            matcher_<xsl:value-of select="$matcher-name2"/>
  +          </xsl:when>
  +          <xsl:otherwise>
  +            <xsl:call-template name="error">
  +              <xsl:with-param name="message">cannot choose a matcher name <xsl:value-of select="$matcher-type"/></xsl:with-param>
  +            </xsl:call-template>
  +          </xsl:otherwise>
  +        </xsl:choose>
  +      </xsl:for-each>
  +    </xsl:variable>
  +    if ((list = <xsl:value-of select="$matcher-name"/> ("<xsl:value-of select="$pattern-value"/>", environment)) != null) {
  +       listOfLists.add (list);  
  +       <xsl:apply-templates/>
  +    }
  +  </xsl:template> <!-- match="map:match" -->
  +
  +  <xsl:template match="map:select">
  +    <xsl:variable name="selector-type">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="parname">type</xsl:with-param>
  +        <xsl:with-param name="default"><xsl:value-of select="/map:sitemap/map:components/map:selectors/@default"/></xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +    <xsl:for-each select="./map:when">
  +      <xsl:variable name="test-value">
  +        <xsl:call-template name="get-parameter">
  +          <xsl:with-param name="parname">test</xsl:with-param>
  +          <xsl:with-param name="required">true</xsl:with-param>
  +        </xsl:call-template>
  +      </xsl:variable>
  +      <xsl:variable name="selector-name1" select="translate($test-value,'/- *?@:{}()[].#^\\$|&#33;','_')"/>
  +      <xsl:variable name="selector-name2" select='translate($selector-name1,"&#39;","")'/>
  +      <xsl:variable name="selector-name">
  +        <xsl:for-each select="/map:sitemap/map:components/map:selectors/map:selector[@name=$selector-type]">
  +          <xsl:choose>
  +            <xsl:when test="(./@src)">
  +              selector_<xsl:value-of select="translate($selector-type, '- ', '__')"/>.select
  +            </xsl:when>
  +            <xsl:when test="(./@factory)">
  +              selector_<xsl:value-of select="$selector-name2"/>
  +            </xsl:when>
  +            <xsl:otherwise>
  +              <xsl:call-template name="error">
  +                <xsl:with-param name="message">cannot choose a selector name <xsl:value-of select="$selector-type"/></xsl:with-param>
  +              </xsl:call-template>
  +            </xsl:otherwise>
  +          </xsl:choose>
  +        </xsl:for-each>
  +      </xsl:variable>
  +      if (<xsl:value-of select="$selector-name"/> ("<xsl:value-of select="$test-value"/>", environment)) {
  +       <xsl:apply-templates/>
  +      }
  +    </xsl:for-each>
  +
  +    <xsl:for-each select="./map:otherwise">
  +      else {
  +      <xsl:apply-templates/>
  +      }
  +    </xsl:for-each>
  +  </xsl:template> <!-- match="/map:sitemap/map:select" -->
  +
  +  <xsl:template match="map:generate">
  +    <xsl:call-template name="setup-component">
  +      <xsl:with-param name="default-component" select="/map:sitemap/map:components/map:generators/@default"/>
  +      <xsl:with-param name="method">setGenerator</xsl:with-param>
  +      <xsl:with-param name="prefix">generator</xsl:with-param>
  +    </xsl:call-template>
  +  </xsl:template> <!-- match="map:generate" -->
  +
  +  <xsl:template match="map:transform">
  +    <xsl:call-template name="setup-component">
  +      <xsl:with-param name="default-component" select="/map:sitemap/map:components/map:transformers/@default"/>
  +      <xsl:with-param name="method">addTransformer</xsl:with-param>
  +      <xsl:with-param name="prefix">transformer</xsl:with-param>
  +    </xsl:call-template>
  +  </xsl:template> <!-- match="map:transormer" -->
  +
  +  <xsl:template match="map:serialize">
  +    <xsl:call-template name="setup-component">
  +      <xsl:with-param name="default-component" select="/map:sitemap/map:components/map:serializers/@default"/>
  +      <xsl:with-param name="method">setSerializer</xsl:with-param>
  +      <xsl:with-param name="prefix">serializer</xsl:with-param>
  +    </xsl:call-template> 
  +    return pipeline.process (environment, out);
  +  </xsl:template> <!-- match="map:serialize" --> 
  +
  +  <xsl:template match="map:read">
  +    <xsl:call-template name="setup-component">
  +      <xsl:with-param name="default-component" select="/map:sitemap/map:components/map:readers/@default"/>
  +      <xsl:with-param name="method">setReader</xsl:with-param>
  +      <xsl:with-param name="prefix">reader</xsl:with-param>
  +    </xsl:call-template> 
  +    return pipeline.process (environment, out);
  +  </xsl:template> <!-- match="map:read" --> 
  +
  +  <xsl:template match="map:mount">
  +    <xsl:variable name="src" select="@src"/>
  +    <xsl:variable name="pos"><xsl:value-of select="translate(./@uri-prefix, '- /{}', '___')"/></xsl:variable>
  +    <xsl:variable name="check-reload">
  +      <xsl:choose>
  +        <xsl:when test="@check-reload='yes'">true</xsl:when>
  +        <xsl:when test="@check-reload='true'">true</xsl:when>
  +        <xsl:when test="@check-reload='no'">false</xsl:when>
  +        <xsl:when test="@check-reload='false'">false</xsl:when>
  +        <xsl:when test="not(@check-reload)">true</xsl:when>
  +        <xsl:otherwise>
  +          <xsl:call-template name="error">
  +            <xsl:with-param name="message">
  +              element <xsl:value-of select="name(.)"/> with uri-prefix="<xsl:value-of select="@uri-prefix"/>" has a wrong value in 'check-reload' attribute . Use "yes" or "no" but not "<xsl:value-of select="@check-reload"/>".
  +            </xsl:with-param>
  +          </xsl:call-template>
  +        </xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +    return sitemapManager.invoke (environment, substitute(listOfLists,"<xsl:value-of select="@uri-prefix"/>"), makeAbsolute(substitute(listOfLists,"<xsl:value-of select="@src"/>")), <xsl:value-of select="$check-reload"/>, out);
  +  </xsl:template> <!-- match="map:mount" -->
  +
  +  <xsl:template match="map:redirect-to">
  +    <xsl:choose>
  +      <xsl:when test="@resource">
  +        return resource_<xsl:value-of select="translate(@resource, '- ', '__')"/>(pipeline, listOfLists, environment, out);
  +      </xsl:when>
  +      <xsl:when test="@uri">
  +        // request.setUri ("<xsl:value-of select="@uri"/>");
  +        // this.process(environment, out);
  +      </xsl:when>
  +      <xsl:otherwise>
  +        <xsl:call-template name="error">
  +          <xsl:with-param name="message">Missing attribute uri= or resource= to element redirect-to</xsl:with-param>
  +        </xsl:call-template>
  +      </xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template> <!-- match="map:redirect-to" -->
  +
  +  <xsl:template match="map:param">
  +    param.setParameter ("<xsl:value-of select="@name"/>", "<xsl:value-of select="@map:value"/>");
  +  </xsl:template> <!-- match="map:param" -->
  +
  +  <!-- Sitemap Utility templates --> 
  +
  +  <xsl:template name="config-components"> 
  +    <xsl:param name="name"/>  
  +    <xsl:param name="interface"/> 
  +    <xsl:param name="components"/>  
  + 
  +    <xsl:variable name="qname"> 
  +      <xsl:value-of select="concat($prefix, ':value')"/> 
  +    </xsl:variable> 
  +
  +    <xsl:variable name="ns" select="namespace-uri(.)"/> 
  +    <xsl:for-each select="$components"> 
  +      confBuilder.startDocument ();
  +      <xsl:call-template name="nested-config-components">
  +        <xsl:with-param name="name" select="$name"/>
  +        <xsl:with-param name="config-name"><xsl:value-of select="concat(local-name(.),'/',@name)"/></xsl:with-param>
  +        <xsl:with-param name="interface" select="$interface"/>
  +        <xsl:with-param name="components" select="*"/>
  +        <xsl:with-param name="type" select="@name"/>
  +        <xsl:with-param name="ns" select="$ns"/>
  +      </xsl:call-template>
  +      confBuilder.endDocument ();
  +      cconf = confBuilder.getConfiguration();
  +      <xsl:value-of select="$name"/>_<xsl:value-of select="translate(@name, '- ', '__')"/> = 
  +        (<xsl:value-of select="$interface"/>)load_component ("<xsl:value-of select="@src"/>", 
  +            cconf);
  +    </xsl:for-each> 
  +  </xsl:template> 
  +
  +  <xsl:template name="nested-config-components"> 
  +    <xsl:param name="name"/>  
  +    <xsl:param name="config-name"/>  
  +    <xsl:param name="interface"/> 
  +    <xsl:param name="components"/>  
  +    <xsl:param name="type"/>  
  +    <xsl:param name="ns"/>  
  +    <xsl:param name="subname"/>  
  + 
  +    <xsl:variable name="qname"> 
  +      <xsl:value-of select="concat($prefix, ':value')"/> 
  +    </xsl:variable> 
  +
  +    <!-- process content -->
  +    <xsl:for-each select="$components">
  +      <xsl:if test="$ns!=namespace-uri(.)">
  +        confBuilder.startPrefixMapping("","<xsl:value-of select="namespace-uri(.)"/>"); 
  +      </xsl:if>
  +      attr.clear();  
  +      <xsl:for-each select="attribute::*[name(.)!=$qname]">
  +        attr.addAttribute ("", "<xsl:value-of select="local-name(.)"/>", "<xsl:value-of select="name(.)"/>", "CDATA", "<xsl:value-of select="."/>"); 
  +      </xsl:for-each>
  +      confBuilder.startElement("<xsl:value-of select="namespace-uri(.)"/>", "<xsl:value-of select="local-name(.)"/>", "<xsl:value-of select="name(.)"/>", attr); 
  +      <xsl:for-each select="attribute::*[name(.)=$qname]">
  +        confBuilder.characters("<xsl:value-of select="."/>".toCharArray(), 0, <xsl:value-of select="string-length(.)"/>); 
  +      </xsl:for-each>
  +      <xsl:if test="normalize-space(text())">
  +        confBuilder.characters("<xsl:value-of select="text()"/>".toCharArray(), 0, <xsl:value-of select="string-length(text())"/>); 
  +      </xsl:if>
  +      <xsl:variable name="newsubname">
  +        <xsl:choose>
  +          <xsl:when test="not($subname)"><xsl:value-of select="position()"/></xsl:when>
  +          <xsl:otherwise><xsl:value-of select="concat($subname,position())"/></xsl:otherwise>
  +        </xsl:choose>
  +      </xsl:variable>
  +      <xsl:call-template name="nested-config-components"> 
  +        <xsl:with-param name="name"><xsl:value-of select="$name"/></xsl:with-param> 
  +        <xsl:with-param name="config-name"><xsl:value-of select="local-name(.)"/></xsl:with-param> 
  +        <xsl:with-param name="interface"><xsl:value-of select="$interface"/></xsl:with-param> 
  +        <xsl:with-param name="components" select="./*"/> 
  +        <xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param>
  +        <xsl:with-param name="ns"><xsl:value-of select="namespace-uri(.)"/></xsl:with-param>
  +        <xsl:with-param name="subname"><xsl:value-of select="$newsubname"/></xsl:with-param>
  +      </xsl:call-template> 
  +      confBuilder.endElement("<xsl:value-of select="namespace-uri(.)"/>", "<xsl:value-of select="local-name(.)"/>", "<xsl:value-of select="name(.)"/>"); 
  +      <xsl:if test="$ns!=namespace-uri(.)">
  +        confBuilder.endPrefixMapping(""); 
  +      </xsl:if>
  +    </xsl:for-each> 
  +  </xsl:template> 
  +
  +  <xsl:template name="setup-component">
  +    <xsl:param name="default-component"/>
  +    <xsl:param name="method"/>
  +    <xsl:param name="prefix"/>
  +    <xsl:variable name="component-type"> 
  +      <xsl:call-template name="get-parameter"> 
  +        <xsl:with-param name="parname">type</xsl:with-param> 
  +        <xsl:with-param name="default"><xsl:value-of select="$default-component"/></xsl:with-param> 
  +      </xsl:call-template> 
  +    </xsl:variable> 
  +    <xsl:variable name="component-source"> 
  +      <xsl:call-template name="get-parameter"> 
  +        <xsl:with-param name="parname">src</xsl:with-param> 
  +        <xsl:with-param name="default">null</xsl:with-param> 
  +      </xsl:call-template> 
  +    </xsl:variable> 
  +    <xsl:if test="descendant::map:param">
  +      param = new Parameters (); 
  +    </xsl:if>
  +    <xsl:variable name="component-param">
  +      <xsl:choose>
  +        <xsl:when test="descendant::map:param">
  +          param
  +        </xsl:when>
  +        <xsl:otherwise>
  +          emptyParam
  +        </xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +    <xsl:apply-templates select="./map:param"/> 
  +    <xsl:choose> 
  +      <xsl:when test="$component-source='null'"> 
  +        pipeline.<xsl:value-of select="$method"/> (<xsl:value-of select="$prefix"/>_<xsl:value-of select="$component-type"/>, 
  +            null, <xsl:value-of select="$component-param"/>); 
  +      </xsl:when> 
  +      <xsl:otherwise> 
  +        pipeline.<xsl:value-of select="$method"/> (<xsl:value-of select="$prefix"/>_<xsl:value-of select="$component-type"/>,  
  +            makeAbsolute(substitute(listOfLists,"<xsl:value-of select="$component-source"/>")), <xsl:value-of select="$component-param"/>); 
  +      </xsl:otherwise> 
  +    </xsl:choose> 
  +  </xsl:template>
  +
  +  <!-- Utility templates -->
  +
  +  <xsl:template name="get-parameter">
  +    <xsl:param name="parname"/>
  +    <xsl:param name="default"/>
  +    <xsl:param name="required">false</xsl:param>
  +
  +    <xsl:variable name="qname">
  +      <xsl:value-of select="concat($prefix, ':param')"/>
  +    </xsl:variable>
  +
  +    <xsl:choose>
  +      <xsl:when test="@*[name(.) = $parname]"><xsl:value-of select="@*[name(.) = $parname]"/>	</xsl:when>
  +      <xsl:when test="(*[name(.) = $qname])[@name = $parname]">
  +        <xsl:call-template name="get-nested-content">
  +          <xsl:with-param name="content"
  +                          select="(*[name(.) = $qname])[@name = $parname]"/>
  +        </xsl:call-template>
  +      </xsl:when>
  +      <xsl:otherwise>
  +        <xsl:choose>
  +          <xsl:when test="string-length($default) = 0">
  +            <xsl:choose>
  +              <xsl:when test="$required = 'true'">
  +                <xsl:call-template name="error">
  +                  <xsl:with-param name="message">[Logicsheet processor]
  +Parameter '<xsl:value-of select="$parname"/>' missing in dynamic tag &lt;<xsl:value-of select="name(.)"/>&gt;
  +                  </xsl:with-param>
  +                </xsl:call-template>
  +              </xsl:when>
  +              <xsl:otherwise>""</xsl:otherwise>
  +            </xsl:choose>
  +          </xsl:when>
  +          <xsl:otherwise><xsl:copy-of select="$default"/></xsl:otherwise>
  +        </xsl:choose>
  +      </xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template name="get-nested-content">
  +    <xsl:param name="content"/>
  +    <xsl:choose>
  +      <xsl:when test="$content/*">
  +        <xsl:apply-templates select="$content/*"/>
  +      </xsl:when>
  +      <xsl:otherwise><xsl:value-of select="$content"/></xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template name="error">
  +    <xsl:param name="message"/>
  +    <xsl:message terminate="yes"><xsl:value-of select="$message"/></xsl:message>
  +  </xsl:template>
  +
  +  <!-- Ignored elements -->
  +  <xsl:template match="map:logicsheet|map:dependency|map:handle-errors"/>
  +
  +</xsl:stylesheet>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +25 -25    xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/Constants.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Constants.java	2000/05/23 23:09:57	1.1.2.1
  +++ Constants.java	2000/07/22 20:41:36	1.1.2.2
  @@ -1,25 +1,25 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  -
  -/**
  - * Constants used by XSP classes
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:57 $
  - */
  -public interface Constants {
  -  public static final String XSP_PREFIX = "xsp";
  -  public static final String XSP_URI = "http://xml.apache.org/xsp";
  -
  -  public static final String XSP_REQUEST_PREFIX = "xsp-request";
  -  public static final String XSP_REQUEST_URI = XSP_URI + "/request";
  -
  -  public static final String XSP_RESPONSE_PREFIX = "xsp-response";
  -  public static final String XSP_RESPONSE_URI = XSP_URI + "/response";
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  +
  +/**
  + * Constants used by XSP classes
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:36 $
  + */
  +public interface Constants {
  +  public static final String XSP_PREFIX = "xsp";
  +  public static final String XSP_URI = "http://xml.apache.org/xsp";
  +
  +  public static final String XSP_REQUEST_PREFIX = "xsp-request";
  +  public static final String XSP_REQUEST_URI = XSP_URI + "/request";
  +
  +  public static final String XSP_RESPONSE_PREFIX = "xsp-response";
  +  public static final String XSP_RESPONSE_URI = XSP_URI + "/response";
  +}
  
  
  
  1.1.2.5   +40 -40    xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPGenerator.java
  
  Index: XSPGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPGenerator.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- XSPGenerator.java	2000/07/11 23:46:37	1.1.2.4
  +++ XSPGenerator.java	2000/07/22 20:41:36	1.1.2.5
  @@ -1,40 +1,40 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  -
  -import org.apache.cocoon.Cocoon;
  -import org.apache.avalon.ComponentManager;
  -import org.apache.cocoon.components.parser.Parser;
  -
  -import org.apache.cocoon.generation.AbstractServerPage;
  -
  -/**
  - * Base class for XSP-generated <code>ServerPagesGenerator</code> classes
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/11 23:46:37 $
  - */
  -public abstract class XSPGenerator extends AbstractServerPage {
  -  /** The XSP Object Model */
  -  protected Cocoon cocoon;
  -  protected Parser parser;
  -  // Request and Response are inherited from AbstractGenerator 
  -
  -  /**
  -   * Set the current <code>ComponentManager</code> instance used by this
  -   * <code>Generator</code> and initialize relevant instance variables.
  -   *
  -   * @param manager The global component manager
  -   */
  -  public void setComponentManager(ComponentManager manager) {
  -    super.setComponentManager(manager);
  -
  -    this.cocoon = (Cocoon) this.manager.getComponent("cocoon");
  -    this.parser = (Parser) this.manager.getComponent("parser");
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  +
  +import org.apache.cocoon.Cocoon;
  +import org.apache.avalon.ComponentManager;
  +import org.apache.cocoon.components.parser.Parser;
  +
  +import org.apache.cocoon.generation.AbstractServerPage;
  +
  +/**
  + * Base class for XSP-generated <code>ServerPagesGenerator</code> classes
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:36 $
  + */
  +public abstract class XSPGenerator extends AbstractServerPage {
  +  /** The XSP Object Model */
  +  protected Cocoon cocoon;
  +  protected Parser parser;
  +  // Request and Response are inherited from AbstractGenerator 
  +
  +  /**
  +   * Set the current <code>ComponentManager</code> instance used by this
  +   * <code>Generator</code> and initialize relevant instance variables.
  +   *
  +   * @param manager The global component manager
  +   */
  +  public void setComponentManager(ComponentManager manager) {
  +    super.setComponentManager(manager);
  +
  +    this.cocoon = (Cocoon) this.manager.getComponent("cocoon");
  +    this.parser = (Parser) this.manager.getComponent("parser");
  +  }
  +}
  
  
  
  1.1.2.2   +252 -252  xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPMarkupLanguage.java
  
  Index: XSPMarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPMarkupLanguage.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XSPMarkupLanguage.java	2000/05/23 23:09:58	1.1.2.1
  +++ XSPMarkupLanguage.java	2000/07/22 20:41:36	1.1.2.2
  @@ -1,252 +1,252 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  -
  -import java.io.File;
  -import java.util.Date;
  -import java.util.Vector;
  -import java.util.Hashtable;
  -
  -import org.w3c.dom.Node;
  -import org.w3c.dom.Text;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.ProcessingInstruction;
  -
  -import org.apache.cocoon.util.DOMUtils;
  -import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
  -
  -import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * This class implements <code>MarkupLanguage</code> for Cocoon's
  - * <a href="http://xml.apache.org/cocoon/xsp.html">XSP</a>.
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:58 $
  - */
  -public class XSPMarkupLanguage extends AbstractMarkupLanguage {
  -  /**
  -   * The default constructor.
  -   */
  -  public XSPMarkupLanguage() throws SAXException, IOException {
  -    super();
  -  }
  -
  -  /**
  -   * Return the XSP language name: <i>xsp</i> :-)
  -   *
  -   * @return The <i>xsp</i> constant
  -   */
  -  public String getName() {
  -    return "xsp";
  -  }
  -
  -  /**
  -   * Return the document-declared encoding or <code>null</code> if it's the
  -   * platform's default encoding
  -   *
  -   * @param document The input document
  -   * @return The document-declared encoding
  -   */
  -  public String getEncoding(Document document) {
  -    String encoding = document.getDocumentElement().getAttribute("encoding");
  -
  -    if (encoding.length() > 0) {
  -      return encoding;
  -    }
  -
  -    return null;
  -  }
  -
  -  /**
  -   * Prepare the document for logicsheet processing and code generation. This
  -   * method sets the base filename, file path and creation date as root element
  -   * attibutes and encodes text nodes as strings.
  -   *
  -   * @param document The input document
  -   * @param filename The input source filename
  -   * @param language The target programming language
  -   * @return The augmented document
  -   */
  -  protected Document preprocessDocument(
  -    Document document, String filename, ProgrammingLanguage language
  -  )
  -  {
  -    // Store path and file name
  -    int pos = filename.lastIndexOf(File.separatorChar);
  -    String name = filename.substring(pos + 1);
  -    String path = filename.substring(0, pos).replace(File.separatorChar, '/');
  -
  -    Element root = document.getDocumentElement();
  -
  -    root.setAttribute("file-name", name);
  -    root.setAttribute("file-path", path);
  -    root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
  -
  -    this.quoteStrings(document, language);
  -
  -    return document;
  -  }
  -
  -  /**
  -   * Encode text nodes as strings according to the target programming languages
  -   * string constant escaping rules.
  -   *
  -   * @param node The node to be escaped
  -   * @param language The target programming language
  -   */
  -  protected void quoteStrings(Node node, ProgrammingLanguage language) {
  -    switch (node.getNodeType()) {
  -      case Node.PROCESSING_INSTRUCTION_NODE:
  -        ProcessingInstruction pi = (ProcessingInstruction) node;
  -	if (!pi.getTarget().equals("xml-logicsheet")) {
  -          pi.setData(language.quoteString(pi.getData()));
  -	}
  -        break;
  -      case Node.TEXT_NODE:
  -        Element parent = (Element) node.getParentNode();
  -
  -        String tagName = parent.getTagName();
  -
  -        if (
  -          tagName.equals("xsp:expr") ||
  -          tagName.equals("xsp:logic") ||
  -          tagName.equals("xsp:structure") ||
  -          tagName.equals("xsp:include")
  -        ) {
  -          return;
  -        }
  -
  -        String value = language.quoteString(node.getNodeValue());
  -        Text textNode = node.getOwnerDocument().createTextNode(value);
  -
  -        Element textElement = node.getOwnerDocument().createElement("xsp:text");
  -
  -        textElement.appendChild(textNode);
  -        parent.replaceChild(textElement, node);
  -
  -        break;
  -      case Node.ELEMENT_NODE:
  -        ((Element) node).normalize();
  -        // Fall through
  -      default:
  -        NodeList childList = node.getChildNodes();
  -        int childCount = childList.getLength();
  -
  -        for (int i = 0; i < childCount; i++) {
  -          this.quoteStrings(childList.item(i), language);
  -        }
  -
  -        break;
  -    }
  -  }
  -
  -  /**
  -   * Returns a list of logicsheets to be applied to this document for source
  -   * code generation. This method scans the input document for
  -   * &lt;?xml-logicsheet?&gt; processing instructions and top-level
  -   * &lt;xsp:logicsheet&gt; elements. Logicsheet declarations are removed from
  -   * the input document.
  -   *
  -   * @param document The input document
  -   * @return An array of logicsheet <i>names</i>
  -   */
  -  protected String[] getLogicsheets(Document document) {
  -    Vector removedNodes = new Vector();
  -    Vector logicsheetList = new Vector();
  -    Element root = document.getDocumentElement();
  -
  -    // Retrieve logicsheets declared by processing-instruction
  -    NodeList nodeList = document.getChildNodes();
  -    int count = nodeList.getLength();
  -    for (int i = 0; i < count; i++) {
  -      Node node = nodeList.item(i);
  -      if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
  -	ProcessingInstruction pi = (ProcessingInstruction) node;
  -
  -	if (pi.getTarget().equals("xml-logicsheet")) {
  -          Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
  -	  logicsheetList.addElement(attrs.get("href"));
  -
  -	  removedNodes.addElement(pi);
  -	}
  -      }
  -    }
  -
  -    // Retrieve logicsheets declared by top-level elements
  -    nodeList = root.getElementsByTagName("xsp:logicsheet");
  -    count = nodeList.getLength();
  -
  -    for (int i = 0; i < count; i++) {
  -      Element logicsheetElement = (Element) nodeList.item(i);
  -      removedNodes.addElement(logicsheetElement);
  -      logicsheetList.addElement(logicsheetElement.getAttribute("location"));
  -    }
  -
  -    String[] logicsheetLocations = new String[logicsheetList.size()];
  -    logicsheetList.copyInto(logicsheetLocations);
  -
  -    // Remove logicsheet directives
  -    count = removedNodes.size();
  -    for (int i = 0; i < count; i++) {
  -      Node node = (Node) removedNodes.elementAt(i); 
  -      Node parent = node.getParentNode();
  -      parent.removeChild(node);
  -    }
  -
  -    return logicsheetLocations;
  -  }
  -
  -  /**
  -   * Add a dependency on an external file to the document for inclusion in
  -   * generated code. This is used by <code>AbstractServerPagesGenerator</code>
  -   * to populate a list of <code>File</code>'s tested for change on each
  -   * invocation; this information, in turn, is used by
  -   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  -   * necessary. XSP uses &lt;xsp:dependency&gt; elements for this purpose
  -   *
  -   * @param PARAM_NAME Param description
  -   * @return the value
  -   * @exception EXCEPTION_NAME If an error occurs
  -   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  -   *      and <code>ServerPagesLoaderImpl</code>
  -   */
  -  protected void addDependency(Document document, String location) {
  -    Element root = document.getDocumentElement();
  -    Element dependency = document.createElement("xsp:dependency");
  -    dependency.appendChild(document.createTextNode(location));
  -    root.appendChild(dependency);
  -  }
  -
  -  /**
  -   * Scan top-level document elements for non-xsp tag names returning the first
  -   * (and hopefully <i>only</i>) user-defined element
  -   *
  -   * @param document The input document
  -   * @return The first non-xsp element
  -   */
  -  protected Element getUserRoot(Document document) {
  -    Element root = document.getDocumentElement();
  -    NodeList elements = root.getElementsByTagName("*");
  -    int elementCount = elements.getLength();
  -    for (int i = 0; i < elementCount; i++) {
  -      Element userRoot = (Element) elements.item(i);
  -      if (!userRoot.getTagName().startsWith("xsp:")) {
  -        return userRoot;
  -      }
  -    }
  -
  -    return null;
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  +
  +import java.io.File;
  +import java.util.Date;
  +import java.util.Vector;
  +import java.util.Hashtable;
  +
  +import org.w3c.dom.Node;
  +import org.w3c.dom.Text;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.ProcessingInstruction;
  +
  +import org.apache.cocoon.util.DOMUtils;
  +import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
  +
  +import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  +
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * This class implements <code>MarkupLanguage</code> for Cocoon's
  + * <a href="http://xml.apache.org/cocoon/xsp.html">XSP</a>.
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:36 $
  + */
  +public class XSPMarkupLanguage extends AbstractMarkupLanguage {
  +  /**
  +   * The default constructor.
  +   */
  +  public XSPMarkupLanguage() throws SAXException, IOException {
  +    super();
  +  }
  +
  +  /**
  +   * Return the XSP language name: <i>xsp</i> :-)
  +   *
  +   * @return The <i>xsp</i> constant
  +   */
  +  public String getName() {
  +    return "xsp";
  +  }
  +
  +  /**
  +   * Return the document-declared encoding or <code>null</code> if it's the
  +   * platform's default encoding
  +   *
  +   * @param document The input document
  +   * @return The document-declared encoding
  +   */
  +  public String getEncoding(Document document) {
  +    String encoding = document.getDocumentElement().getAttribute("encoding");
  +
  +    if (encoding.length() > 0) {
  +      return encoding;
  +    }
  +
  +    return null;
  +  }
  +
  +  /**
  +   * Prepare the document for logicsheet processing and code generation. This
  +   * method sets the base filename, file path and creation date as root element
  +   * attibutes and encodes text nodes as strings.
  +   *
  +   * @param document The input document
  +   * @param filename The input source filename
  +   * @param language The target programming language
  +   * @return The augmented document
  +   */
  +  protected Document preprocessDocument(
  +    Document document, String filename, ProgrammingLanguage language
  +  )
  +  {
  +    // Store path and file name
  +    int pos = filename.lastIndexOf(File.separatorChar);
  +    String name = filename.substring(pos + 1);
  +    String path = filename.substring(0, pos).replace(File.separatorChar, '/');
  +
  +    Element root = document.getDocumentElement();
  +
  +    root.setAttribute("file-name", name);
  +    root.setAttribute("file-path", path);
  +    root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
  +
  +    this.quoteStrings(document, language);
  +
  +    return document;
  +  }
  +
  +  /**
  +   * Encode text nodes as strings according to the target programming languages
  +   * string constant escaping rules.
  +   *
  +   * @param node The node to be escaped
  +   * @param language The target programming language
  +   */
  +  protected void quoteStrings(Node node, ProgrammingLanguage language) {
  +    switch (node.getNodeType()) {
  +      case Node.PROCESSING_INSTRUCTION_NODE:
  +        ProcessingInstruction pi = (ProcessingInstruction) node;
  +	if (!pi.getTarget().equals("xml-logicsheet")) {
  +          pi.setData(language.quoteString(pi.getData()));
  +	}
  +        break;
  +      case Node.TEXT_NODE:
  +        Element parent = (Element) node.getParentNode();
  +
  +        String tagName = parent.getTagName();
  +
  +        if (
  +          tagName.equals("xsp:expr") ||
  +          tagName.equals("xsp:logic") ||
  +          tagName.equals("xsp:structure") ||
  +          tagName.equals("xsp:include")
  +        ) {
  +          return;
  +        }
  +
  +        String value = language.quoteString(node.getNodeValue());
  +        Text textNode = node.getOwnerDocument().createTextNode(value);
  +
  +        Element textElement = node.getOwnerDocument().createElement("xsp:text");
  +
  +        textElement.appendChild(textNode);
  +        parent.replaceChild(textElement, node);
  +
  +        break;
  +      case Node.ELEMENT_NODE:
  +        ((Element) node).normalize();
  +        // Fall through
  +      default:
  +        NodeList childList = node.getChildNodes();
  +        int childCount = childList.getLength();
  +
  +        for (int i = 0; i < childCount; i++) {
  +          this.quoteStrings(childList.item(i), language);
  +        }
  +
  +        break;
  +    }
  +  }
  +
  +  /**
  +   * Returns a list of logicsheets to be applied to this document for source
  +   * code generation. This method scans the input document for
  +   * &lt;?xml-logicsheet?&gt; processing instructions and top-level
  +   * &lt;xsp:logicsheet&gt; elements. Logicsheet declarations are removed from
  +   * the input document.
  +   *
  +   * @param document The input document
  +   * @return An array of logicsheet <i>names</i>
  +   */
  +  protected String[] getLogicsheets(Document document) {
  +    Vector removedNodes = new Vector();
  +    Vector logicsheetList = new Vector();
  +    Element root = document.getDocumentElement();
  +
  +    // Retrieve logicsheets declared by processing-instruction
  +    NodeList nodeList = document.getChildNodes();
  +    int count = nodeList.getLength();
  +    for (int i = 0; i < count; i++) {
  +      Node node = nodeList.item(i);
  +      if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
  +	ProcessingInstruction pi = (ProcessingInstruction) node;
  +
  +	if (pi.getTarget().equals("xml-logicsheet")) {
  +          Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
  +	  logicsheetList.addElement(attrs.get("href"));
  +
  +	  removedNodes.addElement(pi);
  +	}
  +      }
  +    }
  +
  +    // Retrieve logicsheets declared by top-level elements
  +    nodeList = root.getElementsByTagName("xsp:logicsheet");
  +    count = nodeList.getLength();
  +
  +    for (int i = 0; i < count; i++) {
  +      Element logicsheetElement = (Element) nodeList.item(i);
  +      removedNodes.addElement(logicsheetElement);
  +      logicsheetList.addElement(logicsheetElement.getAttribute("location"));
  +    }
  +
  +    String[] logicsheetLocations = new String[logicsheetList.size()];
  +    logicsheetList.copyInto(logicsheetLocations);
  +
  +    // Remove logicsheet directives
  +    count = removedNodes.size();
  +    for (int i = 0; i < count; i++) {
  +      Node node = (Node) removedNodes.elementAt(i); 
  +      Node parent = node.getParentNode();
  +      parent.removeChild(node);
  +    }
  +
  +    return logicsheetLocations;
  +  }
  +
  +  /**
  +   * Add a dependency on an external file to the document for inclusion in
  +   * generated code. This is used by <code>AbstractServerPagesGenerator</code>
  +   * to populate a list of <code>File</code>'s tested for change on each
  +   * invocation; this information, in turn, is used by
  +   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  +   * necessary. XSP uses &lt;xsp:dependency&gt; elements for this purpose
  +   *
  +   * @param PARAM_NAME Param description
  +   * @return the value
  +   * @exception EXCEPTION_NAME If an error occurs
  +   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  +   *      and <code>ServerPagesLoaderImpl</code>
  +   */
  +  protected void addDependency(Document document, String location) {
  +    Element root = document.getDocumentElement();
  +    Element dependency = document.createElement("xsp:dependency");
  +    dependency.appendChild(document.createTextNode(location));
  +    root.appendChild(dependency);
  +  }
  +
  +  /**
  +   * Scan top-level document elements for non-xsp tag names returning the first
  +   * (and hopefully <i>only</i>) user-defined element
  +   *
  +   * @param document The input document
  +   * @return The first non-xsp element
  +   */
  +  protected Element getUserRoot(Document document) {
  +    Element root = document.getDocumentElement();
  +    NodeList elements = root.getElementsByTagName("*");
  +    int elementCount = elements.getLength();
  +    for (int i = 0; i < elementCount; i++) {
  +      Element userRoot = (Element) elements.item(i);
  +      if (!userRoot.getTagName().startsWith("xsp:")) {
  +        return userRoot;
  +      }
  +    }
  +
  +    return null;
  +  }
  +}
  
  
  
  1.1.2.2   +154 -154  xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPObjectHelper.java
  
  Index: XSPObjectHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPObjectHelper.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XSPObjectHelper.java	2000/05/23 23:09:58	1.1.2.1
  +++ XSPObjectHelper.java	2000/07/22 20:41:36	1.1.2.2
  @@ -1,154 +1,154 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  -
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -import org.xml.sax.SAXException;
  -
  -/**
  - * Base class for XSP's object model manipulation logicsheets
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:58 $
  - */
  -public class XSPObjectHelper implements Constants {
  -  /**
  -   * Empty attributes used for contentHandler.startElement()
  -   */
  -  protected static final AttributesImpl emptyAttr = new AttributesImpl();
  -
  -  /**
  -   * Uri and prefix associated with object helper. Derived classes must assign
  -   * these variables to their proper values
  -   */
  -  protected static String URI;
  -  protected static String PREFIX;
  -
  -  /**
  -   * Output an element containing text only and no attributes
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   * @param data The data contained by the element
  -   */
  -  protected static void elementData(
  -    ContentHandler contentHandler,
  -    String name,
  -    String data
  -  )
  -    throws SAXException
  -  {
  -    start(contentHandler, name);
  -    data(contentHandler, data);
  -    end(contentHandler, name);
  -  }
  -
  -  /**
  -   * Output an element containing text only and attributes
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   * @param data The data contained by the element
  -   * @param attr The element attributes
  -   */
  -  protected static void elementData(
  -    ContentHandler contentHandler,
  -    String name,
  -    String data,
  -    AttributesImpl attr
  -  )
  -    throws SAXException
  -  {
  -    start(contentHandler, name, attr);
  -    data(contentHandler, data);
  -    end(contentHandler, name);
  -  }
  -
  -  /**
  -   * Start an element with the proper object's uri and prefix and no
  -   * attributes
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   */
  -  protected static void start(
  -    ContentHandler contentHandler,
  -    String name
  -  )
  -    throws SAXException
  -  {
  -    contentHandler.startElement(URI, name, PREFIX + ":" + name, emptyAttr);
  -  }
  -
  -  /**
  -   * Start an element with the proper object's uri and prefix and with
  -   * attributes
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   * @param attr The element attributes
  -   */
  -  protected static void start(
  -    ContentHandler contentHandler,
  -    String name,
  -    AttributesImpl attr
  -  )
  -    throws SAXException
  -  {
  -    contentHandler.startElement(URI, name, PREFIX + ":" + name, attr);
  -  }
  -
  -  /**
  -   * End an element with the proper object's uri and prefix
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   */
  -  protected static void end(
  -    ContentHandler contentHandler,
  -    String name
  -  )
  -    throws SAXException
  -  {
  -    contentHandler.endElement(URI, name, PREFIX + ":" + name);
  -  }
  -
  -  /**
  -   * Add an attribute
  -   *
  -   * @param attr The attribute list
  -   * @param name The attribute name
  -   * @param value The attribute value
  -   */
  -  protected static void addAttribute(
  -    AttributesImpl attr,
  -    String name,
  -    String value
  -  )
  -    throws SAXException
  -  {
  -    attr.addAttribute("", name, "", "CDATA", value);
  -  }
  -
  -  /**
  -   * Add string data
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param data The string data
  -   */
  -  protected static void data(
  -    ContentHandler contentHandler,
  -    String data
  -  )
  -    throws SAXException
  -  {
  -    contentHandler.characters(data.toCharArray(), 0, data.length());
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  +
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + * Base class for XSP's object model manipulation logicsheets
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:36 $
  + */
  +public class XSPObjectHelper implements Constants {
  +  /**
  +   * Empty attributes used for contentHandler.startElement()
  +   */
  +  protected static final AttributesImpl emptyAttr = new AttributesImpl();
  +
  +  /**
  +   * Uri and prefix associated with object helper. Derived classes must assign
  +   * these variables to their proper values
  +   */
  +  protected static String URI;
  +  protected static String PREFIX;
  +
  +  /**
  +   * Output an element containing text only and no attributes
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   * @param data The data contained by the element
  +   */
  +  protected static void elementData(
  +    ContentHandler contentHandler,
  +    String name,
  +    String data
  +  )
  +    throws SAXException
  +  {
  +    start(contentHandler, name);
  +    data(contentHandler, data);
  +    end(contentHandler, name);
  +  }
  +
  +  /**
  +   * Output an element containing text only and attributes
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   * @param data The data contained by the element
  +   * @param attr The element attributes
  +   */
  +  protected static void elementData(
  +    ContentHandler contentHandler,
  +    String name,
  +    String data,
  +    AttributesImpl attr
  +  )
  +    throws SAXException
  +  {
  +    start(contentHandler, name, attr);
  +    data(contentHandler, data);
  +    end(contentHandler, name);
  +  }
  +
  +  /**
  +   * Start an element with the proper object's uri and prefix and no
  +   * attributes
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   */
  +  protected static void start(
  +    ContentHandler contentHandler,
  +    String name
  +  )
  +    throws SAXException
  +  {
  +    contentHandler.startElement(URI, name, PREFIX + ":" + name, emptyAttr);
  +  }
  +
  +  /**
  +   * Start an element with the proper object's uri and prefix and with
  +   * attributes
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   * @param attr The element attributes
  +   */
  +  protected static void start(
  +    ContentHandler contentHandler,
  +    String name,
  +    AttributesImpl attr
  +  )
  +    throws SAXException
  +  {
  +    contentHandler.startElement(URI, name, PREFIX + ":" + name, attr);
  +  }
  +
  +  /**
  +   * End an element with the proper object's uri and prefix
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   */
  +  protected static void end(
  +    ContentHandler contentHandler,
  +    String name
  +  )
  +    throws SAXException
  +  {
  +    contentHandler.endElement(URI, name, PREFIX + ":" + name);
  +  }
  +
  +  /**
  +   * Add an attribute
  +   *
  +   * @param attr The attribute list
  +   * @param name The attribute name
  +   * @param value The attribute value
  +   */
  +  protected static void addAttribute(
  +    AttributesImpl attr,
  +    String name,
  +    String value
  +  )
  +    throws SAXException
  +  {
  +    attr.addAttribute("", name, "", "CDATA", value);
  +  }
  +
  +  /**
  +   * Add string data
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param data The string data
  +   */
  +  protected static void data(
  +    ContentHandler contentHandler,
  +    String data
  +  )
  +    throws SAXException
  +  {
  +    contentHandler.characters(data.toCharArray(), 0, data.length());
  +  }
  +}
  
  
  
  1.1.2.2   +222 -222  xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPRequestHelper.java
  
  Index: XSPRequestHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPRequestHelper.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XSPRequestHelper.java	2000/05/23 23:09:59	1.1.2.1
  +++ XSPRequestHelper.java	2000/07/22 20:41:37	1.1.2.2
  @@ -1,222 +1,222 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  -
  -import java.util.Enumeration;
  -
  -import org.apache.cocoon.Request;
  -
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -import org.xml.sax.SAXException;
  -
  -/**
  - * The XSP <code>Request</code> object helper
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:59 $
  - */
  -public class XSPRequestHelper extends XSPObjectHelper {
  -  /**
  -   * Assign values to the object's namespace uri and prefix
  -   */
  -  static {
  -    URI = XSP_REQUEST_URI;
  -    PREFIX = XSP_REQUEST_PREFIX;
  -  }
  -
  -  /**
  -   * Output the uri associated with the given <code>Request</code>
  -   *
  -   * @param request The Cocoon request
  -   * @param contentHandler The SAX content handler
  -   * @exception SAXException If a SAX error occurs
  -   */
  -  public static void getUri(
  -    Request request,
  -    ContentHandler contentHandler
  -  )
  -    throws SAXException
  -  {
  -    elementData(contentHandler, "uri", request.getUri());
  -  }
  -
  -  /**
  -   * Return the given request parameter value or a user-provided default if
  -   * none was specified.
  -   *
  -   * @param request The Cocoon request
  -   * @param name The parameter name
  -   * @param defaultValue Value to substitute in absence of a parameter value
  -   */
  -  public static String getParameter(
  -    Request request,
  -    String name,
  -    String defaultValue
  -  ) {
  -    String value = request.getParameter(name);
  -
  -    if (value == null) {
  -      value = defaultValue;
  -    }
  -
  -    return value;
  -  }
  -
  -  /**
  -   * Output the given request parameter value or a user-provided default if
  -   * none was specified.
  -   *
  -   * @param request The Cocoon request
  -   * @param contentHandler The SAX content handler
  -   * @param name The parameter name
  -   * @param defaultValue Value to substitute in absence of a parameter value
  -   * @exception SAXException If a SAX error occurs
  -   */
  -  public static void getParameter(
  -    Request request,
  -    ContentHandler contentHandler,
  -    String name,
  -    String defaultValue
  -  )
  -    throws SAXException
  -  {
  -    AttributesImpl attr = new AttributesImpl();
  -    addAttribute(attr, "name", name);
  -
  -    elementData(
  -      contentHandler,
  -      "parameter",
  -      getParameter(request, name, defaultValue),
  -      attr
  -    );
  -  }
  -
  -  /**
  -   * Output the request parameter values for a given name
  -   *
  -   * @param request The Cocoon request
  -   * @param contentHandler The SAX content handler
  -   * @exception SAXException If a SAX error occurs
  -   */
  -  public static void getParameterValues(
  -    Request request,
  -    ContentHandler contentHandler,
  -    String name
  -  )
  -    throws SAXException
  -  {
  -    AttributesImpl attr = new AttributesImpl();
  -    addAttribute(attr, "name", name);
  -
  -    start(contentHandler, "parameter-values", attr);
  -
  -    String[] values = request.getParameterValues(name);
  -
  -    if (values != null) {
  -      for (int i = 0; i < values.length; i++) {
  -        elementData(contentHandler, "value", values[i]);
  -      }
  -    }
  -
  -    end(contentHandler, "parameter-values");
  -  }
  -
  -  /**
  -   * Output parameter names for a given request
  -   *
  -   * @param request The Cocoon request
  -   * @param contentHandler The SAX content handler
  -   * @exception SAXException If a SAX error occurs
  -   */
  -  public static void getParameterNames(
  -    Request request,
  -    ContentHandler contentHandler
  -  )
  -    throws SAXException
  -  {
  -    start(contentHandler, "parameter-names");
  -
  -    Enumeration e = request.getParameterNames();
  -    while (e.hasMoreElements()) {
  -      String name = (String) e.nextElement();
  -      elementData(contentHandler, "name", name);
  -    }
  -
  -    end(contentHandler, "parameter-names");
  -  }
  -
  -  /**
  -   * Return the request header value for a given name
  -   *
  -   * @param request The Cocoon request
  -   * @param name The parameter name
  -   */
  -  public static String getHeader(
  -    Request request,
  -    String name
  -  ) {
  -    return request.getHeader(name);
  -  }
  -
  -  /**
  -   * Output the request header value for a given name
  -   *
  -   * @param request The Cocoon request
  -   * @param contentHandler The SAX content handler
  -   * @param name The parameter name
  -   * @exception SAXException If a SAX error occurs
  -   */
  -  public static void getHeader(
  -    Request request,
  -    ContentHandler contentHandler,
  -    String name
  -  )
  -    throws SAXException
  -  {
  -    AttributesImpl attr = new AttributesImpl();
  -    addAttribute(attr, "name", name);
  -
  -    String value = getHeader(request, name);
  -    if (value == null) {
  -      value = "";
  -    }
  -
  -    elementData(
  -      contentHandler,
  -      "header",
  -      value,
  -      attr
  -    );
  -  }
  -
  -  /**
  -   * Output the header names for a given request
  -   *
  -   * @param request The Cocoon request
  -   * @param contentHandler The SAX content handler
  -   * @exception SAXException If a SAX error occurs
  -   */
  -  public static void getHeaderNames(
  -    Request request,
  -    ContentHandler contentHandler
  -  )
  -    throws SAXException
  -  {
  -    start(contentHandler, "header-names");
  -
  -    Enumeration e = request.getHeaderNames();
  -    while (e.hasMoreElements()) {
  -      String name = (String) e.nextElement();
  -      elementData(contentHandler, "name", name);
  -    }
  -
  -    end(contentHandler, "header-names");
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  +
  +import java.util.Enumeration;
  +
  +import org.apache.cocoon.Request;
  +
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + * The XSP <code>Request</code> object helper
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:37 $
  + */
  +public class XSPRequestHelper extends XSPObjectHelper {
  +  /**
  +   * Assign values to the object's namespace uri and prefix
  +   */
  +  static {
  +    URI = XSP_REQUEST_URI;
  +    PREFIX = XSP_REQUEST_PREFIX;
  +  }
  +
  +  /**
  +   * Output the uri associated with the given <code>Request</code>
  +   *
  +   * @param request The Cocoon request
  +   * @param contentHandler The SAX content handler
  +   * @exception SAXException If a SAX error occurs
  +   */
  +  public static void getUri(
  +    Request request,
  +    ContentHandler contentHandler
  +  )
  +    throws SAXException
  +  {
  +    elementData(contentHandler, "uri", request.getUri());
  +  }
  +
  +  /**
  +   * Return the given request parameter value or a user-provided default if
  +   * none was specified.
  +   *
  +   * @param request The Cocoon request
  +   * @param name The parameter name
  +   * @param defaultValue Value to substitute in absence of a parameter value
  +   */
  +  public static String getParameter(
  +    Request request,
  +    String name,
  +    String defaultValue
  +  ) {
  +    String value = request.getParameter(name);
  +
  +    if (value == null) {
  +      value = defaultValue;
  +    }
  +
  +    return value;
  +  }
  +
  +  /**
  +   * Output the given request parameter value or a user-provided default if
  +   * none was specified.
  +   *
  +   * @param request The Cocoon request
  +   * @param contentHandler The SAX content handler
  +   * @param name The parameter name
  +   * @param defaultValue Value to substitute in absence of a parameter value
  +   * @exception SAXException If a SAX error occurs
  +   */
  +  public static void getParameter(
  +    Request request,
  +    ContentHandler contentHandler,
  +    String name,
  +    String defaultValue
  +  )
  +    throws SAXException
  +  {
  +    AttributesImpl attr = new AttributesImpl();
  +    addAttribute(attr, "name", name);
  +
  +    elementData(
  +      contentHandler,
  +      "parameter",
  +      getParameter(request, name, defaultValue),
  +      attr
  +    );
  +  }
  +
  +  /**
  +   * Output the request parameter values for a given name
  +   *
  +   * @param request The Cocoon request
  +   * @param contentHandler The SAX content handler
  +   * @exception SAXException If a SAX error occurs
  +   */
  +  public static void getParameterValues(
  +    Request request,
  +    ContentHandler contentHandler,
  +    String name
  +  )
  +    throws SAXException
  +  {
  +    AttributesImpl attr = new AttributesImpl();
  +    addAttribute(attr, "name", name);
  +
  +    start(contentHandler, "parameter-values", attr);
  +
  +    String[] values = request.getParameterValues(name);
  +
  +    if (values != null) {
  +      for (int i = 0; i < values.length; i++) {
  +        elementData(contentHandler, "value", values[i]);
  +      }
  +    }
  +
  +    end(contentHandler, "parameter-values");
  +  }
  +
  +  /**
  +   * Output parameter names for a given request
  +   *
  +   * @param request The Cocoon request
  +   * @param contentHandler The SAX content handler
  +   * @exception SAXException If a SAX error occurs
  +   */
  +  public static void getParameterNames(
  +    Request request,
  +    ContentHandler contentHandler
  +  )
  +    throws SAXException
  +  {
  +    start(contentHandler, "parameter-names");
  +
  +    Enumeration e = request.getParameterNames();
  +    while (e.hasMoreElements()) {
  +      String name = (String) e.nextElement();
  +      elementData(contentHandler, "name", name);
  +    }
  +
  +    end(contentHandler, "parameter-names");
  +  }
  +
  +  /**
  +   * Return the request header value for a given name
  +   *
  +   * @param request The Cocoon request
  +   * @param name The parameter name
  +   */
  +  public static String getHeader(
  +    Request request,
  +    String name
  +  ) {
  +    return request.getHeader(name);
  +  }
  +
  +  /**
  +   * Output the request header value for a given name
  +   *
  +   * @param request The Cocoon request
  +   * @param contentHandler The SAX content handler
  +   * @param name The parameter name
  +   * @exception SAXException If a SAX error occurs
  +   */
  +  public static void getHeader(
  +    Request request,
  +    ContentHandler contentHandler,
  +    String name
  +  )
  +    throws SAXException
  +  {
  +    AttributesImpl attr = new AttributesImpl();
  +    addAttribute(attr, "name", name);
  +
  +    String value = getHeader(request, name);
  +    if (value == null) {
  +      value = "";
  +    }
  +
  +    elementData(
  +      contentHandler,
  +      "header",
  +      value,
  +      attr
  +    );
  +  }
  +
  +  /**
  +   * Output the header names for a given request
  +   *
  +   * @param request The Cocoon request
  +   * @param contentHandler The SAX content handler
  +   * @exception SAXException If a SAX error occurs
  +   */
  +  public static void getHeaderNames(
  +    Request request,
  +    ContentHandler contentHandler
  +  )
  +    throws SAXException
  +  {
  +    start(contentHandler, "header-names");
  +
  +    Enumeration e = request.getHeaderNames();
  +    while (e.hasMoreElements()) {
  +      String name = (String) e.nextElement();
  +      elementData(contentHandler, "name", name);
  +    }
  +
  +    end(contentHandler, "header-names");
  +  }
  +}
  
  
  
  1.1.2.2   +54 -54    xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPResponseHelper.java
  
  Index: XSPResponseHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPResponseHelper.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XSPResponseHelper.java	2000/05/23 23:09:59	1.1.2.1
  +++ XSPResponseHelper.java	2000/07/22 20:41:37	1.1.2.2
  @@ -1,54 +1,54 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  -
  -import java.util.Enumeration;
  -
  -import org.apache.cocoon.Response;
  -
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -import org.xml.sax.SAXException;
  -
  -/**
  - * The XSP <code>Response</code> object helper
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:09:59 $
  - */
  -public class XSPResponseHelper extends XSPObjectHelper {
  -  /**
  -   * Assign values to the object's namespace uri and prefix
  -   */
  -  static {
  -    URI = XSP_RESPONSE_URI;
  -    PREFIX = XSP_RESPONSE_PREFIX;
  -  }
  -
  -  /**
  -   * Set the content header for a given response
  -   *
  -   * @param response The Cocoon <code>Response</code>
  -   * @param name The header name
  -   * @param value The header value
  -   */
  -  public static void setHeader(Response response, String name, String value) {
  -    response.setHeader(name, value);
  -  }
  -
  -  /**
  -   * Set the content type for a given response
  -   *
  -   * @param response The Cocoon <code>Response</code>
  -   * @param type The content type
  -   */
  -  public static void setContentType(Response response, String type) {
  -    response.setContentType(type);
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.markup.xsp;
  +
  +import java.util.Enumeration;
  +
  +import org.apache.cocoon.Response;
  +
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + * The XSP <code>Response</code> object helper
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:37 $
  + */
  +public class XSPResponseHelper extends XSPObjectHelper {
  +  /**
  +   * Assign values to the object's namespace uri and prefix
  +   */
  +  static {
  +    URI = XSP_RESPONSE_URI;
  +    PREFIX = XSP_RESPONSE_PREFIX;
  +  }
  +
  +  /**
  +   * Set the content header for a given response
  +   *
  +   * @param response The Cocoon <code>Response</code>
  +   * @param name The header name
  +   * @param value The header value
  +   */
  +  public static void setHeader(Response response, String name, String value) {
  +    response.setHeader(name, value);
  +  }
  +
  +  /**
  +   * Set the content type for a given response
  +   *
  +   * @param response The Cocoon <code>Response</code>
  +   * @param type The content type
  +   */
  +  public static void setContentType(Response response, String type) {
  +    response.setContentType(type);
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +162 -162  xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/request.xsl
  
  Index: request.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/request.xsl,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- request.xsl	2000/05/23 23:10:00	1.1.2.1
  +++ request.xsl	2000/07/22 20:41:38	1.1.2.2
  @@ -1,162 +1,162 @@
  -<?xml version="1.0"?>
  -<!--
  - *****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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.                                                         *
  - ***************************************************************************** 
  --->
  -
  -<!-- XSP Response logicsheet for the Java language -->
  -<xsl:stylesheet
  -  version="1.0"
  -  xmlns:xsp="http://xml.apache.org/xsp"
  -  xmlns:xsp-request="http://xml.apache.org/xsp/request"
  -
  -  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  ->
  -  <xsl:template match="xsp-request:get-uri">
  -    <xsl:variable name="as">
  -      <xsl:call-template name="value-for-as">
  -        <xsl:with-param name="default" select="'string'"/>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:choose>
  -      <xsl:when test="$as = 'string'">
  -        <xsp:expr>
  -          (this.request.getUri())
  -        </xsp:expr>
  -      </xsl:when>
  -      <xsl:when test="$as = 'xml'">
  -	<!-- <xsp-request:uri> -->
  -        <xsp:logic>
  -          XSPRequestHelper.getUri(this.request, this.contentHandler);
  -        </xsp:logic>
  -      </xsl:when>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp-request:get-parameter">
  -    <xsl:variable name="name">
  -      <xsl:call-template name="value-for-name"/>
  -    </xsl:variable>
  -
  -    <xsl:variable name="default">
  -      <xsl:choose>
  -        <xsl:when test="@default">"<xsl:value-of select="@default"/>"</xsl:when>
  -        <xsl:when test="default">
  -          <xsl:call-template name="get-nested-content">
  -            <xsl:with-param name="content" select="xsp-request:default"/>
  -          </xsl:call-template>
  -        </xsl:when>
  -        <xsl:otherwise>null</xsl:otherwise>
  -      </xsl:choose>
  -    </xsl:variable>
  -
  -    <xsl:variable name="as">
  -      <xsl:call-template name="value-for-as">
  -        <xsl:with-param name="default" select="'string'"/>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:choose>
  -      <xsl:when test="$as = 'string'">
  -        <xsp:expr>
  -          (XSPRequestHelper.getParameter(this.request, <xsl:copy-of select="$name"/>, <xsl:copy-of select="$default"/>))
  -        </xsp:expr>
  -      </xsl:when>
  -      <xsl:when test="$as = 'xml'">
  -	<!-- <xsp-request:uri> -->
  -        <xsp:logic>
  -          XSPRequestHelper.getParameter(this.request, this.contentHandler, <xsl:copy-of select="$name"/>, <xsl:copy-of select="$default"/>);
  -        </xsp:logic>
  -      </xsl:when>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp-request:get-parameter-values">
  -    <xsl:variable name="name">
  -      <xsl:call-template name="value-for-name"/>
  -    </xsl:variable>
  -
  -     <xsp:logic>
  -        XSPRequestHelper.getParameterValues(this.request, this.contentHandler, <xsl:copy-of select="$name"/>);
  -     </xsp:logic>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp-request:get-parameter-names">
  -     <xsp:logic>
  -        XSPRequestHelper.getParameterNames(this.request, this.contentHandler);
  -     </xsp:logic>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp-request:get-header">
  -    <xsl:variable name="name">
  -      <xsl:call-template name="value-for-name"/>
  -    </xsl:variable>
  -
  -    <xsl:variable name="as">
  -      <xsl:call-template name="value-for-as">
  -        <xsl:with-param name="default" select="'string'"/>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:choose>
  -      <xsl:when test="$as = 'string'">
  -        <xsp:expr>
  -          (XSPRequestHelper.getHeader(this.request, <xsl:copy-of select="$name"/>))
  -        </xsp:expr>
  -      </xsl:when>
  -      <xsl:when test="$as = 'xml'">
  -	<!-- <xsp-request:uri> -->
  -        <xsp:logic>
  -          XSPRequestHelper.getHeader(this.request, this.contentHandler, <xsl:copy-of select="$name"/>);
  -        </xsp:logic>
  -      </xsl:when>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp-request:get-header-names">
  -     <xsp:logic>
  -        XSPRequestHelper.getHeaderNames(this.request, this.contentHandler);
  -     </xsp:logic>
  -  </xsl:template>
  -
  -  <xsl:template name="value-for-as">
  -    <xsl:param name="default"/>
  -    <xsl:choose>
  -      <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
  -      <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template name="value-for-name">
  -    <xsl:choose>
  -      <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
  -      <xsl:when test="name">
  -        <xsl:call-template name="get-nested-content">
  -          <xsl:with-param name="content" select="xsp-request:name"/>
  -        </xsl:call-template>
  -      </xsl:when>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template name="get-nested-content">
  -    <xsl:param name="content"/>
  -    <xsl:choose>
  -      <xsl:when test="$content/*">
  -        <xsl:apply-templates select="$content/*"/>
  -      </xsl:when>
  -      <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  - 
  -  <xsl:template match="@*|*|text()|processing-instruction()">
  -    <xsl:copy>
  -      <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
  -    </xsl:copy>
  -  </xsl:template>
  -</xsl:stylesheet>
  +<?xml version="1.0"?>
  +<!--
  + *****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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.                                                         *
  + ***************************************************************************** 
  +-->
  +
  +<!-- XSP Response logicsheet for the Java language -->
  +<xsl:stylesheet
  +  version="1.0"
  +  xmlns:xsp="http://xml.apache.org/xsp"
  +  xmlns:xsp-request="http://xml.apache.org/xsp/request"
  +
  +  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  +>
  +  <xsl:template match="xsp-request:get-uri">
  +    <xsl:variable name="as">
  +      <xsl:call-template name="value-for-as">
  +        <xsl:with-param name="default" select="'string'"/>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:choose>
  +      <xsl:when test="$as = 'string'">
  +        <xsp:expr>
  +          (this.request.getUri())
  +        </xsp:expr>
  +      </xsl:when>
  +      <xsl:when test="$as = 'xml'">
  +	<!-- <xsp-request:uri> -->
  +        <xsp:logic>
  +          XSPRequestHelper.getUri(this.request, this.contentHandler);
  +        </xsp:logic>
  +      </xsl:when>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp-request:get-parameter">
  +    <xsl:variable name="name">
  +      <xsl:call-template name="value-for-name"/>
  +    </xsl:variable>
  +
  +    <xsl:variable name="default">
  +      <xsl:choose>
  +        <xsl:when test="@default">"<xsl:value-of select="@default"/>"</xsl:when>
  +        <xsl:when test="default">
  +          <xsl:call-template name="get-nested-content">
  +            <xsl:with-param name="content" select="xsp-request:default"/>
  +          </xsl:call-template>
  +        </xsl:when>
  +        <xsl:otherwise>null</xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +
  +    <xsl:variable name="as">
  +      <xsl:call-template name="value-for-as">
  +        <xsl:with-param name="default" select="'string'"/>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:choose>
  +      <xsl:when test="$as = 'string'">
  +        <xsp:expr>
  +          (XSPRequestHelper.getParameter(this.request, <xsl:copy-of select="$name"/>, <xsl:copy-of select="$default"/>))
  +        </xsp:expr>
  +      </xsl:when>
  +      <xsl:when test="$as = 'xml'">
  +	<!-- <xsp-request:uri> -->
  +        <xsp:logic>
  +          XSPRequestHelper.getParameter(this.request, this.contentHandler, <xsl:copy-of select="$name"/>, <xsl:copy-of select="$default"/>);
  +        </xsp:logic>
  +      </xsl:when>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp-request:get-parameter-values">
  +    <xsl:variable name="name">
  +      <xsl:call-template name="value-for-name"/>
  +    </xsl:variable>
  +
  +     <xsp:logic>
  +        XSPRequestHelper.getParameterValues(this.request, this.contentHandler, <xsl:copy-of select="$name"/>);
  +     </xsp:logic>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp-request:get-parameter-names">
  +     <xsp:logic>
  +        XSPRequestHelper.getParameterNames(this.request, this.contentHandler);
  +     </xsp:logic>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp-request:get-header">
  +    <xsl:variable name="name">
  +      <xsl:call-template name="value-for-name"/>
  +    </xsl:variable>
  +
  +    <xsl:variable name="as">
  +      <xsl:call-template name="value-for-as">
  +        <xsl:with-param name="default" select="'string'"/>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:choose>
  +      <xsl:when test="$as = 'string'">
  +        <xsp:expr>
  +          (XSPRequestHelper.getHeader(this.request, <xsl:copy-of select="$name"/>))
  +        </xsp:expr>
  +      </xsl:when>
  +      <xsl:when test="$as = 'xml'">
  +	<!-- <xsp-request:uri> -->
  +        <xsp:logic>
  +          XSPRequestHelper.getHeader(this.request, this.contentHandler, <xsl:copy-of select="$name"/>);
  +        </xsp:logic>
  +      </xsl:when>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp-request:get-header-names">
  +     <xsp:logic>
  +        XSPRequestHelper.getHeaderNames(this.request, this.contentHandler);
  +     </xsp:logic>
  +  </xsl:template>
  +
  +  <xsl:template name="value-for-as">
  +    <xsl:param name="default"/>
  +    <xsl:choose>
  +      <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
  +      <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template name="value-for-name">
  +    <xsl:choose>
  +      <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
  +      <xsl:when test="name">
  +        <xsl:call-template name="get-nested-content">
  +          <xsl:with-param name="content" select="xsp-request:name"/>
  +        </xsl:call-template>
  +      </xsl:when>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template name="get-nested-content">
  +    <xsl:param name="content"/>
  +    <xsl:choose>
  +      <xsl:when test="$content/*">
  +        <xsl:apply-templates select="$content/*"/>
  +      </xsl:when>
  +      <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  + 
  +  <xsl:template match="@*|*|text()|processing-instruction()">
  +    <xsl:copy>
  +      <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
  +    </xsl:copy>
  +  </xsl:template>
  +</xsl:stylesheet>
  
  
  
  1.1.2.2   +81 -81    xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/response.xsl
  
  Index: response.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/response.xsl,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- response.xsl	2000/05/23 23:10:00	1.1.2.1
  +++ response.xsl	2000/07/22 20:41:38	1.1.2.2
  @@ -1,81 +1,81 @@
  -<?xml version="1.0"?>
  -<!--
  - *****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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.                                                         *
  - ***************************************************************************** 
  --->
  -
  -<!-- XSP Response logicsheet for the Java language -->
  -<xsl:stylesheet
  -  version="1.0"
  -  xmlns:xsp="http://xml.apache.org/xsp"
  -  xmlns:xsp-response="http://xml.apache.org/xsp/response"
  -
  -  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  ->
  -  <xsl:template match="xsp-response:set-header">
  -    <xsl:variable name="name">
  -      <xsl:choose>
  -        <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
  -        <xsl:when test="name">
  -          <xsl:call-template name="get-nested-content">
  -            <xsl:with-param name="content" select="xsp-response:name"/>
  -          </xsl:call-template>
  -        </xsl:when>
  -      </xsl:choose>
  -    </xsl:variable>
  -
  -    <xsl:variable name="value">
  -      <xsl:choose>
  -        <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
  -        <xsl:when test="value">
  -          <xsl:call-template name="get-nested-content">
  -            <xsl:with-param name="content" select="xsp-response:value"/>
  -          </xsl:call-template>
  -        </xsl:when>
  -        <xsl:otherwise>""</xsl:otherwise>
  -      </xsl:choose>
  -    </xsl:variable>
  -
  -    <xsp:logic>
  -      XSPResponseHelper.setHeader(this.response, <xsl:value-of select="$name"/>, <xsl:value-of select="$value"/>);
  -    </xsp:logic>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp-response:set-content-type">
  -    <xsl:variable name="type">
  -      <xsl:choose>
  -        <xsl:when test="@type">"<xsl:value-of select="@type"/>"</xsl:when>
  -        <xsl:when test="type">
  -          <xsl:call-template name="get-nested-content">
  -            <xsl:with-param name="content" select="xsp-response:type"/>
  -          </xsl:call-template>
  -        </xsl:when>
  -      </xsl:choose>
  -    </xsl:variable>
  -
  -    <xsp:logic>
  -      XSPResponseHelper.setContentType(this.response, <xsl:value-of select="$type"/>);
  -    </xsp:logic>
  -  </xsl:template>
  -
  -  <xsl:template name="get-nested-content">
  -    <xsl:param name="content"/>
  -    <xsl:choose>
  -      <xsl:when test="$content/*">
  -        <xsl:apply-templates select="$content/*"/>
  -      </xsl:when>
  -      <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  - 
  -  <xsl:template match="@*|*|text()|processing-instruction()">
  -    <xsl:copy>
  -      <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
  -    </xsl:copy>
  -  </xsl:template>
  -</xsl:stylesheet>
  +<?xml version="1.0"?>
  +<!--
  + *****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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.                                                         *
  + ***************************************************************************** 
  +-->
  +
  +<!-- XSP Response logicsheet for the Java language -->
  +<xsl:stylesheet
  +  version="1.0"
  +  xmlns:xsp="http://xml.apache.org/xsp"
  +  xmlns:xsp-response="http://xml.apache.org/xsp/response"
  +
  +  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  +>
  +  <xsl:template match="xsp-response:set-header">
  +    <xsl:variable name="name">
  +      <xsl:choose>
  +        <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
  +        <xsl:when test="name">
  +          <xsl:call-template name="get-nested-content">
  +            <xsl:with-param name="content" select="xsp-response:name"/>
  +          </xsl:call-template>
  +        </xsl:when>
  +      </xsl:choose>
  +    </xsl:variable>
  +
  +    <xsl:variable name="value">
  +      <xsl:choose>
  +        <xsl:when test="@value">"<xsl:value-of select="@value"/>"</xsl:when>
  +        <xsl:when test="value">
  +          <xsl:call-template name="get-nested-content">
  +            <xsl:with-param name="content" select="xsp-response:value"/>
  +          </xsl:call-template>
  +        </xsl:when>
  +        <xsl:otherwise>""</xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +
  +    <xsp:logic>
  +      XSPResponseHelper.setHeader(this.response, <xsl:value-of select="$name"/>, <xsl:value-of select="$value"/>);
  +    </xsp:logic>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp-response:set-content-type">
  +    <xsl:variable name="type">
  +      <xsl:choose>
  +        <xsl:when test="@type">"<xsl:value-of select="@type"/>"</xsl:when>
  +        <xsl:when test="type">
  +          <xsl:call-template name="get-nested-content">
  +            <xsl:with-param name="content" select="xsp-response:type"/>
  +          </xsl:call-template>
  +        </xsl:when>
  +      </xsl:choose>
  +    </xsl:variable>
  +
  +    <xsp:logic>
  +      XSPResponseHelper.setContentType(this.response, <xsl:value-of select="$type"/>);
  +    </xsp:logic>
  +  </xsl:template>
  +
  +  <xsl:template name="get-nested-content">
  +    <xsl:param name="content"/>
  +    <xsl:choose>
  +      <xsl:when test="$content/*">
  +        <xsl:apply-templates select="$content/*"/>
  +      </xsl:when>
  +      <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  + 
  +  <xsl:template match="@*|*|text()|processing-instruction()">
  +    <xsl:copy>
  +      <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
  +    </xsl:copy>
  +  </xsl:template>
  +</xsl:stylesheet>
  
  
  
  1.1.2.5   +431 -431  xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/xsp.xsl
  
  Index: xsp.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/xsp.xsl,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- xsp.xsl	2000/07/11 23:46:38	1.1.2.4
  +++ xsp.xsl	2000/07/22 20:41:38	1.1.2.5
  @@ -1,431 +1,431 @@
  -<?xml version="1.0"?>
  -<!--
  - *****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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.                                                         *
  - ***************************************************************************** 
  --->
  -
  -<!-- XSP Core logicsheet for the Java language -->
  -<xsl:stylesheet
  -  version="1.0"
  -
  -  xmlns:xsp="http://xml.apache.org/xsp"
  -  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  ->
  -  <xsl:output method="text"/>
  -
  -  <xsl:variable name="prefix">xsp</xsl:variable>
  -
  -  <xsl:template match="/">
  -    <code xml:space="preserve">
  -      <xsl:apply-templates select="xsp:page"/>
  -    </code>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp:page">
  -    package <xsl:value-of select="translate(@file-path, '/', '.')"/>;
  -
  -    import java.io.*;
  -    import java.net.*;
  -    import java.util.*;
  -
  -    import org.w3c.dom.*;
  -    import org.xml.sax.*;
  -    import org.xml.sax.helpers.*;
  -
  -    import org.apache.avalon.*;
  -    import org.apache.avalon.utils.*;
  -    import org.apache.cocoon.*;
  -    import org.apache.cocoon.generation.*;
  -    import org.apache.cocoon.components.parser.*;
  -
  -    import org.apache.cocoon.components.language.markup.xsp.XSPGenerator;
  -    import org.apache.cocoon.components.language.markup.xsp.XSPRequestHelper;
  -    import org.apache.cocoon.components.language.markup.xsp.XSPResponseHelper;
  -
  -
  -    /* User Imports */
  -    <xsl:for-each select="xsp:structure/xsp:include">
  -      import <xsl:value-of select="."/>;
  -    </xsl:for-each>
  -
  -    /**
  -     * Generated by XSP. Edit at your own risk, :-)
  -     */
  -    public class <xsl:value-of select="@file-name"/> extends XSPGenerator {
  -      static {
  -        dateCreated = <xsl:value-of select="@creation-date"/>L;
  -        dependencies = new File[] {
  -          <xsl:for-each select="xsp:dependency">
  -            new File("<xsl:value-of select="translate(., '\','/')"/>"),
  -          </xsl:for-each>
  -        };
  -      }
  -
  -      /* User Class Declarations */
  -      <xsl:apply-templates select="xsp:logic"/>
  -
  -      /**
  -       * Generate XML data.
  -       */
  -      public void generate() throws SAXException {
  -        this.contentHandler.startDocument();
  -        AttributesImpl xspAttr = new AttributesImpl();
  -
  -        <!-- Generate top-level processing instructions -->
  -        <xsl:apply-templates select="/processing-instruction()"/>
  -
  -        <!-- Start top-level namespace prefix mapping -->
  -        <xsl:for-each select="namespace::*[not(local-name(.) = 'xsp')]">
  -          this.contentHandler.startPrefixMapping(
  -            "<xsl:value-of select="local-name(.)"/>",
  -            "<xsl:value-of select="."/>"
  -          );
  -        </xsl:for-each>
  -
  -        <!-- Process only 1st non-XSP element as generated root -->
  -        <xsl:call-template name="process-first-element">
  -          <xsl:with-param
  -                          name="content"
  -                          select="*[not(starts-with(name(.), 'xsp:'))]"/>
  -        </xsl:call-template>
  -
  -        <!-- End top-level namespace prefix mapping -->
  -        <xsl:for-each select="namespace::*[not(local-name(.) = 'xsp')]">
  -          this.contentHandler.endPrefixMapping(
  -            "<xsl:value-of select="local-name(.)"/>"
  -          );
  -        </xsl:for-each>
  -
  -        this.contentHandler.endDocument();
  -      }
  -    }
  -  </xsl:template>
  -
  -  <xsl:template name="process-first-element">
  -    <xsl:param name="content"/>
  -    <xsl:apply-templates select="$content[1]"/>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp:element">
  -    <xsl:variable name="uri">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="name">uri</xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:variable name="prefix">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="name">prefix</xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:variable name="name">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="name">name</xsl:with-param>
  -        <xsl:with-param name="required">true</xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:variable name="raw-name">
  -      <xsl:if test="
  -        ($uri = '&quot;&quot;' and $prefix != '&quot;&quot;') or
  -        ($uri != '&quot;&quot;' and $prefix = '&quot;&quot;')
  -      ">
  -        <xsl:call-template name="error">
  -          <xsl:with-param name="message">[&lt;xsp:element&gt;]
  -Either both 'uri' and 'prefix' or none of them must be specified
  -          </xsl:with-param>
  -        </xsl:call-template>
  -      </xsl:if>
  -
  -      <xsl:choose>
  -        <xsl:when test="$prefix = '&quot;&quot;'">
  -          <xsl:copy-of select="$name"/>
  -        </xsl:when>
  -        <xsl:otherwise>
  -          <xsl:copy-of select="$prefix"/> + ":" + <xsl:copy-of select="$name"/>
  -        </xsl:otherwise>
  -      </xsl:choose>
  -    </xsl:variable>
  -
  -    <xsl:for-each select="namespace::*">
  -      this.contentHandler.startPrefixMapping(
  -        "<xsl:value-of select="local-name(.)"/>",
  -        "<xsl:value-of select="."/>"
  -      );
  -    </xsl:for-each>
  -
  -    <xsl:apply-templates select="xsp:attribute"/>
  -
  -    this.contentHandler.startElement(
  -      <xsl:copy-of select="$uri"/>,
  -      <xsl:copy-of select="$name"/>,
  -      <xsl:copy-of select="$raw-name"/>,
  -      xspAttr
  -    );
  -
  -    xspAttr.clear();
  -
  -    <xsl:apply-templates select="node()[not(name(.) = 'xsp:attribute')]"/>
  -
  -    this.contentHandler.endElement(
  -      <xsl:copy-of select="$uri"/>,
  -      <xsl:copy-of select="$name"/>,
  -      <xsl:copy-of select="$raw-name"/>
  -    );
  -
  -    <xsl:for-each select="namespace::*">
  -      this.contentHandler.endPrefixMapping(
  -        "<xsl:value-of select="local-name(.)"/>"
  -      );
  -    </xsl:for-each>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp:attribute">
  -    <xsl:variable name="uri">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="name">uri</xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:variable name="prefix">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="name">prefix</xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:variable name="name">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="name">name</xsl:with-param>
  -        <xsl:with-param name="required">true</xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:variable name="raw-name">
  -      <xsl:if test="
  -        ($uri = '&quot;&quot;' and $prefix != '&quot;&quot;') or
  -        ($uri != '&quot;&quot;' and $prefix = '&quot;&quot;')
  -      ">
  -        <xsl:call-template name="error">
  -          <xsl:with-param name="message">[&lt;xsp:attribute&gt;]
  -Either both 'uri' and 'prefix' or none of them must be specified
  -          </xsl:with-param>
  -        </xsl:call-template>
  -      </xsl:if>
  -
  -      <xsl:choose>
  -        <xsl:when test="$prefix = '&quot;&quot;'">
  -          <xsl:copy-of select="$name"/>
  -        </xsl:when>
  -        <xsl:otherwise>
  -          <xsl:copy-of select="$prefix"/> + ":" + <xsl:copy-of select="$name"/>
  -        </xsl:otherwise>
  -      </xsl:choose>
  -    </xsl:variable>
  -
  -    <xsl:variable name="content">
  -      <xsl:for-each select="text()|xsp:expr">
  -        <xsl:choose>
  -          <xsl:when test="name(.) = 'xsp:expr'">
  -            String.valueOf(<xsl:value-of select="."/>)
  -          </xsl:when>
  -          <xsl:otherwise>
  -            "<xsl:value-of select="."/>"
  -          </xsl:otherwise>
  -        </xsl:choose>
  -        +
  -      </xsl:for-each>
  -      ""
  -    </xsl:variable>
  -
  -    xspAttr.addAttribute(
  -      <xsl:copy-of select="$uri"/>,
  -      <xsl:copy-of select="$name"/>,
  -      <xsl:copy-of select="$raw-name"/>,
  -      "CDATA",
  -      <xsl:value-of select="normalize-space($content)"/>
  -    );
  -  </xsl:template>
  -
  -  <xsl:template match="xsp:expr">
  -    <xsl:choose>
  -      <xsl:when test="starts-with(name(..), 'xsp:') and name(..) != 'xsp:content'">
  -        <!--
  -             Expression is nested inside another XSP tag:
  -             preserve its Java type
  -        -->
  -        (<xsl:value-of select="."/>)
  -      </xsl:when>
  -      <xsl:otherwise>
  -        <!-- Coerce to String and output as character data -->
  -        this.characters(String.valueOf(<xsl:value-of select="."/>));
  -      </xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <!-- FIXME: Is this _really_ necessary? -->
  -  <xsl:template match="xsp:content">
  -    <xsl:apply-templates/>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp:logic">
  -    <xsl:apply-templates/>
  -  </xsl:template>
  -
  -  <xsl:template match="xsp:pi">
  -    <xsl:variable name="target">
  -      <xsl:call-template name="get-parameter">
  -        <xsl:with-param name="name">target</xsl:with-param>
  -      </xsl:call-template>
  -    </xsl:variable>
  -
  -    <xsl:variable name="content">
  -      <xsl:for-each select="text()|xsp:expr">
  -        <xsl:choose>
  -          <xsl:when test="name(.) = 'xsp:expr'">
  -           String.valueOf(<xsl:value-of select="."/>)
  -          </xsl:when>
  -          <xsl:otherwise>
  -            "<xsl:value-of select="."/>"
  -          </xsl:otherwise>
  -        </xsl:choose>
  -       +
  -      </xsl:for-each>
  -      ""
  -    </xsl:variable>
  -
  -    this.contentHandler.processingInstruction(
  -      <xsl:copy-of select="$target"/>,
  -      <xsl:value-of select="normalize-space($content)"/>
  -    );
  -  </xsl:template>
  -
  -  <!-- FIXME: How to create comments in SAX? -->
  -  <xsl:template match="xsp:comment">
  -    this.comment("<xsl:value-of select="."/>");
  -  </xsl:template>
  -
  -
  -  <xsl:template match="*[not(starts-with(name(.), 'xsp:'))]">
  -    <xsl:for-each select="namespace::*">
  -      this.contentHandler.startPrefixMapping(
  -        "<xsl:value-of select="local-name(.)"/>",
  -        "<xsl:value-of select="."/>"
  -      );
  -    </xsl:for-each>
  -
  -    <xsl:apply-templates select="@*"/>
  -
  -    this.contentHandler.startElement(
  -      "<xsl:value-of select="namespace-uri(.)"/>",
  -      "<xsl:value-of select="local-name(.)"/>",
  -      "<xsl:value-of select="name(.)"/>",
  -      xspAttr
  -    );
  -
  -    xspAttr.clear();
  -
  -    <xsl:apply-templates/>
  -
  -    this.contentHandler.endElement(
  -      "<xsl:value-of select="namespace-uri(.)"/>",
  -      "<xsl:value-of select="local-name(.)"/>",
  -      "<xsl:value-of select="name(.)"/>"
  -    );
  -
  -    <xsl:for-each select="namespace::*">
  -      this.contentHandler.endPrefixMapping(
  -        "<xsl:value-of select="local-name(.)"/>"
  -      );
  -    </xsl:for-each>
  -  </xsl:template>
  -
  -  <xsl:template match="@*">
  -    xspAttr.addAttribute(
  -      "<xsl:value-of select="namespace-uri(.)"/>",
  -      "<xsl:value-of select="local-name(.)"/>",
  -      "<xsl:value-of select="name(.)"/>",
  -      "CDATA",
  -      "<xsl:value-of select="."/>"
  -    );
  -  </xsl:template>
  -
  -  <xsl:template match="text()">
  -    <xsl:choose>
  -      <xsl:when test="name(..) = 'xsp:logic' or name(..) = 'xsp:expr'">
  -        <xsl:value-of select="."/>
  -      </xsl:when>
  -      <xsl:otherwise>
  -        this.characters("<xsl:value-of select="."/>");
  -      </xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template match="processing-instruction()">
  -    this.contentHandler.processingInstruction(
  -      "<xsl:value-of select="name()"/>",
  -      "<xsl:value-of select="."/>"
  -    );
  -  </xsl:template>
  -
  -  <!-- Utility templates -->
  -  <xsl:template name="get-parameter">
  -    <xsl:param name="name"/>
  -    <xsl:param name="default"/>
  -    <xsl:param name="required">false</xsl:param>
  -
  -    <xsl:variable name="qname">
  -      <xsl:value-of select="concat($prefix, ':param')"/>
  -    </xsl:variable>
  -
  -    <xsl:choose>
  -      <xsl:when test="@*[name(.) = $name]">"<xsl:value-of select="@*[name(.) = $name]"/>"</xsl:when>
  -      <xsl:when test="(*[name(.) = $qname])[@name = $name]">
  -        <xsl:call-template name="get-nested-content">
  -          <xsl:with-param name="content"
  -                          select="(*[name(.) = $qname])[@name = $name]"/>
  -        </xsl:call-template>
  -      </xsl:when>
  -      <xsl:otherwise>
  -        <xsl:choose>
  -          <xsl:when test="string-length($default) = 0">
  -            <xsl:choose>
  -              <xsl:when test="$required = 'true'">
  -                <xsl:call-template name="error">
  -                  <xsl:with-param name="message">[Logicsheet processor]
  -Parameter '<xsl:value-of select="$name"/>' missing in dynamic tag &lt;<xsl:value-of select="name(.)"/>&gt;
  -                  </xsl:with-param>
  -                </xsl:call-template>
  -              </xsl:when>
  -              <xsl:otherwise>""</xsl:otherwise>
  -            </xsl:choose>
  -          </xsl:when>
  -          <xsl:otherwise><xsl:copy-of select="$default"/></xsl:otherwise>
  -        </xsl:choose>
  -      </xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template name="get-nested-content">
  -    <xsl:param name="content"/>
  -    <xsl:choose>
  -      <xsl:when test="$content/*">
  -        <xsl:apply-templates select="$content/*"/>
  -      </xsl:when>
  -      <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
  -    </xsl:choose>
  -  </xsl:template>
  -
  -  <xsl:template name="error">
  -    <xsl:param name="message"/>
  -    <xsl:message terminate="yes"><xsl:value-of select="$message"/></xsl:message>
  -  </xsl:template>
  -
  -  <!-- Ignored elements -->
  -  <xsl:template match="xsp:logicsheet|xsp:dependency|xsp:param"/>
  -</xsl:stylesheet>
  +<?xml version="1.0"?>
  +<!--
  + *****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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.                                                         *
  + ***************************************************************************** 
  +-->
  +
  +<!-- XSP Core logicsheet for the Java language -->
  +<xsl:stylesheet
  +  version="1.0"
  +
  +  xmlns:xsp="http://xml.apache.org/xsp"
  +  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  +>
  +  <xsl:output method="text"/>
  +
  +  <xsl:variable name="prefix">xsp</xsl:variable>
  +
  +  <xsl:template match="/">
  +    <code xml:space="preserve">
  +      <xsl:apply-templates select="xsp:page"/>
  +    </code>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp:page">
  +    package <xsl:value-of select="translate(@file-path, '/', '.')"/>;
  +
  +    import java.io.*;
  +    import java.net.*;
  +    import java.util.*;
  +
  +    import org.w3c.dom.*;
  +    import org.xml.sax.*;
  +    import org.xml.sax.helpers.*;
  +
  +    import org.apache.avalon.*;
  +    import org.apache.avalon.utils.*;
  +    import org.apache.cocoon.*;
  +    import org.apache.cocoon.generation.*;
  +    import org.apache.cocoon.components.parser.*;
  +
  +    import org.apache.cocoon.components.language.markup.xsp.XSPGenerator;
  +    import org.apache.cocoon.components.language.markup.xsp.XSPRequestHelper;
  +    import org.apache.cocoon.components.language.markup.xsp.XSPResponseHelper;
  +
  +
  +    /* User Imports */
  +    <xsl:for-each select="xsp:structure/xsp:include">
  +      import <xsl:value-of select="."/>;
  +    </xsl:for-each>
  +
  +    /**
  +     * Generated by XSP. Edit at your own risk, :-)
  +     */
  +    public class <xsl:value-of select="@file-name"/> extends XSPGenerator {
  +      static {
  +        dateCreated = <xsl:value-of select="@creation-date"/>L;
  +        dependencies = new File[] {
  +          <xsl:for-each select="xsp:dependency">
  +            new File("<xsl:value-of select="translate(., '\','/')"/>"),
  +          </xsl:for-each>
  +        };
  +      }
  +
  +      /* User Class Declarations */
  +      <xsl:apply-templates select="xsp:logic"/>
  +
  +      /**
  +       * Generate XML data.
  +       */
  +      public void generate() throws SAXException {
  +        this.contentHandler.startDocument();
  +        AttributesImpl xspAttr = new AttributesImpl();
  +
  +        <!-- Generate top-level processing instructions -->
  +        <xsl:apply-templates select="/processing-instruction()"/>
  +
  +        <!-- Start top-level namespace prefix mapping -->
  +        <xsl:for-each select="namespace::*[not(local-name(.) = 'xsp')]">
  +          this.contentHandler.startPrefixMapping(
  +            "<xsl:value-of select="local-name(.)"/>",
  +            "<xsl:value-of select="."/>"
  +          );
  +        </xsl:for-each>
  +
  +        <!-- Process only 1st non-XSP element as generated root -->
  +        <xsl:call-template name="process-first-element">
  +          <xsl:with-param
  +                          name="content"
  +                          select="*[not(starts-with(name(.), 'xsp:'))]"/>
  +        </xsl:call-template>
  +
  +        <!-- End top-level namespace prefix mapping -->
  +        <xsl:for-each select="namespace::*[not(local-name(.) = 'xsp')]">
  +          this.contentHandler.endPrefixMapping(
  +            "<xsl:value-of select="local-name(.)"/>"
  +          );
  +        </xsl:for-each>
  +
  +        this.contentHandler.endDocument();
  +      }
  +    }
  +  </xsl:template>
  +
  +  <xsl:template name="process-first-element">
  +    <xsl:param name="content"/>
  +    <xsl:apply-templates select="$content[1]"/>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp:element">
  +    <xsl:variable name="uri">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="name">uri</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:variable name="prefix">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="name">prefix</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:variable name="name">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="name">name</xsl:with-param>
  +        <xsl:with-param name="required">true</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:variable name="raw-name">
  +      <xsl:if test="
  +        ($uri = '&quot;&quot;' and $prefix != '&quot;&quot;') or
  +        ($uri != '&quot;&quot;' and $prefix = '&quot;&quot;')
  +      ">
  +        <xsl:call-template name="error">
  +          <xsl:with-param name="message">[&lt;xsp:element&gt;]
  +Either both 'uri' and 'prefix' or none of them must be specified
  +          </xsl:with-param>
  +        </xsl:call-template>
  +      </xsl:if>
  +
  +      <xsl:choose>
  +        <xsl:when test="$prefix = '&quot;&quot;'">
  +          <xsl:copy-of select="$name"/>
  +        </xsl:when>
  +        <xsl:otherwise>
  +          <xsl:copy-of select="$prefix"/> + ":" + <xsl:copy-of select="$name"/>
  +        </xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +
  +    <xsl:for-each select="namespace::*">
  +      this.contentHandler.startPrefixMapping(
  +        "<xsl:value-of select="local-name(.)"/>",
  +        "<xsl:value-of select="."/>"
  +      );
  +    </xsl:for-each>
  +
  +    <xsl:apply-templates select="xsp:attribute"/>
  +
  +    this.contentHandler.startElement(
  +      <xsl:copy-of select="$uri"/>,
  +      <xsl:copy-of select="$name"/>,
  +      <xsl:copy-of select="$raw-name"/>,
  +      xspAttr
  +    );
  +
  +    xspAttr.clear();
  +
  +    <xsl:apply-templates select="node()[not(name(.) = 'xsp:attribute')]"/>
  +
  +    this.contentHandler.endElement(
  +      <xsl:copy-of select="$uri"/>,
  +      <xsl:copy-of select="$name"/>,
  +      <xsl:copy-of select="$raw-name"/>
  +    );
  +
  +    <xsl:for-each select="namespace::*">
  +      this.contentHandler.endPrefixMapping(
  +        "<xsl:value-of select="local-name(.)"/>"
  +      );
  +    </xsl:for-each>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp:attribute">
  +    <xsl:variable name="uri">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="name">uri</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:variable name="prefix">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="name">prefix</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:variable name="name">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="name">name</xsl:with-param>
  +        <xsl:with-param name="required">true</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:variable name="raw-name">
  +      <xsl:if test="
  +        ($uri = '&quot;&quot;' and $prefix != '&quot;&quot;') or
  +        ($uri != '&quot;&quot;' and $prefix = '&quot;&quot;')
  +      ">
  +        <xsl:call-template name="error">
  +          <xsl:with-param name="message">[&lt;xsp:attribute&gt;]
  +Either both 'uri' and 'prefix' or none of them must be specified
  +          </xsl:with-param>
  +        </xsl:call-template>
  +      </xsl:if>
  +
  +      <xsl:choose>
  +        <xsl:when test="$prefix = '&quot;&quot;'">
  +          <xsl:copy-of select="$name"/>
  +        </xsl:when>
  +        <xsl:otherwise>
  +          <xsl:copy-of select="$prefix"/> + ":" + <xsl:copy-of select="$name"/>
  +        </xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +
  +    <xsl:variable name="content">
  +      <xsl:for-each select="text()|xsp:expr">
  +        <xsl:choose>
  +          <xsl:when test="name(.) = 'xsp:expr'">
  +            String.valueOf(<xsl:value-of select="."/>)
  +          </xsl:when>
  +          <xsl:otherwise>
  +            "<xsl:value-of select="."/>"
  +          </xsl:otherwise>
  +        </xsl:choose>
  +        +
  +      </xsl:for-each>
  +      ""
  +    </xsl:variable>
  +
  +    xspAttr.addAttribute(
  +      <xsl:copy-of select="$uri"/>,
  +      <xsl:copy-of select="$name"/>,
  +      <xsl:copy-of select="$raw-name"/>,
  +      "CDATA",
  +      <xsl:value-of select="normalize-space($content)"/>
  +    );
  +  </xsl:template>
  +
  +  <xsl:template match="xsp:expr">
  +    <xsl:choose>
  +      <xsl:when test="starts-with(name(..), 'xsp:') and name(..) != 'xsp:content'">
  +        <!--
  +             Expression is nested inside another XSP tag:
  +             preserve its Java type
  +        -->
  +        (<xsl:value-of select="."/>)
  +      </xsl:when>
  +      <xsl:otherwise>
  +        <!-- Coerce to String and output as character data -->
  +        this.characters(String.valueOf(<xsl:value-of select="."/>));
  +      </xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <!-- FIXME: Is this _really_ necessary? -->
  +  <xsl:template match="xsp:content">
  +    <xsl:apply-templates/>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp:logic">
  +    <xsl:apply-templates/>
  +  </xsl:template>
  +
  +  <xsl:template match="xsp:pi">
  +    <xsl:variable name="target">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="name">target</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <xsl:variable name="content">
  +      <xsl:for-each select="text()|xsp:expr">
  +        <xsl:choose>
  +          <xsl:when test="name(.) = 'xsp:expr'">
  +           String.valueOf(<xsl:value-of select="."/>)
  +          </xsl:when>
  +          <xsl:otherwise>
  +            "<xsl:value-of select="."/>"
  +          </xsl:otherwise>
  +        </xsl:choose>
  +       +
  +      </xsl:for-each>
  +      ""
  +    </xsl:variable>
  +
  +    this.contentHandler.processingInstruction(
  +      <xsl:copy-of select="$target"/>,
  +      <xsl:value-of select="normalize-space($content)"/>
  +    );
  +  </xsl:template>
  +
  +  <!-- FIXME: How to create comments in SAX? -->
  +  <xsl:template match="xsp:comment">
  +    this.comment("<xsl:value-of select="."/>");
  +  </xsl:template>
  +
  +
  +  <xsl:template match="*[not(starts-with(name(.), 'xsp:'))]">
  +    <xsl:for-each select="namespace::*">
  +      this.contentHandler.startPrefixMapping(
  +        "<xsl:value-of select="local-name(.)"/>",
  +        "<xsl:value-of select="."/>"
  +      );
  +    </xsl:for-each>
  +
  +    <xsl:apply-templates select="@*"/>
  +
  +    this.contentHandler.startElement(
  +      "<xsl:value-of select="namespace-uri(.)"/>",
  +      "<xsl:value-of select="local-name(.)"/>",
  +      "<xsl:value-of select="name(.)"/>",
  +      xspAttr
  +    );
  +
  +    xspAttr.clear();
  +
  +    <xsl:apply-templates/>
  +
  +    this.contentHandler.endElement(
  +      "<xsl:value-of select="namespace-uri(.)"/>",
  +      "<xsl:value-of select="local-name(.)"/>",
  +      "<xsl:value-of select="name(.)"/>"
  +    );
  +
  +    <xsl:for-each select="namespace::*">
  +      this.contentHandler.endPrefixMapping(
  +        "<xsl:value-of select="local-name(.)"/>"
  +      );
  +    </xsl:for-each>
  +  </xsl:template>
  +
  +  <xsl:template match="@*">
  +    xspAttr.addAttribute(
  +      "<xsl:value-of select="namespace-uri(.)"/>",
  +      "<xsl:value-of select="local-name(.)"/>",
  +      "<xsl:value-of select="name(.)"/>",
  +      "CDATA",
  +      "<xsl:value-of select="."/>"
  +    );
  +  </xsl:template>
  +
  +  <xsl:template match="text()">
  +    <xsl:choose>
  +      <xsl:when test="name(..) = 'xsp:logic' or name(..) = 'xsp:expr'">
  +        <xsl:value-of select="."/>
  +      </xsl:when>
  +      <xsl:otherwise>
  +        this.characters("<xsl:value-of select="."/>");
  +      </xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template match="processing-instruction()">
  +    this.contentHandler.processingInstruction(
  +      "<xsl:value-of select="name()"/>",
  +      "<xsl:value-of select="."/>"
  +    );
  +  </xsl:template>
  +
  +  <!-- Utility templates -->
  +  <xsl:template name="get-parameter">
  +    <xsl:param name="name"/>
  +    <xsl:param name="default"/>
  +    <xsl:param name="required">false</xsl:param>
  +
  +    <xsl:variable name="qname">
  +      <xsl:value-of select="concat($prefix, ':param')"/>
  +    </xsl:variable>
  +
  +    <xsl:choose>
  +      <xsl:when test="@*[name(.) = $name]">"<xsl:value-of select="@*[name(.) = $name]"/>"</xsl:when>
  +      <xsl:when test="(*[name(.) = $qname])[@name = $name]">
  +        <xsl:call-template name="get-nested-content">
  +          <xsl:with-param name="content"
  +                          select="(*[name(.) = $qname])[@name = $name]"/>
  +        </xsl:call-template>
  +      </xsl:when>
  +      <xsl:otherwise>
  +        <xsl:choose>
  +          <xsl:when test="string-length($default) = 0">
  +            <xsl:choose>
  +              <xsl:when test="$required = 'true'">
  +                <xsl:call-template name="error">
  +                  <xsl:with-param name="message">[Logicsheet processor]
  +Parameter '<xsl:value-of select="$name"/>' missing in dynamic tag &lt;<xsl:value-of select="name(.)"/>&gt;
  +                  </xsl:with-param>
  +                </xsl:call-template>
  +              </xsl:when>
  +              <xsl:otherwise>""</xsl:otherwise>
  +            </xsl:choose>
  +          </xsl:when>
  +          <xsl:otherwise><xsl:copy-of select="$default"/></xsl:otherwise>
  +        </xsl:choose>
  +      </xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template name="get-nested-content">
  +    <xsl:param name="content"/>
  +    <xsl:choose>
  +      <xsl:when test="$content/*">
  +        <xsl:apply-templates select="$content/*"/>
  +      </xsl:when>
  +      <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
  +    </xsl:choose>
  +  </xsl:template>
  +
  +  <xsl:template name="error">
  +    <xsl:param name="message"/>
  +    <xsl:message terminate="yes"><xsl:value-of select="$message"/></xsl:message>
  +  </xsl:template>
  +
  +  <!-- Ignored elements -->
  +  <xsl:template match="xsp:logicsheet|xsp:dependency|xsp:param"/>
  +</xsl:stylesheet>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +95 -95    xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/AbstractProgrammingLanguage.java
  
  Index: AbstractProgrammingLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/AbstractProgrammingLanguage.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AbstractProgrammingLanguage.java	2000/07/11 03:09:46	1.1.2.2
  +++ AbstractProgrammingLanguage.java	2000/07/22 20:41:39	1.1.2.3
  @@ -1,95 +1,95 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  -
  -import java.io.File;
  -
  -import org.apache.avalon.Configurable;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.avalon.AbstractNamedComponent;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * Base implementation of <code>ProgrammingLanguage</code>. This class sets the
  - * <code>CodeFormatter</code> instance and deletes source program files after
  - * unloading.
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:09:46 $
  - */
  -public abstract class AbstractProgrammingLanguage
  -  extends AbstractNamedComponent
  -  implements ProgrammingLanguage
  -{
  -  /** The source code formatter */
  -  protected Class codeFormatter;
  -
  -  /**
  -   * Set the configuration parameters. This method instantiates the
  -   * sitemap-specified source code formatter
  -   *
  -   * @param params The configuration parameters
  -   * @exception Exception If the language compiler cannot be loaded
  -   */
  -  protected void setParameters(Parameters params) throws Exception
  -  {
  -    try {
  -      String className = params.getParameter("code-formatter", null);
  -      if (className != null) {
  -        this.codeFormatter =
  -	  this.getClass().getClassLoader().loadClass(className);
  -      }
  -    } catch (Exception e) { }
  -  }
  -
  -  /**
  -   * Return this language's source code formatter. A new formatter instance is
  -   * created on each invocation.
  -   *
  -   * @return The language source code formatter
  -   */
  -  public CodeFormatter getCodeFormatter() {
  -    if (this.codeFormatter != null) {
  -      try {
  -        return (CodeFormatter) this.codeFormatter.newInstance();
  -      } catch (Exception e) { }
  -    }
  -
  -    return null;
  -  }
  -
  -  /**
  -   * Unload a previously loaded program
  -   *
  -   * @param program A previously loaded object program
  -   * @exception LanguageException If an error occurs during unloading
  -   */
  -  protected abstract void doUnload(
  -    Object program, String filename, String baseDirectory
  -  )
  -    throws LanguageException;
  -
  -  public final void unload(
  -    Object program, String filename, String baseDirectory
  -  )
  -    throws LanguageException
  -  {
  -    File file = new File (
  -      baseDirectory + File.separator +
  -      filename + "." + this.getSourceExtension()
  -    );
  -
  -    file.delete();
  -
  -    this.doUnload(program, filename, baseDirectory);
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  +
  +import java.io.File;
  +
  +import org.apache.avalon.Configurable;
  +import org.apache.avalon.Configuration;
  +import org.apache.avalon.ConfigurationException;
  +
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.avalon.AbstractNamedComponent;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * Base implementation of <code>ProgrammingLanguage</code>. This class sets the
  + * <code>CodeFormatter</code> instance and deletes source program files after
  + * unloading.
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:39 $
  + */
  +public abstract class AbstractProgrammingLanguage
  +  extends AbstractNamedComponent
  +  implements ProgrammingLanguage
  +{
  +  /** The source code formatter */
  +  protected Class codeFormatter;
  +
  +  /**
  +   * Set the configuration parameters. This method instantiates the
  +   * sitemap-specified source code formatter
  +   *
  +   * @param params The configuration parameters
  +   * @exception Exception If the language compiler cannot be loaded
  +   */
  +  protected void setParameters(Parameters params) throws Exception
  +  {
  +    try {
  +      String className = params.getParameter("code-formatter", null);
  +      if (className != null) {
  +        this.codeFormatter =
  +	  this.getClass().getClassLoader().loadClass(className);
  +      }
  +    } catch (Exception e) { }
  +  }
  +
  +  /**
  +   * Return this language's source code formatter. A new formatter instance is
  +   * created on each invocation.
  +   *
  +   * @return The language source code formatter
  +   */
  +  public CodeFormatter getCodeFormatter() {
  +    if (this.codeFormatter != null) {
  +      try {
  +        return (CodeFormatter) this.codeFormatter.newInstance();
  +      } catch (Exception e) { }
  +    }
  +
  +    return null;
  +  }
  +
  +  /**
  +   * Unload a previously loaded program
  +   *
  +   * @param program A previously loaded object program
  +   * @exception LanguageException If an error occurs during unloading
  +   */
  +  protected abstract void doUnload(
  +    Object program, String filename, String baseDirectory
  +  )
  +    throws LanguageException;
  +
  +  public final void unload(
  +    Object program, String filename, String baseDirectory
  +  )
  +    throws LanguageException
  +  {
  +    File file = new File (
  +      baseDirectory + File.separator +
  +      filename + "." + this.getSourceExtension()
  +    );
  +
  +    file.delete();
  +
  +    this.doUnload(program, filename, baseDirectory);
  +  }
  +}
  
  
  
  1.1.2.2   +26 -26    xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CodeFormatter.java
  
  Index: CodeFormatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CodeFormatter.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CodeFormatter.java	2000/05/23 23:10:01	1.1.2.1
  +++ CodeFormatter.java	2000/07/22 20:41:39	1.1.2.2
  @@ -1,26 +1,26 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  -
  -/**
  - * This interface defines source beautifying formatting
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:10:01 $
  - */
  -public interface CodeFormatter {
  -  /**
  -   * Format and beautify a <code>String</code> containing source code 
  -   *
  -   * @param code The input source code
  -   * @param encoding The encoding used for constant strings embedded in the
  -   * source code
  -   * @return The formatted source code
  -   */
  -  public String format(String code, String encoding);
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  +
  +/**
  + * This interface defines source beautifying formatting
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:39 $
  + */
  +public interface CodeFormatter {
  +  /**
  +   * Format and beautify a <code>String</code> containing source code 
  +   *
  +   * @param code The input source code
  +   * @param encoding The encoding used for constant strings embedded in the
  +   * source code
  +   * @return The formatted source code
  +   */
  +  public String format(String code, String encoding);
  +}
  
  
  
  1.1.2.4   +182 -182  xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompiledProgrammingLanguage.java
  
  Index: CompiledProgrammingLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompiledProgrammingLanguage.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- CompiledProgrammingLanguage.java	2000/07/11 03:09:46	1.1.2.3
  +++ CompiledProgrammingLanguage.java	2000/07/22 20:41:39	1.1.2.4
  @@ -1,182 +1,182 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  -
  -import java.io.File;
  -
  -import org.apache.avalon.utils.Parameters;
  -
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.Component;
  -import org.apache.avalon.ComponentManager;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * A compiled programming language. This class extends
  - * <code>AbstractProgrammingLanguage</code> adding support for compilation
  - * and object program files
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/11 03:09:46 $
  - */
  -public abstract class CompiledProgrammingLanguage
  -  extends AbstractProgrammingLanguage
  -  implements Composer
  -{
  -  /** The compiler */
  -  protected Class compilerClass;
  -
  -  /** The component manager */
  -  protected ComponentManager manager;
  -
  -  /** The source deletion option */
  -  protected boolean deleteSources = false;
  -
  -  /**
  -   * Set the configuration parameters. This method instantiates the
  -   * sitemap-specified language compiler
  -   *
  -   * @param params The configuration parameters
  -   * @exception Exception If the language compiler cannot be loaded
  -   */
  -  protected void setParameters(Parameters params) throws Exception {
  -    super.setParameters(params);
  -
  -    String compilerClass = params.getParameter("compiler", null);
  -    if (compilerClass == null) {
  -      throw new LanguageException(
  -        "Missing 'compiler' parameter for compiled language '" +
  -	this.getName() + "'"
  -      );
  -    }
  -    this.compilerClass =
  -      this.getClass().getClassLoader().loadClass(compilerClass);
  -
  -    this.deleteSources = params.getParameterAsBoolean("delete-sources", false);
  -  }
  -
  -  /**
  -   * Set the global component manager
  -   *
  -   * @param manager The global component manager
  -   */
  -  public void setComponentManager(ComponentManager manager) {
  -    this.manager = manager;
  -  }
  -
  -  /**
  -   * Return the language's canonical object file extension.
  -   *
  -   * @return The object file extension
  -   */
  -  public abstract String getObjectExtension();
  -
  -  /**
  -   * Unload a previously loaded program
  -   *
  -   * @param program A previously loaded object program
  -   * @exception LanguageException If an error occurs during unloading
  -   */
  -  public abstract void doUnload(Object program) throws LanguageException;
  -
  -  /**
  -   * Unload a previously loaded program given its original filesystem location
  -   *
  -   * @param program The previously loaded object program
  -   * @param filename The base filename of the object program
  -   * @param baseDirectory The directory contaning the object program file
  -   * @return the value
  -   * @exception EXCEPTION_NAME If an error occurs
  -   */
  -  protected final void doUnload(
  -    Object program, String filename, String baseDirectory
  -  )
  -    throws LanguageException
  -  {
  -    File file = new File (
  -      baseDirectory + File.separator +
  -      filename + "." + this.getObjectExtension()
  -    );
  -
  -    file.delete();
  -
  -    this.doUnload(program);
  -  }
  -
  -  /**
  -   * Actually load an object program from a file.
  -   *
  -   * @param filename The object program base file name
  -   * @param baseDirectory The directory containing the object program file
  -   * @return The loaded object program
  -   * @exception LanguageException If an error occurs during loading
  -   */
  -  protected abstract Object loadProgram(String filename, String baseDirectory)
  -    throws LanguageException;
  -
  -  /**
  -   * Compile a source file yielding a loadable object file.
  -   *
  -   * @param filename The object program base file name
  -   * @param baseDirectory The directory containing the object program file
  -   * @param encoding The encoding expected in the source file or
  -   * <code>null</code> if it is the platform's default encoding
  -   * @exception LanguageException If an error occurs during compilation
  -   */
  -  protected abstract void compile(
  -    String filename, String baseDirectory, String encoding
  -  ) throws LanguageException;
  -
  -  /**
  -   * Load an object program from a file. This method compiled the
  -   * corresponding source file if necessary
  -   *
  -   * @param filename The object program base file name
  -   * @param baseDirectory The directory containing the object program file
  -   * @param encoding The encoding expected in the source file or
  -   * <code>null</code> if it is the platform's default encoding
  -   * @return The loaded object program
  -   * @exception LanguageException If an error occurs during compilation
  -   */
  -  public Object load(String filename, String baseDirectory, String encoding)
  -    throws LanguageException
  -  {
  -
  -    // Does object file exist? Load and return instance
  -    File objectFile = new File(
  -      baseDirectory + File.separator +
  -      filename + "." + this.getObjectExtension()
  -    );
  -
  -    if (objectFile.exists() && objectFile.isFile() && objectFile.canRead()) {
  -      return this.loadProgram(filename, baseDirectory);
  -    }
  -
  -    // Does source file exist?
  -    File sourceFile = new File(
  -      baseDirectory + File.separator +
  -      filename + "." + this.getSourceExtension()
  -    );
  -
  -    if (sourceFile.exists() && sourceFile.isFile() && sourceFile.canRead()) {
  -      this.compile(filename, baseDirectory, encoding);
  -
  -      if (this.deleteSources) {
  -        sourceFile.delete();
  -      }
  -
  -      return this.loadProgram(filename, baseDirectory);
  -    }
  -
  -    throw new LanguageException(
  -      "Can't load program: " +
  -      baseDirectory + File.separator + filename
  -    );
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  +
  +import java.io.File;
  +
  +import org.apache.avalon.utils.Parameters;
  +
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.Component;
  +import org.apache.avalon.ComponentManager;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * A compiled programming language. This class extends
  + * <code>AbstractProgrammingLanguage</code> adding support for compilation
  + * and object program files
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:39 $
  + */
  +public abstract class CompiledProgrammingLanguage
  +  extends AbstractProgrammingLanguage
  +  implements Composer
  +{
  +  /** The compiler */
  +  protected Class compilerClass;
  +
  +  /** The component manager */
  +  protected ComponentManager manager;
  +
  +  /** The source deletion option */
  +  protected boolean deleteSources = false;
  +
  +  /**
  +   * Set the configuration parameters. This method instantiates the
  +   * sitemap-specified language compiler
  +   *
  +   * @param params The configuration parameters
  +   * @exception Exception If the language compiler cannot be loaded
  +   */
  +  protected void setParameters(Parameters params) throws Exception {
  +    super.setParameters(params);
  +
  +    String compilerClass = params.getParameter("compiler", null);
  +    if (compilerClass == null) {
  +      throw new LanguageException(
  +        "Missing 'compiler' parameter for compiled language '" +
  +	this.getName() + "'"
  +      );
  +    }
  +    this.compilerClass =
  +      this.getClass().getClassLoader().loadClass(compilerClass);
  +
  +    this.deleteSources = params.getParameterAsBoolean("delete-sources", false);
  +  }
  +
  +  /**
  +   * Set the global component manager
  +   *
  +   * @param manager The global component manager
  +   */
  +  public void setComponentManager(ComponentManager manager) {
  +    this.manager = manager;
  +  }
  +
  +  /**
  +   * Return the language's canonical object file extension.
  +   *
  +   * @return The object file extension
  +   */
  +  public abstract String getObjectExtension();
  +
  +  /**
  +   * Unload a previously loaded program
  +   *
  +   * @param program A previously loaded object program
  +   * @exception LanguageException If an error occurs during unloading
  +   */
  +  public abstract void doUnload(Object program) throws LanguageException;
  +
  +  /**
  +   * Unload a previously loaded program given its original filesystem location
  +   *
  +   * @param program The previously loaded object program
  +   * @param filename The base filename of the object program
  +   * @param baseDirectory The directory contaning the object program file
  +   * @return the value
  +   * @exception EXCEPTION_NAME If an error occurs
  +   */
  +  protected final void doUnload(
  +    Object program, String filename, String baseDirectory
  +  )
  +    throws LanguageException
  +  {
  +    File file = new File (
  +      baseDirectory + File.separator +
  +      filename + "." + this.getObjectExtension()
  +    );
  +
  +    file.delete();
  +
  +    this.doUnload(program);
  +  }
  +
  +  /**
  +   * Actually load an object program from a file.
  +   *
  +   * @param filename The object program base file name
  +   * @param baseDirectory The directory containing the object program file
  +   * @return The loaded object program
  +   * @exception LanguageException If an error occurs during loading
  +   */
  +  protected abstract Object loadProgram(String filename, String baseDirectory)
  +    throws LanguageException;
  +
  +  /**
  +   * Compile a source file yielding a loadable object file.
  +   *
  +   * @param filename The object program base file name
  +   * @param baseDirectory The directory containing the object program file
  +   * @param encoding The encoding expected in the source file or
  +   * <code>null</code> if it is the platform's default encoding
  +   * @exception LanguageException If an error occurs during compilation
  +   */
  +  protected abstract void compile(
  +    String filename, String baseDirectory, String encoding
  +  ) throws LanguageException;
  +
  +  /**
  +   * Load an object program from a file. This method compiled the
  +   * corresponding source file if necessary
  +   *
  +   * @param filename The object program base file name
  +   * @param baseDirectory The directory containing the object program file
  +   * @param encoding The encoding expected in the source file or
  +   * <code>null</code> if it is the platform's default encoding
  +   * @return The loaded object program
  +   * @exception LanguageException If an error occurs during compilation
  +   */
  +  public Object load(String filename, String baseDirectory, String encoding)
  +    throws LanguageException
  +  {
  +
  +    // Does object file exist? Load and return instance
  +    File objectFile = new File(
  +      baseDirectory + File.separator +
  +      filename + "." + this.getObjectExtension()
  +    );
  +
  +    if (objectFile.exists() && objectFile.isFile() && objectFile.canRead()) {
  +      return this.loadProgram(filename, baseDirectory);
  +    }
  +
  +    // Does source file exist?
  +    File sourceFile = new File(
  +      baseDirectory + File.separator +
  +      filename + "." + this.getSourceExtension()
  +    );
  +
  +    if (sourceFile.exists() && sourceFile.isFile() && sourceFile.canRead()) {
  +      this.compile(filename, baseDirectory, encoding);
  +
  +      if (this.deleteSources) {
  +        sourceFile.delete();
  +      }
  +
  +      return this.loadProgram(filename, baseDirectory);
  +    }
  +
  +    throw new LanguageException(
  +      "Can't load program: " +
  +      baseDirectory + File.separator + filename
  +    );
  +  }
  +}
  
  
  
  1.1.2.2   +145 -145  xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompilerError.java
  
  Index: CompilerError.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompilerError.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CompilerError.java	2000/05/23 23:10:03	1.1.2.1
  +++ CompilerError.java	2000/07/22 20:41:39	1.1.2.2
  @@ -1,145 +1,145 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  -
  -/**
  - * This class encapsulates an error message produced by a programming language
  - * processor (whether interpreted or compiled)
  - * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:10:03 $
  - * @since 2.0
  - */
  -
  -public class CompilerError {
  -  /**
  -   * Is this a severe error or a warning?
  -   */
  -  private boolean error;
  -  /**
  -   * The start line number of the offending program text
  -   */
  -  private int startline;
  -  /**
  -   * The start column number of the offending program text
  -   */
  -  private int startcolumn;
  -  /**
  -   * The end line number of the offending program text
  -   */
  -  private int endline;
  -  /**
  -   * The end column number of the offending program text
  -   */
  -  private int endcolumn;
  -  /**
  -   * The name of the file containing the offending program text
  -   */
  -  private String file;
  -  /**
  -   * The actual error text produced by the language processor
  -   */
  -  private String message;
  -    
  -  /**
  -   * The error message constructor.
  -   *
  -   * @param file The name of the file containing the offending program text
  -   * @param error The actual error text produced by the language processor
  -   * @param startline The start line number of the offending program text
  -   * @param startcolumn The start column number of the offending program text
  -   * @param endline The end line number of the offending program text
  -   * @param endcolumn The end column number of the offending program text
  -   * @param message The actual error text produced by the language processor
  -   */
  -  public CompilerError(
  -    String file,
  -    boolean error,
  -    int startline,
  -    int startcolumn,
  -    int endline,
  -    int endcolumn,
  -    String message
  -  ) 
  -  {
  -    this.file = file;
  -    this.error = error;
  -    this.startline = startline;
  -    this.startcolumn = startcolumn;
  -    this.endline = endline;
  -    this.endcolumn = endcolumn;
  -    this.message = message;
  -  }
  -
  -  /**
  -   * Return the filename associated with this compiler error.
  -   *
  -   * @return The filename associated with this compiler error
  -   */
  -  public String getFile() {
  -    return file;
  -  }
  -
  -  /**
  -   * Assert whether this is a severe error or a warning
  -   *
  -   * @return Whether the error is severe
  -   */
  -  public boolean isError() {
  -    return error;
  -  }
  -
  -  /**
  -   * Return the starting line number of the program text originating this error
  -   *
  -   * @return The starting line number of the program text originating this error
  -   */
  -  public int getStartLine() {
  -    return startline;
  -  }
  -
  -  /**
  -   * Return the starting column number of the program text originating this
  -   * error
  -   *
  -   * @return The starting column number of the program text originating this
  -   * error
  -   */
  -  public int getStartColumn() {
  -    return startcolumn;
  -  }
  -
  -  /**
  -   * Return the ending line number of the program text originating this error
  -   *
  -   * @return The ending line number of the program text originating this error
  -   */
  -  public int getEndLine() {
  -    return endline;
  -  }
  -
  -  /**
  -   * Return the ending column number of the program text originating this
  -   * error
  -   *
  -   * @return The ending column number of the program text originating this
  -   * error
  -   */
  -  public int getEndColumn() {
  -    return endcolumn;
  -  }
  -
  -  /**
  -   * Return the message produced by the language processor
  -   *
  -   * @return The message produced by the language processor
  -   */
  -  public String getMessage() {
  -    return message;
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  +
  +/**
  + * This class encapsulates an error message produced by a programming language
  + * processor (whether interpreted or compiled)
  + * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:39 $
  + * @since 2.0
  + */
  +
  +public class CompilerError {
  +  /**
  +   * Is this a severe error or a warning?
  +   */
  +  private boolean error;
  +  /**
  +   * The start line number of the offending program text
  +   */
  +  private int startline;
  +  /**
  +   * The start column number of the offending program text
  +   */
  +  private int startcolumn;
  +  /**
  +   * The end line number of the offending program text
  +   */
  +  private int endline;
  +  /**
  +   * The end column number of the offending program text
  +   */
  +  private int endcolumn;
  +  /**
  +   * The name of the file containing the offending program text
  +   */
  +  private String file;
  +  /**
  +   * The actual error text produced by the language processor
  +   */
  +  private String message;
  +    
  +  /**
  +   * The error message constructor.
  +   *
  +   * @param file The name of the file containing the offending program text
  +   * @param error The actual error text produced by the language processor
  +   * @param startline The start line number of the offending program text
  +   * @param startcolumn The start column number of the offending program text
  +   * @param endline The end line number of the offending program text
  +   * @param endcolumn The end column number of the offending program text
  +   * @param message The actual error text produced by the language processor
  +   */
  +  public CompilerError(
  +    String file,
  +    boolean error,
  +    int startline,
  +    int startcolumn,
  +    int endline,
  +    int endcolumn,
  +    String message
  +  ) 
  +  {
  +    this.file = file;
  +    this.error = error;
  +    this.startline = startline;
  +    this.startcolumn = startcolumn;
  +    this.endline = endline;
  +    this.endcolumn = endcolumn;
  +    this.message = message;
  +  }
  +
  +  /**
  +   * Return the filename associated with this compiler error.
  +   *
  +   * @return The filename associated with this compiler error
  +   */
  +  public String getFile() {
  +    return file;
  +  }
  +
  +  /**
  +   * Assert whether this is a severe error or a warning
  +   *
  +   * @return Whether the error is severe
  +   */
  +  public boolean isError() {
  +    return error;
  +  }
  +
  +  /**
  +   * Return the starting line number of the program text originating this error
  +   *
  +   * @return The starting line number of the program text originating this error
  +   */
  +  public int getStartLine() {
  +    return startline;
  +  }
  +
  +  /**
  +   * Return the starting column number of the program text originating this
  +   * error
  +   *
  +   * @return The starting column number of the program text originating this
  +   * error
  +   */
  +  public int getStartColumn() {
  +    return startcolumn;
  +  }
  +
  +  /**
  +   * Return the ending line number of the program text originating this error
  +   *
  +   * @return The ending line number of the program text originating this error
  +   */
  +  public int getEndLine() {
  +    return endline;
  +  }
  +
  +  /**
  +   * Return the ending column number of the program text originating this
  +   * error
  +   *
  +   * @return The ending column number of the program text originating this
  +   * error
  +   */
  +  public int getEndColumn() {
  +    return endcolumn;
  +  }
  +
  +  /**
  +   * Return the message produced by the language processor
  +   *
  +   * @return The message produced by the language processor
  +   */
  +  public String getMessage() {
  +    return message;
  +  }
  +}
  
  
  
  1.1.2.3   +80 -80    xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/LanguageCompiler.java
  
  Index: LanguageCompiler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/LanguageCompiler.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- LanguageCompiler.java	2000/07/11 03:09:46	1.1.2.2
  +++ LanguageCompiler.java	2000/07/22 20:41:39	1.1.2.3
  @@ -1,80 +1,80 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  -
  -import java.util.Vector;
  -import org.apache.avalon.Component;
  -
  -import java.io.IOException;
  -
  -/**
  - * This interface defines a compiler's functionality for all
  - * (Java-based) compiled languages
  - * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:09:46 $
  - * @since 2.0
  - */
  -public interface LanguageCompiler extends Component {
  -  /**
  -   * Set the name of the file containing the source program
  -   *
  -   * @param file The name of the file containing the source program
  -   */
  -  void setFile(String file);
  -
  -  /**
  -   * Set the name of the directory containing the source program file
  -   *
  -   * @param srcDir The name of the directory containing the source program file
  -   */
  -  void setSource(String srcDir);
  -
  -  /**
  -   * Set the name of the directory to contain the resulting object program file
  -   *
  -   * @param destDir The name of the directory to contain the resulting object
  -   * program file
  -   */
  -  void setDestination(String destDir);
  -
  -  /**
  -   * Set the classpath to be used for this compilation
  -   *
  -   * @param classpath The classpath to be used for this compilation
  -   */
  -  void setClasspath(String classpath);
  -
  -  /**
  -   * Set the encoding of the input source file or <code>null</code> to use the
  -   * platform's default encoding
  -   *
  -   * @param encoding The encoding of the input source file or <code>null</code>
  -   * to use the platform's default encoding
  -   */
  -  void setEncoding(String encoding);
  -
  -  /**
  -   * Compile a source file yielding a loadable program file.
  -   *
  -   * @param filename The object program base file name
  -   * @param baseDirectory The directory containing the object program file
  -   * @param encoding The encoding expected in the source file or
  -   * <code>null</code> if it is the platform's default encoding
  -   * @exception LanguageException If an error occurs during compilation
  -   */
  -  boolean compile() throws IOException;
  -
  -  /**
  -   * Return the list of errors generated by this compilation
  -   *
  -   * @return The list of errors generated by this compilation
  -   * @exception IOException If an error occurs during message collection
  -   */
  -  Vector getErrors() throws IOException;
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  +
  +import java.util.Vector;
  +import org.apache.avalon.Component;
  +
  +import java.io.IOException;
  +
  +/**
  + * This interface defines a compiler's functionality for all
  + * (Java-based) compiled languages
  + * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:39 $
  + * @since 2.0
  + */
  +public interface LanguageCompiler extends Component {
  +  /**
  +   * Set the name of the file containing the source program
  +   *
  +   * @param file The name of the file containing the source program
  +   */
  +  void setFile(String file);
  +
  +  /**
  +   * Set the name of the directory containing the source program file
  +   *
  +   * @param srcDir The name of the directory containing the source program file
  +   */
  +  void setSource(String srcDir);
  +
  +  /**
  +   * Set the name of the directory to contain the resulting object program file
  +   *
  +   * @param destDir The name of the directory to contain the resulting object
  +   * program file
  +   */
  +  void setDestination(String destDir);
  +
  +  /**
  +   * Set the classpath to be used for this compilation
  +   *
  +   * @param classpath The classpath to be used for this compilation
  +   */
  +  void setClasspath(String classpath);
  +
  +  /**
  +   * Set the encoding of the input source file or <code>null</code> to use the
  +   * platform's default encoding
  +   *
  +   * @param encoding The encoding of the input source file or <code>null</code>
  +   * to use the platform's default encoding
  +   */
  +  void setEncoding(String encoding);
  +
  +  /**
  +   * Compile a source file yielding a loadable program file.
  +   *
  +   * @param filename The object program base file name
  +   * @param baseDirectory The directory containing the object program file
  +   * @param encoding The encoding expected in the source file or
  +   * <code>null</code> if it is the platform's default encoding
  +   * @exception LanguageException If an error occurs during compilation
  +   */
  +  boolean compile() throws IOException;
  +
  +  /**
  +   * Return the list of errors generated by this compilation
  +   *
  +   * @return The list of errors generated by this compilation
  +   * @exception IOException If an error occurs during message collection
  +   */
  +  Vector getErrors() throws IOException;
  +}
  
  
  
  1.1.2.3   +78 -78    xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/ProgrammingLanguage.java
  
  Index: ProgrammingLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/ProgrammingLanguage.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ProgrammingLanguage.java	2000/07/11 03:09:46	1.1.2.2
  +++ ProgrammingLanguage.java	2000/07/22 20:41:39	1.1.2.3
  @@ -1,78 +1,78 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  -
  -import org.apache.avalon.NamedComponent;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * This interface states the functionality of a programming language processor
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:09:46 $
  - */
  -public interface ProgrammingLanguage extends NamedComponent {
  -  /**
  -   * Return the programming language's source file extension
  -   *
  -   * @return The canonical source file extension
  -   */
  -  public String getSourceExtension();
  -
  -  /**
  -   * Load a program from a file
  -   *
  -   * @param filename The program base file name
  -   * @param baseDirectory The directory containing the program file
  -   * @param encoding The encoding expected in the source file or
  -   * <code>null</code> if it is the platform's default encoding
  -   * @return The loaded program
  -   * @exception LanguageException If an error occurs during loading
  -   */
  -  public Object load(String filename, String baseDirectory, String encoding)
  -    throws LanguageException;
  -
  -  /**
  -   * Create a new instance for the given program type
  -   *
  -   * @param program The program type
  -   * @return A new program type instance
  -   * @exception LanguageException If an instantiation error occurs
  -   */
  -  public Object instantiate(Object program) throws LanguageException;
  -
  -  /**
  -   * Unload from memory and invalidate a given program
  -   *
  -   * @param program The program
  -   * @param filename The name of the file this program was loaded from
  -   * @param baseDirectory The directory containing the program file
  -   * @exception LanguageException If an error occurs
  -   */
  -  public void unload (Object program, String filename, String baseDirectory)
  -    throws LanguageException;
  -
  -  /**
  -   * Return the <code>CodeFormatter</code> associated with this programming
  -   * language
  -   *
  -   * @return The code formatter object or <code>null</code> if none is
  -   * available
  -   */
  -  public CodeFormatter getCodeFormatter();
  -
  -  /**
  -   * Escape a <code>String</code> according to the programming language's
  -   * string constant encoding rules.
  -   *
  -   * @param constant The string to be escaped
  -   * @return The escaped string
  -   */
  -  public String quoteString(String constant);
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming;
  +
  +import org.apache.avalon.NamedComponent;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * This interface states the functionality of a programming language processor
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:39 $
  + */
  +public interface ProgrammingLanguage extends NamedComponent {
  +  /**
  +   * Return the programming language's source file extension
  +   *
  +   * @return The canonical source file extension
  +   */
  +  public String getSourceExtension();
  +
  +  /**
  +   * Load a program from a file
  +   *
  +   * @param filename The program base file name
  +   * @param baseDirectory The directory containing the program file
  +   * @param encoding The encoding expected in the source file or
  +   * <code>null</code> if it is the platform's default encoding
  +   * @return The loaded program
  +   * @exception LanguageException If an error occurs during loading
  +   */
  +  public Object load(String filename, String baseDirectory, String encoding)
  +    throws LanguageException;
  +
  +  /**
  +   * Create a new instance for the given program type
  +   *
  +   * @param program The program type
  +   * @return A new program type instance
  +   * @exception LanguageException If an instantiation error occurs
  +   */
  +  public Object instantiate(Object program) throws LanguageException;
  +
  +  /**
  +   * Unload from memory and invalidate a given program
  +   *
  +   * @param program The program
  +   * @param filename The name of the file this program was loaded from
  +   * @param baseDirectory The directory containing the program file
  +   * @exception LanguageException If an error occurs
  +   */
  +  public void unload (Object program, String filename, String baseDirectory)
  +    throws LanguageException;
  +
  +  /**
  +   * Return the <code>CodeFormatter</code> associated with this programming
  +   * language
  +   *
  +   * @return The code formatter object or <code>null</code> if none is
  +   * available
  +   */
  +  public CodeFormatter getCodeFormatter();
  +
  +  /**
  +   * Escape a <code>String</code> according to the programming language's
  +   * string constant encoding rules.
  +   *
  +   * @param constant The string to be escaped
  +   * @return The escaped string
  +   */
  +  public String quoteString(String constant);
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +172 -172  xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/AbstractJavaCompiler.java
  
  Index: AbstractJavaCompiler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/AbstractJavaCompiler.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AbstractJavaCompiler.java	2000/07/11 03:09:49	1.1.2.2
  +++ AbstractJavaCompiler.java	2000/07/22 20:41:40	1.1.2.3
  @@ -1,172 +1,172 @@
  -/**
  -* ***************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.*;
  -import java.util.*;
  -import org.apache.avalon.*;
  -
  -import org.apache.cocoon.components.language.programming.*;
  -
  -/**
  - * This class implements the functionality common to all Java compilers.
  - * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:09:49 $
  - * @since 2.0
  - */
  -public abstract class AbstractJavaCompiler implements LanguageCompiler {
  -  /**
  -   * The source program filename
  -   */
  -  protected String    file;
  -  /**
  -   * The name of the directory containing the source program file
  -   */
  -  protected String    srcDir;
  -  /**
  -   * The name of the directory to contain the resulting object program file
  -   */
  -  protected String    destDir;
  -  /**
  -   * The classpath to be used for compilation
  -   */
  -  protected String    classpath;
  -  /**
  -   * The encoding of the source program or <code>null</code> to use the
  -   * platform's default encoding
  -   */
  -  protected String    encoding = null;
  -  /**
  -   * The input stream to output compilation errors
  -   */
  -  protected InputStream errors;
  -
  -  /**
  -   * Set the name of the file containing the source program
  -   *
  -   * @param file The name of the file containing the source program
  -   */
  -  public void setFile(String file) {
  -    this.file = file;
  -  } 
  -
  -  /**
  -   * Set the name of the directory containing the source program file
  -   *
  -   * @param srcDir The name of the directory containing the source program file
  -   */
  -  public void setSource(String srcDir) {
  -    this.srcDir = srcDir;
  -  } 
  -
  -  /**
  -   * Set the name of the directory to contain the resulting object program file
  -   *
  -   * @param destDir The name of the directory to contain the resulting object
  -   * program file
  -   */
  -  public void setDestination(String destDir) {
  -    this.destDir = destDir;
  -  } 
  -
  -  /**
  -   * Set the classpath to be used for this compilation
  -   *
  -   * @param classpath The classpath to be used for this compilation
  -   */
  -  public void setClasspath(String classpath) {
  -    this.classpath = classpath;
  -  } 
  -
  -  /**
  -   * Set the encoding of the input source file or <code>null</code> to use the
  -   * platform's default encoding
  -   *
  -   * @param encoding The encoding of the input source file or <code>null</code>
  -   * to use the platform's default encoding
  -   */
  -  public void setEncoding(String encoding) {
  -    this.encoding = encoding;
  -  } 
  -
  -  /**
  -   * Return the list of errors generated by this compilation
  -   *
  -   * @return The list of errors generated by this compilation
  -   * @exception IOException If an error occurs during message collection
  -   */
  -  public Vector getErrors() throws IOException {
  -    return parseStream(new BufferedReader(new InputStreamReader(errors)));
  -  } 
  -
  -  /**
  -   * Parse the compiler error stream to produce a list of
  -   * <code>CompilerError</code>s
  -   *
  -   * @param errors The error stream
  -   * @return The list of compiler error messages
  -   * @exception IOException If an error occurs during message collection
  -   */
  -  protected abstract Vector parseStream(BufferedReader errors) 
  -      throws IOException;
  -
  -  /**
  -   * Fill the arguments taken by the Java compiler
  -   *
  -   * @param argument The list of compilation arguments
  -   * @return The prepared list of compilation arguments
  -   */
  -  protected Vector fillArguments(Vector arguments) {
  -    // destination directory
  -    arguments.addElement("-d");
  -    arguments.addElement(destDir);
  -
  -    // classpath
  -    arguments.addElement("-classpath");
  -
  -    if (System.getProperty("java.version").startsWith("1.1")) {
  -      arguments.addElement(classpath + File.pathSeparator + srcDir);
  -    } else {
  -      arguments.addElement(classpath);
  -      arguments.addElement("-sourcepath");
  -      arguments.addElement(srcDir);
  -    } 
  -
  -    // add optimization (for what is worth)
  -    arguments.addElement("-O");
  -
  -    // add encoding if set
  -    if (encoding != null) {
  -      arguments.addElement("-encoding");
  -      arguments.addElement(encoding);
  -    } 
  -
  -    return arguments;
  -  } 
  -
  -  /**
  -   * Copy arguments to a string array
  -   *
  -   * @param arguments The compiler arguments
  -   * @return A string array containing compilation arguments
  -   */
  -  protected String[] toStringArray(Vector arguments) {
  -    int    i;
  -    String[] args = new String[arguments.size() + 1];
  -
  -    for (i = 0; i < arguments.size(); i++) {
  -      args[i] = (String) arguments.elementAt(i);
  -    } 
  -
  -    args[i] = file;
  -
  -    return args;
  -  } 
  -}
  +/**
  +* ***************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.*;
  +import java.util.*;
  +import org.apache.avalon.*;
  +
  +import org.apache.cocoon.components.language.programming.*;
  +
  +/**
  + * This class implements the functionality common to all Java compilers.
  + * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:40 $
  + * @since 2.0
  + */
  +public abstract class AbstractJavaCompiler implements LanguageCompiler {
  +  /**
  +   * The source program filename
  +   */
  +  protected String    file;
  +  /**
  +   * The name of the directory containing the source program file
  +   */
  +  protected String    srcDir;
  +  /**
  +   * The name of the directory to contain the resulting object program file
  +   */
  +  protected String    destDir;
  +  /**
  +   * The classpath to be used for compilation
  +   */
  +  protected String    classpath;
  +  /**
  +   * The encoding of the source program or <code>null</code> to use the
  +   * platform's default encoding
  +   */
  +  protected String    encoding = null;
  +  /**
  +   * The input stream to output compilation errors
  +   */
  +  protected InputStream errors;
  +
  +  /**
  +   * Set the name of the file containing the source program
  +   *
  +   * @param file The name of the file containing the source program
  +   */
  +  public void setFile(String file) {
  +    this.file = file;
  +  } 
  +
  +  /**
  +   * Set the name of the directory containing the source program file
  +   *
  +   * @param srcDir The name of the directory containing the source program file
  +   */
  +  public void setSource(String srcDir) {
  +    this.srcDir = srcDir;
  +  } 
  +
  +  /**
  +   * Set the name of the directory to contain the resulting object program file
  +   *
  +   * @param destDir The name of the directory to contain the resulting object
  +   * program file
  +   */
  +  public void setDestination(String destDir) {
  +    this.destDir = destDir;
  +  } 
  +
  +  /**
  +   * Set the classpath to be used for this compilation
  +   *
  +   * @param classpath The classpath to be used for this compilation
  +   */
  +  public void setClasspath(String classpath) {
  +    this.classpath = classpath;
  +  } 
  +
  +  /**
  +   * Set the encoding of the input source file or <code>null</code> to use the
  +   * platform's default encoding
  +   *
  +   * @param encoding The encoding of the input source file or <code>null</code>
  +   * to use the platform's default encoding
  +   */
  +  public void setEncoding(String encoding) {
  +    this.encoding = encoding;
  +  } 
  +
  +  /**
  +   * Return the list of errors generated by this compilation
  +   *
  +   * @return The list of errors generated by this compilation
  +   * @exception IOException If an error occurs during message collection
  +   */
  +  public Vector getErrors() throws IOException {
  +    return parseStream(new BufferedReader(new InputStreamReader(errors)));
  +  } 
  +
  +  /**
  +   * Parse the compiler error stream to produce a list of
  +   * <code>CompilerError</code>s
  +   *
  +   * @param errors The error stream
  +   * @return The list of compiler error messages
  +   * @exception IOException If an error occurs during message collection
  +   */
  +  protected abstract Vector parseStream(BufferedReader errors) 
  +      throws IOException;
  +
  +  /**
  +   * Fill the arguments taken by the Java compiler
  +   *
  +   * @param argument The list of compilation arguments
  +   * @return The prepared list of compilation arguments
  +   */
  +  protected Vector fillArguments(Vector arguments) {
  +    // destination directory
  +    arguments.addElement("-d");
  +    arguments.addElement(destDir);
  +
  +    // classpath
  +    arguments.addElement("-classpath");
  +
  +    if (System.getProperty("java.version").startsWith("1.1")) {
  +      arguments.addElement(classpath + File.pathSeparator + srcDir);
  +    } else {
  +      arguments.addElement(classpath);
  +      arguments.addElement("-sourcepath");
  +      arguments.addElement(srcDir);
  +    } 
  +
  +    // add optimization (for what is worth)
  +    arguments.addElement("-O");
  +
  +    // add encoding if set
  +    if (encoding != null) {
  +      arguments.addElement("-encoding");
  +      arguments.addElement(encoding);
  +    } 
  +
  +    return arguments;
  +  } 
  +
  +  /**
  +   * Copy arguments to a string array
  +   *
  +   * @param arguments The compiler arguments
  +   * @return A string array containing compilation arguments
  +   */
  +  protected String[] toStringArray(Vector arguments) {
  +    int    i;
  +    String[] args = new String[arguments.size() + 1];
  +
  +    for (i = 0; i < arguments.size(); i++) {
  +      args[i] = (String) arguments.elementAt(i);
  +    } 
  +
  +    args[i] = file;
  +
  +    return args;
  +  } 
  +}
  
  
  
  1.1.2.3   +240 -240  xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JavaLanguage.java
  
  Index: JavaLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JavaLanguage.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- JavaLanguage.java	2000/07/11 03:09:50	1.1.2.2
  +++ JavaLanguage.java	2000/07/22 20:41:40	1.1.2.3
  @@ -1,240 +1,240 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.File;
  -import java.util.Vector;
  -
  -import org.apache.avalon.utils.Parameters;
  -
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.Component;
  -import org.apache.avalon.ComponentManager;
  -
  -import org.apache.cocoon.components.classloader.ClassLoaderManager;
  -
  -import org.apache.cocoon.components.language.programming.*;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * The Java programming language processor
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:09:50 $
  - */
  -public class JavaLanguage extends CompiledProgrammingLanguage {
  -  /** The class loader */
  -  ClassLoaderManager classLoaderManager;
  -
  -  /**
  -   * Return the language name
  -   *
  -   * @return The language name
  -   */
  -  public String getName() {
  -    return "java";
  -  }
  -
  -  /**
  -   * Return the language's canonical source file extension.
  -   *
  -   * @return The source file extension
  -   */
  -  public String getSourceExtension() {
  -    return "java";
  -  }
  -
  -  /**
  -   * Return the language's canonical object file extension.
  -   *
  -   * @return The object file extension
  -   */
  -  public String getObjectExtension() {
  -    return "class";
  -  }
  -
  -  /**
  -   * Set the configuration parameters. This method instantiates the
  -   * sitemap-specified <code>ClassLoaderManager</code>
  -   *
  -   * @param params The configuration parameters
  -   * @exception Exception If the class loader manager cannot be instantiated
  -   */
  -  protected void setParameters(Parameters params) throws Exception {
  -    super.setParameters(params);
  -
  -    String compilerClass = params.getParameter("class-loader", null);
  -    if (compilerClass != null) {
  -      this.classLoaderManager = (ClassLoaderManager)
  -        this.getClass().getClassLoader().loadClass(compilerClass).newInstance();
  -    }
  -  }
  -
  -  /**
  -   * Set the global component manager. This methods initializes the class
  -   * loader manager if it was not (successfully) specified in the language
  -   * parameters
  -   *
  -   * @param manager The global component manager
  -   */
  -  public void setComponentManager(ComponentManager manager) {
  -    super.setComponentManager(manager);
  -
  -    if (this.classLoaderManager == null) {
  -      this.classLoaderManager =
  -        (ClassLoaderManager) this.manager.getComponent("class-loader");
  -    }
  -  }
  -
  -  /**
  -   * Actually load an object program from a class file.
  -   *
  -   * @param filename The object program base file name
  -   * @param baseDirectory The directory containing the object program file
  -   * @return The loaded object program
  -   * @exception LanguageException If an error occurs during loading
  -   */
  -  protected Object loadProgram(String name, String baseDirectory)
  -    throws LanguageException
  -  {
  -    try {
  -      this.classLoaderManager.addDirectory(baseDirectory); 
  -      return
  -        this.classLoaderManager.loadClass(name.replace(File.separatorChar, '.'));
  -    } catch (Exception e) {
  -      throw new LanguageException(e.getMessage());
  -    }
  -  }
  -
  -  /**
  -   * Compile a source file yielding a loadable class file.
  -   *
  -   * @param filename The object program base file name
  -   * @param baseDirectory The directory containing the object program file
  -   * @param encoding The encoding expected in the source file or
  -   * <code>null</code> if it is the platform's default encoding
  -   * @exception LanguageException If an error occurs during compilation
  -   */
  -  protected void compile(
  -    String name, String baseDirectory, String encoding
  -  ) throws LanguageException {
  -
  -    try {
  -      AbstractJavaCompiler compiler =
  -        (AbstractJavaCompiler) this.compilerClass.newInstance();
  -  
  -      int pos = name.lastIndexOf(File.separatorChar);
  -      String filename = name.substring(pos + 1);
  -      String pathname =
  -        baseDirectory + File.separator +
  -        name.substring(0, pos).replace(File.separatorChar, '/');
  -  
  -      compiler.setFile(
  -        pathname + File.separator +
  -        filename + "." + this.getSourceExtension()
  -      );
  -  
  -      compiler.setSource(pathname);
  -  
  -      compiler.setDestination(baseDirectory);
  -  
  -      compiler.setClasspath(
  -        System.getProperty("java.class.path") + File.pathSeparator +
  -        baseDirectory
  -      );
  -  
  -      if (encoding != null) {
  -        compiler.setEncoding(encoding);
  -      }
  -  
  -      if (!compiler.compile()) {
  -        StringBuffer message =
  -          new StringBuffer("Error compiling " + filename + ":\n");
  -  
  -        Vector errors = compiler.getErrors();
  -        int count = errors.size();
  -        for (int i = 0; i < count; i++) {
  -          CompilerError error = (CompilerError) errors.elementAt(i);
  -          message.append(
  -  	  "Line " + error.getStartLine() +
  -  	  ", column " + error.getStartColumn() +
  -  	  ": " + error.getMessage()
  -          );
  -        }
  -  
  -        throw new LanguageException(message.toString());
  -      }
  -    } catch (Exception e) {
  -e.printStackTrace();
  -      throw new LanguageException(e.getMessage());
  -    }
  -  }
  -
  -  /**
  -   * Create a new instance for the given class
  -   *
  -   * @param program The Java class
  -   * @return A new class instance
  -   * @exception LanguageException If an instantiation error occurs
  -   */
  -  public Object instantiate(Object program) throws LanguageException {
  -    try {
  -      return ((Class) program).newInstance();
  -    } catch (Exception e) {
  -      throw new LanguageException(e.getMessage());
  -    }
  -  }
  -
  -  /**
  -   * Unload a previously loaded class. This method simply reinstantiates the
  -   * class loader to ensure that a new version of the same class will be
  -   * correctly loaded in a future loading operation
  -   *
  -   * @param program A previously loaded class
  -   * @exception LanguageException If an error occurs during unloading
  -   */
  -  public void doUnload(Object program) throws LanguageException {
  -    this.classLoaderManager.reinstantiate();
  -  }
  -
  -  /**
  -   * Escape a <code>String</code> according to the Java string constant
  -   * encoding rules.
  -   *
  -   * @param constant The string to be escaped
  -   * @return The escaped string
  -   */
  -  public String quoteString(String constant) {
  -    char chr[] = constant.toCharArray();
  -    StringBuffer buffer = new StringBuffer();
  -
  -    for (int i = 0; i < chr.length; i++) {
  -      switch (chr[i]) {
  -        case '\t':
  -          buffer.append("\\t");
  -          break;
  -        case '\r':
  -          buffer.append("\\r");
  -          break;
  -        case '\n':
  -          buffer.append("\\n");
  -          break;
  -        case '"':
  -	case '\\':
  -          buffer.append('\\');
  -          // Fall through
  -        default:
  -          buffer.append(chr[i]);
  -          break;
  -      }
  -    }
  -
  -    return buffer.toString();
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.File;
  +import java.util.Vector;
  +
  +import org.apache.avalon.utils.Parameters;
  +
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.Component;
  +import org.apache.avalon.ComponentManager;
  +
  +import org.apache.cocoon.components.classloader.ClassLoaderManager;
  +
  +import org.apache.cocoon.components.language.programming.*;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * The Java programming language processor
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:40 $
  + */
  +public class JavaLanguage extends CompiledProgrammingLanguage {
  +  /** The class loader */
  +  ClassLoaderManager classLoaderManager;
  +
  +  /**
  +   * Return the language name
  +   *
  +   * @return The language name
  +   */
  +  public String getName() {
  +    return "java";
  +  }
  +
  +  /**
  +   * Return the language's canonical source file extension.
  +   *
  +   * @return The source file extension
  +   */
  +  public String getSourceExtension() {
  +    return "java";
  +  }
  +
  +  /**
  +   * Return the language's canonical object file extension.
  +   *
  +   * @return The object file extension
  +   */
  +  public String getObjectExtension() {
  +    return "class";
  +  }
  +
  +  /**
  +   * Set the configuration parameters. This method instantiates the
  +   * sitemap-specified <code>ClassLoaderManager</code>
  +   *
  +   * @param params The configuration parameters
  +   * @exception Exception If the class loader manager cannot be instantiated
  +   */
  +  protected void setParameters(Parameters params) throws Exception {
  +    super.setParameters(params);
  +
  +    String compilerClass = params.getParameter("class-loader", null);
  +    if (compilerClass != null) {
  +      this.classLoaderManager = (ClassLoaderManager)
  +        this.getClass().getClassLoader().loadClass(compilerClass).newInstance();
  +    }
  +  }
  +
  +  /**
  +   * Set the global component manager. This methods initializes the class
  +   * loader manager if it was not (successfully) specified in the language
  +   * parameters
  +   *
  +   * @param manager The global component manager
  +   */
  +  public void setComponentManager(ComponentManager manager) {
  +    super.setComponentManager(manager);
  +
  +    if (this.classLoaderManager == null) {
  +      this.classLoaderManager =
  +        (ClassLoaderManager) this.manager.getComponent("class-loader");
  +    }
  +  }
  +
  +  /**
  +   * Actually load an object program from a class file.
  +   *
  +   * @param filename The object program base file name
  +   * @param baseDirectory The directory containing the object program file
  +   * @return The loaded object program
  +   * @exception LanguageException If an error occurs during loading
  +   */
  +  protected Object loadProgram(String name, String baseDirectory)
  +    throws LanguageException
  +  {
  +    try {
  +      this.classLoaderManager.addDirectory(baseDirectory); 
  +      return
  +        this.classLoaderManager.loadClass(name.replace(File.separatorChar, '.'));
  +    } catch (Exception e) {
  +      throw new LanguageException(e.getMessage());
  +    }
  +  }
  +
  +  /**
  +   * Compile a source file yielding a loadable class file.
  +   *
  +   * @param filename The object program base file name
  +   * @param baseDirectory The directory containing the object program file
  +   * @param encoding The encoding expected in the source file or
  +   * <code>null</code> if it is the platform's default encoding
  +   * @exception LanguageException If an error occurs during compilation
  +   */
  +  protected void compile(
  +    String name, String baseDirectory, String encoding
  +  ) throws LanguageException {
  +
  +    try {
  +      AbstractJavaCompiler compiler =
  +        (AbstractJavaCompiler) this.compilerClass.newInstance();
  +  
  +      int pos = name.lastIndexOf(File.separatorChar);
  +      String filename = name.substring(pos + 1);
  +      String pathname =
  +        baseDirectory + File.separator +
  +        name.substring(0, pos).replace(File.separatorChar, '/');
  +  
  +      compiler.setFile(
  +        pathname + File.separator +
  +        filename + "." + this.getSourceExtension()
  +      );
  +  
  +      compiler.setSource(pathname);
  +  
  +      compiler.setDestination(baseDirectory);
  +  
  +      compiler.setClasspath(
  +        System.getProperty("java.class.path") + File.pathSeparator +
  +        baseDirectory
  +      );
  +  
  +      if (encoding != null) {
  +        compiler.setEncoding(encoding);
  +      }
  +  
  +      if (!compiler.compile()) {
  +        StringBuffer message =
  +          new StringBuffer("Error compiling " + filename + ":\n");
  +  
  +        Vector errors = compiler.getErrors();
  +        int count = errors.size();
  +        for (int i = 0; i < count; i++) {
  +          CompilerError error = (CompilerError) errors.elementAt(i);
  +          message.append(
  +  	  "Line " + error.getStartLine() +
  +  	  ", column " + error.getStartColumn() +
  +  	  ": " + error.getMessage()
  +          );
  +        }
  +  
  +        throw new LanguageException(message.toString());
  +      }
  +    } catch (Exception e) {
  +e.printStackTrace();
  +      throw new LanguageException(e.getMessage());
  +    }
  +  }
  +
  +  /**
  +   * Create a new instance for the given class
  +   *
  +   * @param program The Java class
  +   * @return A new class instance
  +   * @exception LanguageException If an instantiation error occurs
  +   */
  +  public Object instantiate(Object program) throws LanguageException {
  +    try {
  +      return ((Class) program).newInstance();
  +    } catch (Exception e) {
  +      throw new LanguageException(e.getMessage());
  +    }
  +  }
  +
  +  /**
  +   * Unload a previously loaded class. This method simply reinstantiates the
  +   * class loader to ensure that a new version of the same class will be
  +   * correctly loaded in a future loading operation
  +   *
  +   * @param program A previously loaded class
  +   * @exception LanguageException If an error occurs during unloading
  +   */
  +  public void doUnload(Object program) throws LanguageException {
  +    this.classLoaderManager.reinstantiate();
  +  }
  +
  +  /**
  +   * Escape a <code>String</code> according to the Java string constant
  +   * encoding rules.
  +   *
  +   * @param constant The string to be escaped
  +   * @return The escaped string
  +   */
  +  public String quoteString(String constant) {
  +    char chr[] = constant.toCharArray();
  +    StringBuffer buffer = new StringBuffer();
  +
  +    for (int i = 0; i < chr.length; i++) {
  +      switch (chr[i]) {
  +        case '\t':
  +          buffer.append("\\t");
  +          break;
  +        case '\r':
  +          buffer.append("\\r");
  +          break;
  +        case '\n':
  +          buffer.append("\\n");
  +          break;
  +        case '"':
  +	case '\\':
  +          buffer.append('\\');
  +          // Fall through
  +        default:
  +          buffer.append(chr[i]);
  +          break;
  +      }
  +    }
  +
  +    return buffer.toString();
  +  }
  +}
  
  
  
  1.1.2.2   +100 -100  xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Javac.java
  
  Index: Javac.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Javac.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Javac.java	2000/05/23 23:10:05	1.1.2.1
  +++ Javac.java	2000/07/22 20:41:40	1.1.2.2
  @@ -1,100 +1,100 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.*;
  -import java.util.*;
  -import org.apache.cocoon.components.language.programming.*;
  -
  -/**
  - * This class wraps the Sun's built-in Java compiler.
  - * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:10:05 $
  - * @since 2.0
  - */
  -
  -public class Javac extends AbstractJavaCompiler {
  -  /**
  -   * Compile a source file yielding a loadable class file.
  -   *
  -   * @param filename The object program base file name
  -   * @param baseDirectory The directory containing the object program file
  -   * @param encoding The encoding expected in the source file or
  -   * <code>null</code> if it is the platform's default encoding
  -   * @exception LanguageException If an error occurs during compilation
  -   */
  -  public boolean compile() throws IOException {
  -    ByteArrayOutputStream err = new ByteArrayOutputStream();
  -    sun.tools.javac.Main compiler = new sun.tools.javac.Main(err, "javac");
  -    boolean result =
  -      compiler.compile(toStringArray(fillArguments(new Vector(10))));
  -    this.errors = new ByteArrayInputStream(err.toByteArray());
  -    return result;
  -  }
  -  
  -  /**
  -   * Parse the compiler error stream to produce a list of
  -   * <code>CompilerError</code>s
  -   *
  -   * @param errors The error stream
  -   * @return The list of compiler error messages
  -   * @exception IOException If an error occurs during message collection
  -   */
  -  protected Vector parseStream(BufferedReader input) throws IOException {
  -    Vector errors = null;
  -    String line = null;
  -    StringBuffer buffer = new StringBuffer();
  -
  -    while (true) {
  -      // cleanup the buffer
  -      buffer.delete(0, buffer.length());
  -
  -      // each error has 3 lines
  -      for (int i = 0; i < 3 ; i++) {
  -        if ((line = input.readLine()) == null) return errors;
  -        buffer.append(line);
  -        buffer.append('\n');
  -      }
  -
  -      // if error is found create the vector
  -      if (errors == null) errors = new Vector(10);
  -      
  -      // add the error bean
  -      errors.addElement(parseError(buffer.toString()));
  -    }
  -  }
  -  
  -  /**
  -   * Parse an individual compiler error message
  -   *
  -   * @param error The error text
  -   * @return A mssaged <code>CompilerError</code>
  -   */
  -  private CompilerError parseError(String error) {
  -    StringTokenizer tokens = new StringTokenizer(error, ":");
  -    String file = tokens.nextToken();
  -    int line = Integer.parseInt(tokens.nextToken());
  -    
  -    tokens = new StringTokenizer(tokens.nextToken().trim(), "\n");
  -    String message = tokens.nextToken();
  -    String context = tokens.nextToken();
  -    String pointer = tokens.nextToken();
  -    int startcolumn = pointer.indexOf("^");
  -    int endcolumn = context.indexOf(" ", startcolumn);
  -    if (endcolumn == -1) endcolumn = context.length();
  -    
  -    String type = "error";
  -    
  -    return new CompilerError(srcDir + File.separator + file, type.equals("error"), line, startcolumn, line, endcolumn, message);
  -  }
  -  
  -  public String getStatus() {
  -    return "Sun Classic JavaC";
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.*;
  +import java.util.*;
  +import org.apache.cocoon.components.language.programming.*;
  +
  +/**
  + * This class wraps the Sun's built-in Java compiler.
  + * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:40 $
  + * @since 2.0
  + */
  +
  +public class Javac extends AbstractJavaCompiler {
  +  /**
  +   * Compile a source file yielding a loadable class file.
  +   *
  +   * @param filename The object program base file name
  +   * @param baseDirectory The directory containing the object program file
  +   * @param encoding The encoding expected in the source file or
  +   * <code>null</code> if it is the platform's default encoding
  +   * @exception LanguageException If an error occurs during compilation
  +   */
  +  public boolean compile() throws IOException {
  +    ByteArrayOutputStream err = new ByteArrayOutputStream();
  +    sun.tools.javac.Main compiler = new sun.tools.javac.Main(err, "javac");
  +    boolean result =
  +      compiler.compile(toStringArray(fillArguments(new Vector(10))));
  +    this.errors = new ByteArrayInputStream(err.toByteArray());
  +    return result;
  +  }
  +  
  +  /**
  +   * Parse the compiler error stream to produce a list of
  +   * <code>CompilerError</code>s
  +   *
  +   * @param errors The error stream
  +   * @return The list of compiler error messages
  +   * @exception IOException If an error occurs during message collection
  +   */
  +  protected Vector parseStream(BufferedReader input) throws IOException {
  +    Vector errors = null;
  +    String line = null;
  +    StringBuffer buffer = new StringBuffer();
  +
  +    while (true) {
  +      // cleanup the buffer
  +      buffer.delete(0, buffer.length());
  +
  +      // each error has 3 lines
  +      for (int i = 0; i < 3 ; i++) {
  +        if ((line = input.readLine()) == null) return errors;
  +        buffer.append(line);
  +        buffer.append('\n');
  +      }
  +
  +      // if error is found create the vector
  +      if (errors == null) errors = new Vector(10);
  +      
  +      // add the error bean
  +      errors.addElement(parseError(buffer.toString()));
  +    }
  +  }
  +  
  +  /**
  +   * Parse an individual compiler error message
  +   *
  +   * @param error The error text
  +   * @return A mssaged <code>CompilerError</code>
  +   */
  +  private CompilerError parseError(String error) {
  +    StringTokenizer tokens = new StringTokenizer(error, ":");
  +    String file = tokens.nextToken();
  +    int line = Integer.parseInt(tokens.nextToken());
  +    
  +    tokens = new StringTokenizer(tokens.nextToken().trim(), "\n");
  +    String message = tokens.nextToken();
  +    String context = tokens.nextToken();
  +    String pointer = tokens.nextToken();
  +    int startcolumn = pointer.indexOf("^");
  +    int endcolumn = context.indexOf(" ", startcolumn);
  +    if (endcolumn == -1) endcolumn = context.length();
  +    
  +    String type = "error";
  +    
  +    return new CompilerError(srcDir + File.separator + file, type.equals("error"), line, startcolumn, line, endcolumn, message);
  +  }
  +  
  +  public String getStatus() {
  +    return "Sun Classic JavaC";
  +  }
  +}
  
  
  
  1.1.2.2   +111 -111  xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Jikes.java
  
  Index: Jikes.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Jikes.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Jikes.java	2000/05/23 23:10:06	1.1.2.1
  +++ Jikes.java	2000/07/22 20:41:40	1.1.2.2
  @@ -1,111 +1,111 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.*;
  -import java.util.*;
  -import org.apache.cocoon.components.language.programming.*;
  -
  -/**
  - * This class wraps IBM's <i>Jikes</i> Java compiler
  - * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:10:06 $
  - * @since 2.0
  - */
  -
  -public class Jikes extends AbstractJavaCompiler {
  -  /**
  -  * Compile a source file yielding a loadable class file.
  -  *
  -  * @param filename The object program base file name
  -  * @param baseDirectory The directory containing the object program file
  -  * @param encoding The encoding expected in the source file or
  -  * <code>null</code> if it is the platform's default encoding
  -  * @exception LanguageException If an error occurs during compilation
  -  */
  -   public boolean compile() throws IOException {
  -      Vector args = new Vector(12);
  -      // command line name
  -      args.add("jikes");
  -      // indicate Emacs output mode must be used
  -      args.add("+D");
  -
  -      Process p = Runtime.getRuntime().exec(toStringArray(fillArguments(args)));
  -
  -      errors = p.getInputStream();
  -      
  -      try {
  -        p.waitFor();
  -        return (p.exitValue() == 0);
  -      } catch(InterruptedException somethingHappened) {
  -        return false;
  -      }
  -   }
  -   
  -  /**
  -   * Parse the compiler error stream to produce a list of
  -   * <code>CompilerError</code>s
  -   *
  -   * @param errors The error stream
  -   * @return The list of compiler error messages
  -   * @exception IOException If an error occurs during message collection
  -   */
  -   protected Vector parseStream(BufferedReader input) throws IOException {
  -      Vector errors = null;
  -      String line = null;
  -      StringBuffer buffer = new StringBuffer();
  -
  -      while (true) {
  -        // cleanup the buffer
  -        buffer.delete(0, buffer.length());
  -
  -        // first line is not space-starting        
  -        if (line == null) line = input.readLine();
  -        if (line == null) return errors;
  -        buffer.append(line);
  -
  -        // all other space-starting lines are one error
  -        while (true) {        
  -           line = input.readLine();
  -           if ((line == null) || (line.charAt(0) != ' ')) break;
  -           buffer.append(line);
  -           buffer.append('\n');
  -        }
  -        
  -        // if error is found create the vector
  -        if (errors == null) errors = new Vector(10);
  -        
  -        // add the error bean
  -        errors.addElement(parseError(buffer.toString()));
  -      }
  -   }
  -   
  -  /**
  -   * Parse an individual compiler error message
  -   *
  -   * @param error The error text
  -   * @return A mssaged <code>CompilerError</code>
  -   */
  -   private CompilerError parseError(String error) {
  -      StringTokenizer tokens = new StringTokenizer(error, ":");
  -      String file = tokens.nextToken();
  -      int startline = Integer.parseInt(tokens.nextToken());
  -      int startcolumn = Integer.parseInt(tokens.nextToken());
  -      int endline = Integer.parseInt(tokens.nextToken());
  -      int endcolumn = Integer.parseInt(tokens.nextToken());
  -      String type = tokens.nextToken().trim().toLowerCase();
  -      String message = tokens.nextToken().trim();
  -      
  -      return new CompilerError(file, type.equals("error"), startline, startcolumn, endline, endcolumn, message);
  -   }
  -   
  -   public String getStatus() {
  -      return "IBM Jikes";
  -   }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.*;
  +import java.util.*;
  +import org.apache.cocoon.components.language.programming.*;
  +
  +/**
  + * This class wraps IBM's <i>Jikes</i> Java compiler
  + * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:40 $
  + * @since 2.0
  + */
  +
  +public class Jikes extends AbstractJavaCompiler {
  +  /**
  +  * Compile a source file yielding a loadable class file.
  +  *
  +  * @param filename The object program base file name
  +  * @param baseDirectory The directory containing the object program file
  +  * @param encoding The encoding expected in the source file or
  +  * <code>null</code> if it is the platform's default encoding
  +  * @exception LanguageException If an error occurs during compilation
  +  */
  +   public boolean compile() throws IOException {
  +      Vector args = new Vector(12);
  +      // command line name
  +      args.add("jikes");
  +      // indicate Emacs output mode must be used
  +      args.add("+D");
  +
  +      Process p = Runtime.getRuntime().exec(toStringArray(fillArguments(args)));
  +
  +      errors = p.getInputStream();
  +      
  +      try {
  +        p.waitFor();
  +        return (p.exitValue() == 0);
  +      } catch(InterruptedException somethingHappened) {
  +        return false;
  +      }
  +   }
  +   
  +  /**
  +   * Parse the compiler error stream to produce a list of
  +   * <code>CompilerError</code>s
  +   *
  +   * @param errors The error stream
  +   * @return The list of compiler error messages
  +   * @exception IOException If an error occurs during message collection
  +   */
  +   protected Vector parseStream(BufferedReader input) throws IOException {
  +      Vector errors = null;
  +      String line = null;
  +      StringBuffer buffer = new StringBuffer();
  +
  +      while (true) {
  +        // cleanup the buffer
  +        buffer.delete(0, buffer.length());
  +
  +        // first line is not space-starting        
  +        if (line == null) line = input.readLine();
  +        if (line == null) return errors;
  +        buffer.append(line);
  +
  +        // all other space-starting lines are one error
  +        while (true) {        
  +           line = input.readLine();
  +           if ((line == null) || (line.charAt(0) != ' ')) break;
  +           buffer.append(line);
  +           buffer.append('\n');
  +        }
  +        
  +        // if error is found create the vector
  +        if (errors == null) errors = new Vector(10);
  +        
  +        // add the error bean
  +        errors.addElement(parseError(buffer.toString()));
  +      }
  +   }
  +   
  +  /**
  +   * Parse an individual compiler error message
  +   *
  +   * @param error The error text
  +   * @return A mssaged <code>CompilerError</code>
  +   */
  +   private CompilerError parseError(String error) {
  +      StringTokenizer tokens = new StringTokenizer(error, ":");
  +      String file = tokens.nextToken();
  +      int startline = Integer.parseInt(tokens.nextToken());
  +      int startcolumn = Integer.parseInt(tokens.nextToken());
  +      int endline = Integer.parseInt(tokens.nextToken());
  +      int endcolumn = Integer.parseInt(tokens.nextToken());
  +      String type = tokens.nextToken().trim().toLowerCase();
  +      String message = tokens.nextToken().trim();
  +      
  +      return new CompilerError(file, type.equals("error"), startline, startcolumn, endline, endcolumn, message);
  +   }
  +   
  +   public String getStatus() {
  +      return "IBM Jikes";
  +   }
  +}
  
  
  
  1.1.2.2   +103 -103  xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JstyleFormatter.java
  
  Index: JstyleFormatter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JstyleFormatter.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- JstyleFormatter.java	2000/05/23 23:10:07	1.1.2.1
  +++ JstyleFormatter.java	2000/07/22 20:41:41	1.1.2.2
  @@ -1,103 +1,103 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.PrintWriter;
  -import java.io.StringReader;
  -import java.io.BufferedReader;
  -import java.io.ByteArrayOutputStream;
  -import java.io.UnsupportedEncodingException;
  -
  -import jstyle.JSFormatter;
  -import jstyle.JSBeautifier;
  -
  -import org.apache.cocoon.components.language.programming.*;
  -
  -/**
  - * This class implements <code>CodeFormatter</code> based on
  - * Tal Davidson's (davidsont@bigfoot.com) <i>Jstyle</i> Java
  - * beautifier. This implementation is very improvised...
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:10:07 $
  - */
  -public class JstyleFormatter implements CodeFormatter {
  -  /**
  -   * The default preferred line length. Should be parametrized!
  -   */
  -  protected static final int PREFERRED_LINE_LENGTH = 72;
  -  /**
  -   * The default line length deviation. Should be parametrized!
  -   */
  -  protected static final int LINE_LENGTH_DEVIATION = 8;
  -
  -  /**
  -   * The default space indentation. Should be parametrized!
  -   */
  -  protected static final int SPACE_INDENTATION = 2;
  -
  -  /**
  -   * Format and beautify a <code>String</code> containing source code.
  -   * This class has 2 pases: one for beautifying and another one for
  -   * indentation. This should be performed in a single step!!!
  -   *
  -   * @param code The input source code
  -   * @param encoding The encoding used for constant strings embedded in the
  -   * source code
  -   * @return The formatted source code
  -   */
  -  public String format(String code, String encoding) {
  -    try {
  -      JSFormatter formatter = new JSFormatter();
  -
  -      formatter.setPreferredLineLength(PREFERRED_LINE_LENGTH);
  -      formatter.setLineLengthDeviation(LINE_LENGTH_DEVIATION);
  -
  -      ByteArrayOutputStream out = new ByteArrayOutputStream(code.length());
  -
  -      formatter.format(
  -        new BufferedReader(new StringReader(code)), new PrintWriter(out, true)
  -      );
  -
  -      JSBeautifier beautifier = new JSBeautifier();
  -
  -      code = this.getString(out, encoding);
  -
  -      out = new ByteArrayOutputStream(code.length());
  -
  -      beautifier.setSpaceIndentation(SPACE_INDENTATION);
  -
  -      beautifier.beautifyReader(
  -        new BufferedReader(new StringReader(code)), new PrintWriter(out, true)
  -      );
  -
  -      return this.getString(out, encoding);
  -    } catch (Exception e) {
  -      return code;
  -    }
  -  }
  -
  -  /**
  -   * Convert a byte array stream to string according to a given encoding.
  -   * The encoding can be <code>null</code> for the platform's default
  -   * encoding
  -   *
  -   * @param PARAM_NAME Param description
  -   * @return the value
  -   * @exception EXCEPTION_NAME If an error occurs
  -   */
  -  protected String getString(ByteArrayOutputStream out, String encoding)
  -    throws UnsupportedEncodingException
  -  {
  -    if (encoding == null) {
  -      return out.toString();
  -    }
  -
  -    return out.toString(encoding);
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.PrintWriter;
  +import java.io.StringReader;
  +import java.io.BufferedReader;
  +import java.io.ByteArrayOutputStream;
  +import java.io.UnsupportedEncodingException;
  +
  +import jstyle.JSFormatter;
  +import jstyle.JSBeautifier;
  +
  +import org.apache.cocoon.components.language.programming.*;
  +
  +/**
  + * This class implements <code>CodeFormatter</code> based on
  + * Tal Davidson's (davidsont@bigfoot.com) <i>Jstyle</i> Java
  + * beautifier. This implementation is very improvised...
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:41 $
  + */
  +public class JstyleFormatter implements CodeFormatter {
  +  /**
  +   * The default preferred line length. Should be parametrized!
  +   */
  +  protected static final int PREFERRED_LINE_LENGTH = 72;
  +  /**
  +   * The default line length deviation. Should be parametrized!
  +   */
  +  protected static final int LINE_LENGTH_DEVIATION = 8;
  +
  +  /**
  +   * The default space indentation. Should be parametrized!
  +   */
  +  protected static final int SPACE_INDENTATION = 2;
  +
  +  /**
  +   * Format and beautify a <code>String</code> containing source code.
  +   * This class has 2 pases: one for beautifying and another one for
  +   * indentation. This should be performed in a single step!!!
  +   *
  +   * @param code The input source code
  +   * @param encoding The encoding used for constant strings embedded in the
  +   * source code
  +   * @return The formatted source code
  +   */
  +  public String format(String code, String encoding) {
  +    try {
  +      JSFormatter formatter = new JSFormatter();
  +
  +      formatter.setPreferredLineLength(PREFERRED_LINE_LENGTH);
  +      formatter.setLineLengthDeviation(LINE_LENGTH_DEVIATION);
  +
  +      ByteArrayOutputStream out = new ByteArrayOutputStream(code.length());
  +
  +      formatter.format(
  +        new BufferedReader(new StringReader(code)), new PrintWriter(out, true)
  +      );
  +
  +      JSBeautifier beautifier = new JSBeautifier();
  +
  +      code = this.getString(out, encoding);
  +
  +      out = new ByteArrayOutputStream(code.length());
  +
  +      beautifier.setSpaceIndentation(SPACE_INDENTATION);
  +
  +      beautifier.beautifyReader(
  +        new BufferedReader(new StringReader(code)), new PrintWriter(out, true)
  +      );
  +
  +      return this.getString(out, encoding);
  +    } catch (Exception e) {
  +      return code;
  +    }
  +  }
  +
  +  /**
  +   * Convert a byte array stream to string according to a given encoding.
  +   * The encoding can be <code>null</code> for the platform's default
  +   * encoding
  +   *
  +   * @param PARAM_NAME Param description
  +   * @return the value
  +   * @exception EXCEPTION_NAME If an error occurs
  +   */
  +  protected String getString(ByteArrayOutputStream out, String encoding)
  +    throws UnsupportedEncodingException
  +  {
  +    if (encoding == null) {
  +      return out.toString();
  +    }
  +
  +    return out.toString(encoding);
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +82 -82    xml-cocoon/src/org/apache/cocoon/components/language/programming/javascript/Attic/JavascriptLanguage.java
  
  Index: JavascriptLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/javascript/Attic/JavascriptLanguage.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- JavascriptLanguage.java	2000/05/23 23:10:08	1.1.2.1
  +++ JavascriptLanguage.java	2000/07/22 20:41:42	1.1.2.2
  @@ -1,82 +1,82 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.javascript;
  -
  -import java.io.File;
  -
  -import org.mozilla.javascript.*;
  -import org.mozilla.javascript.tools.jsc.Main;
  -
  -import org.apache.cocoon.components.language.programming.java.*;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * The compiled Javascript (Rhino) programming language processor
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/05/23 23:10:08 $
  - */
  -public class JavascriptLanguage extends JavaLanguage
  -{
  -  /**
  -   * Return the language name
  -   *
  -   * @return The language name
  -   */
  -  public String getName() {
  -    return "javascript";
  -  }
  -
  -  /**
  -   * Return the language's canonical source file extension.
  -   *
  -   * @return The source file extension
  -   */
  -  public String getSourceExtension() {
  -    return "js";
  -  }
  -
  -  /**
  -   * Compile a source file yielding a loadable class file.
  -   *
  -   * @param filename The object program base file name
  -   * @param baseDirectory The directory containing the object program file
  -   * @param encoding The encoding expected in the source file or
  -   * <code>null</code> if it is the platform's default encoding
  -   * @exception LanguageException If an error occurs during compilation
  -   */
  -  protected void compile(
  -    String name, String baseDirectory, String encoding
  -  ) throws LanguageException {
  -    try {
  -      Main compiler = (Main) this.compilerClass.newInstance();
  -  
  -      int pos = name.lastIndexOf(File.separatorChar);
  -      String filename = name.substring(pos + 1);
  -      String pathname =
  -        baseDirectory + File.separator +
  -        name.substring(0, pos).replace(File.separatorChar, '/');
  -      String packageName =
  -        name.substring(0, pos).replace(File.separatorChar, '.');
  -  
  -      String[] args = {
  -        "-extends",
  -        "org.apache.cocoon.components.language.markup.xsp.javascript.JSGenerator",
  -        "-nosource",
  -        "-O", "9",
  -        "-package", packageName,
  -        pathname + File.separator + filename + "." + this.getSourceExtension()
  -      };
  -  
  -      compiler.main(args);
  -    } catch (Exception e) {
  -      throw new LanguageException(e.getMessage());
  -    }
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.language.programming.javascript;
  +
  +import java.io.File;
  +
  +import org.mozilla.javascript.*;
  +import org.mozilla.javascript.tools.jsc.Main;
  +
  +import org.apache.cocoon.components.language.programming.java.*;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * The compiled Javascript (Rhino) programming language processor
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:42 $
  + */
  +public class JavascriptLanguage extends JavaLanguage
  +{
  +  /**
  +   * Return the language name
  +   *
  +   * @return The language name
  +   */
  +  public String getName() {
  +    return "javascript";
  +  }
  +
  +  /**
  +   * Return the language's canonical source file extension.
  +   *
  +   * @return The source file extension
  +   */
  +  public String getSourceExtension() {
  +    return "js";
  +  }
  +
  +  /**
  +   * Compile a source file yielding a loadable class file.
  +   *
  +   * @param filename The object program base file name
  +   * @param baseDirectory The directory containing the object program file
  +   * @param encoding The encoding expected in the source file or
  +   * <code>null</code> if it is the platform's default encoding
  +   * @exception LanguageException If an error occurs during compilation
  +   */
  +  protected void compile(
  +    String name, String baseDirectory, String encoding
  +  ) throws LanguageException {
  +    try {
  +      Main compiler = (Main) this.compilerClass.newInstance();
  +  
  +      int pos = name.lastIndexOf(File.separatorChar);
  +      String filename = name.substring(pos + 1);
  +      String pathname =
  +        baseDirectory + File.separator +
  +        name.substring(0, pos).replace(File.separatorChar, '/');
  +      String packageName =
  +        name.substring(0, pos).replace(File.separatorChar, '.');
  +  
  +      String[] args = {
  +        "-extends",
  +        "org.apache.cocoon.components.language.markup.xsp.javascript.JSGenerator",
  +        "-nosource",
  +        "-O", "9",
  +        "-package", packageName,
  +        pathname + File.separator + filename + "." + this.getSourceExtension()
  +      };
  +  
  +      compiler.main(args);
  +    } catch (Exception e) {
  +      throw new LanguageException(e.getMessage());
  +    }
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +27 -27    xml-cocoon/src/org/apache/cocoon/components/parser/Attic/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/parser/Attic/Parser.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- Parser.java	2000/07/11 03:09:52	1.1.2.5
  +++ Parser.java	2000/07/22 20:41:42	1.1.2.6
  @@ -1,27 +1,27 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.parser;
  -
  -import java.io.IOException;
  -import org.apache.avalon.Component;
  -import org.apache.cocoon.xml.XMLProducer;
  -import org.apache.cocoon.xml.util.DOMFactory;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/11 03:09:52 $
  - */
  -public interface Parser extends Component, XMLProducer, DOMFactory {
  -    
  -    public void parse(InputSource in) throws SAXException, IOException;
  -    
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.parser;
  +
  +import java.io.IOException;
  +import org.apache.avalon.Component;
  +import org.apache.cocoon.xml.XMLProducer;
  +import org.apache.cocoon.xml.util.DOMFactory;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/22 20:41:42 $
  + */
  +public interface Parser extends Component, XMLProducer, DOMFactory {
  +    
  +    public void parse(InputSource in) throws SAXException, IOException;
  +    
  +}
  
  
  
  1.1.2.4   +102 -102  xml-cocoon/src/org/apache/cocoon/components/parser/Attic/XercesParser.java
  
  Index: XercesParser.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/parser/Attic/XercesParser.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- XercesParser.java	2000/02/27 17:47:13	1.1.2.3
  +++ XercesParser.java	2000/07/22 20:41:42	1.1.2.4
  @@ -1,102 +1,102 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.parser;
  -
  -import java.io.IOException;
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -import org.apache.cocoon.xml.util.DOMFactory;
  -import org.apache.xerces.dom.DocumentImpl;
  -import org.apache.xerces.dom.DocumentTypeImpl;
  -import org.apache.xerces.parsers.SAXParser;
  -import org.xml.sax.ErrorHandler;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.SAXParseException;
  -import org.w3c.dom.Document;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/27 17:47:13 $
  - */
  -public class XercesParser extends AbstractXMLProducer
  -implements Parser, ErrorHandler, DOMFactory {
  -    
  -    public void parse(InputSource in)
  -    throws SAXException, IOException {
  -        SAXParser p=new SAXParser();
  -        p.setFeature("http://xml.org/sax/features/validation",false);
  -        p.setFeature("http://xml.org/sax/features/namespaces",true);
  -        p.setProperty("http://xml.org/sax/properties/lexical-handler",
  -                      super.lexicalHandler);
  -        p.setErrorHandler(this);
  -        p.setContentHandler(super.contentHandler);
  -        p.parse(in);
  -    }
  -        
  -    /** 
  -     * Create a new Document object.
  -     */
  -    public Document newDocument() {
  -        return(newDocument(null,null,null));
  -    }
  -
  -    /** 
  -     * Create a new Document object with a specified DOCTYPE.
  -     */
  -    public Document newDocument(String name) {
  -        return(newDocument(name,null,null));
  -    }
  -
  -    /** 
  -     * Create a new Document object with a specified DOCTYPE, public ID and 
  -     * system ID.
  -     */
  -    public Document newDocument(String name, String pub, String sys) {
  -        DocumentImpl doc=new DocumentImpl();
  -        if ((pub!=null)||(sys!=null)) {
  -            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name,pub,sys);
  -            doc.appendChild(dtd);
  -        } else if (name!=null) {
  -            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name);
  -            doc.appendChild(dtd);
  -        }
  -        return(doc);
  -    }
  -
  -    /**
  -     * Receive notification of a recoverable error.
  -     */
  -    public void error(SAXParseException e)
  -    throws SAXException {
  -        throw new SAXException("Error parsing "+e.getSystemId()+" (line "+
  -                               e.getLineNumber()+" col. "+e.getColumnNumber()+
  -                               "): "+e.getMessage(),e);
  -    }
  -
  -    /**
  -     * Receive notification of a fatal error.
  -     */
  -    public void fatalError(SAXParseException e)
  -    throws SAXException {
  -        throw new SAXException("Fatal error parsing "+e.getSystemId()+" (line "+
  -                               e.getLineNumber()+" col. "+e.getColumnNumber()+
  -                               "): "+e.getMessage(),e);
  -    }
  -
  -    /**
  -     * Receive notification of a warning.
  -     */
  -    public void warning(SAXParseException e)
  -    throws SAXException {
  -        throw new SAXException("Warning parsing "+e.getSystemId()+" (line "+
  -                               e.getLineNumber()+" col. "+e.getColumnNumber()+
  -                               "): "+e.getMessage(),e);
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.parser;
  +
  +import java.io.IOException;
  +import org.apache.cocoon.xml.AbstractXMLProducer;
  +import org.apache.cocoon.xml.util.DOMFactory;
  +import org.apache.xerces.dom.DocumentImpl;
  +import org.apache.xerces.dom.DocumentTypeImpl;
  +import org.apache.xerces.parsers.SAXParser;
  +import org.xml.sax.ErrorHandler;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.SAXParseException;
  +import org.w3c.dom.Document;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:42 $
  + */
  +public class XercesParser extends AbstractXMLProducer
  +implements Parser, ErrorHandler, DOMFactory {
  +    
  +    public void parse(InputSource in)
  +    throws SAXException, IOException {
  +        SAXParser p=new SAXParser();
  +        p.setFeature("http://xml.org/sax/features/validation",false);
  +        p.setFeature("http://xml.org/sax/features/namespaces",true);
  +        p.setProperty("http://xml.org/sax/properties/lexical-handler",
  +                      super.lexicalHandler);
  +        p.setErrorHandler(this);
  +        p.setContentHandler(super.contentHandler);
  +        p.parse(in);
  +    }
  +        
  +    /** 
  +     * Create a new Document object.
  +     */
  +    public Document newDocument() {
  +        return(newDocument(null,null,null));
  +    }
  +
  +    /** 
  +     * Create a new Document object with a specified DOCTYPE.
  +     */
  +    public Document newDocument(String name) {
  +        return(newDocument(name,null,null));
  +    }
  +
  +    /** 
  +     * Create a new Document object with a specified DOCTYPE, public ID and 
  +     * system ID.
  +     */
  +    public Document newDocument(String name, String pub, String sys) {
  +        DocumentImpl doc=new DocumentImpl();
  +        if ((pub!=null)||(sys!=null)) {
  +            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name,pub,sys);
  +            doc.appendChild(dtd);
  +        } else if (name!=null) {
  +            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name);
  +            doc.appendChild(dtd);
  +        }
  +        return(doc);
  +    }
  +
  +    /**
  +     * Receive notification of a recoverable error.
  +     */
  +    public void error(SAXParseException e)
  +    throws SAXException {
  +        throw new SAXException("Error parsing "+e.getSystemId()+" (line "+
  +                               e.getLineNumber()+" col. "+e.getColumnNumber()+
  +                               "): "+e.getMessage(),e);
  +    }
  +
  +    /**
  +     * Receive notification of a fatal error.
  +     */
  +    public void fatalError(SAXParseException e)
  +    throws SAXException {
  +        throw new SAXException("Fatal error parsing "+e.getSystemId()+" (line "+
  +                               e.getLineNumber()+" col. "+e.getColumnNumber()+
  +                               "): "+e.getMessage(),e);
  +    }
  +
  +    /**
  +     * Receive notification of a warning.
  +     */
  +    public void warning(SAXParseException e)
  +    throws SAXException {
  +        throw new SAXException("Warning parsing "+e.getSystemId()+" (line "+
  +                               e.getLineNumber()+" col. "+e.getColumnNumber()+
  +                               "): "+e.getMessage(),e);
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +196 -196  xml-cocoon/src/org/apache/cocoon/components/store/Attic/FilesystemStore.java
  
  Index: FilesystemStore.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/store/Attic/FilesystemStore.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- FilesystemStore.java	2000/05/23 23:10:10	1.1.2.1
  +++ FilesystemStore.java	2000/07/22 20:41:43	1.1.2.2
  @@ -1,196 +1,196 @@
  -package org.apache.cocoon.components.store;
  -
  -import java.io.File;
  -import java.util.Enumeration;
  -
  -import org.apache.cocoon.util.IOUtils;
  -
  -import java.io.IOException;
  -
  -public class FilesystemStore implements Store {
  -  /** The directory repository */
  -  protected File directoryFile;
  -  protected volatile String directoryPath;
  -  
  -  /**
  -   * Constructor
  -   */
  -  public FilesystemStore(String directoryName) throws IOException {
  -    this(new File(directoryName));
  -  }
  -
  -  public FilesystemStore(File directoryFile) throws IOException {
  -    this.directoryFile = directoryFile;
  -
  -    /* Save directory path prefix */
  -    this.directoryPath = IOUtils.getFullFilename(this.directoryFile);
  -    this.directoryPath += File.separator;
  -
  -    /* Does directory exist? */
  -    if (!this.directoryFile.exists()) {
  -      /* Create it anew */
  -      if (!this.directoryFile.mkdir()) {
  -        throw new IOException(
  -	  "Error creating store directory '" + this.directoryPath + "': "
  -	);
  -      }
  -    }
  -
  -    /* Is given file actually a directory? */
  -    if (!this.directoryFile.isDirectory()) {
  -      throw new IOException("'" + this.directoryPath + "' is not a directory");
  -    }
  -
  -    /* Is directory readable and writable? */
  -    if (!(this.directoryFile.canRead() && this.directoryFile.canWrite())) {
  -      throw new IOException(
  -        "Directory '" + this.directoryPath + "' is not readable/writable"
  -      );
  -    }
  -  }
  -
  -  /**
  -   * Returns the repository's full pathname
  -   */
  -  public String getDirectoryPath() {
  -    return this.directoryPath;
  -  }
  -
  -  /**
  -   * Get the file associated with the given unique key name.
  -   */
  -  public Object get(Object key) {
  -    File file = fileFromKey(key);
  -
  -    if (file != null && file.exists()) {
  -      return file;
  -    }
  -
  -    return null;
  -  }
  -  
  -  /**
  -   * Store the given object in a persistent state.
  -   * 1) Null values generate empty directories.
  -   * 2) String values are dumped to text files
  -   * 3) Object values are serialized
  -   */ 
  -  public void store(Object key, Object value) {
  -    try {
  -      File file = fileFromKey(key);
  -
  -      /* Create subdirectories as needed */
  -      File parent = file.getParentFile();
  -      if (parent != null) {
  -        parent.mkdirs();
  -      }
  -
  -      /* Store object as file */
  -      if (value == null) { /* Directory */
  -        if (file.exists()) {
  -          if (!file.delete()) { /* FAILURE */
  -           System.err.println("File cannot be deleted: " + file.toString());
  -           return;
  -          }
  -        }
  -
  -        file.mkdir();
  -      } else if (value instanceof String) { /* Text file */
  -        IOUtils.serializeString(file, (String) value);
  -      } else { /* Serialized Object */
  -        IOUtils.serializeObject(file, value);
  -      }
  -    } catch (Exception e) { /* FAILURE */
  -      e.printStackTrace();
  -    }
  -  }
  -
  -  /**
  -   * Holds the given object in a volatile state.
  -   */ 
  -  public void hold(Object key, Object value) {
  -    this.store(key, value);
  -    File file = (File) this.get(key);
  -    if (file != null) {
  -      file.deleteOnExit();
  -    }
  -  }
  -  
  -  /**
  -   * Remove the object associated to the given key.
  -   */
  -  public void remove(Object key) {
  -    File file = fileFromKey(key);
  -    if (file != null) {
  -      file.delete();
  -    }
  -  }
  -  
  -  /**
  -   * Indicates if the given key is associated to a contained object.
  -   */
  -  public boolean containsKey(Object key) {
  -    File file = fileFromKey(key);
  -    if (file == null) {
  -      return false;
  -    }
  -    return file.exists();
  -  }
  -  
  -  /**
  -   * Returns the list of stored files as an Enumeration of Files
  -   */
  -  public Enumeration keys() {
  -    /* Not yet implemented */
  -    return null;
  -  }
  -
  -  /* Utility Methods*/
  -  protected File fileFromKey(Object key) {
  -    String name = key.toString();
  -
  -    name = IOUtils.getFullFilename(new File(name));
  -
  -    String path = IOUtils.normalizedFilename(IOUtils.pathComponent(name));
  -    String filename = name.substring(name.lastIndexOf(File.separatorChar));
  -
  -    String extension = null;
  -    int extensionPosition = filename.lastIndexOf(".");
  -    if (extensionPosition >= 0) {
  -      extension = filename.substring(extensionPosition + 1);
  -      filename = filename.substring(0, extensionPosition);
  -    }
  -
  -    filename = IOUtils.normalizedFilename(filename);
  -
  -    if (extension != null) {
  -      filename += "." + extension;
  -    }
  -
  -    return new File(this.directoryPath + path + File.separator + filename);
  -  }
  -
  -  public String getString(Object key) throws IOException {
  -    File file = (File) this.get(key);
  -    if (file != null) {
  -      return IOUtils.deserializeString(file);
  -    }
  -
  -    return null;
  -  }
  -
  -  public Object getObject(Object key)
  -    throws IOException, ClassNotFoundException
  -  {
  -    File file = (File) this.get(key);
  -    if (file != null) {
  -      return IOUtils.deserializeObject(file);
  -    }
  -
  -    return null;
  -  }
  -
  -  public String normalizedFilename(String filename) {
  -    return IOUtils.normalizedFilename(filename);
  -  }
  -}
  +package org.apache.cocoon.components.store;
  +
  +import java.io.File;
  +import java.util.Enumeration;
  +
  +import org.apache.cocoon.util.IOUtils;
  +
  +import java.io.IOException;
  +
  +public class FilesystemStore implements Store {
  +  /** The directory repository */
  +  protected File directoryFile;
  +  protected volatile String directoryPath;
  +  
  +  /**
  +   * Constructor
  +   */
  +  public FilesystemStore(String directoryName) throws IOException {
  +    this(new File(directoryName));
  +  }
  +
  +  public FilesystemStore(File directoryFile) throws IOException {
  +    this.directoryFile = directoryFile;
  +
  +    /* Save directory path prefix */
  +    this.directoryPath = IOUtils.getFullFilename(this.directoryFile);
  +    this.directoryPath += File.separator;
  +
  +    /* Does directory exist? */
  +    if (!this.directoryFile.exists()) {
  +      /* Create it anew */
  +      if (!this.directoryFile.mkdir()) {
  +        throw new IOException(
  +	  "Error creating store directory '" + this.directoryPath + "': "
  +	);
  +      }
  +    }
  +
  +    /* Is given file actually a directory? */
  +    if (!this.directoryFile.isDirectory()) {
  +      throw new IOException("'" + this.directoryPath + "' is not a directory");
  +    }
  +
  +    /* Is directory readable and writable? */
  +    if (!(this.directoryFile.canRead() && this.directoryFile.canWrite())) {
  +      throw new IOException(
  +        "Directory '" + this.directoryPath + "' is not readable/writable"
  +      );
  +    }
  +  }
  +
  +  /**
  +   * Returns the repository's full pathname
  +   */
  +  public String getDirectoryPath() {
  +    return this.directoryPath;
  +  }
  +
  +  /**
  +   * Get the file associated with the given unique key name.
  +   */
  +  public Object get(Object key) {
  +    File file = fileFromKey(key);
  +
  +    if (file != null && file.exists()) {
  +      return file;
  +    }
  +
  +    return null;
  +  }
  +  
  +  /**
  +   * Store the given object in a persistent state.
  +   * 1) Null values generate empty directories.
  +   * 2) String values are dumped to text files
  +   * 3) Object values are serialized
  +   */ 
  +  public void store(Object key, Object value) {
  +    try {
  +      File file = fileFromKey(key);
  +
  +      /* Create subdirectories as needed */
  +      File parent = file.getParentFile();
  +      if (parent != null) {
  +        parent.mkdirs();
  +      }
  +
  +      /* Store object as file */
  +      if (value == null) { /* Directory */
  +        if (file.exists()) {
  +          if (!file.delete()) { /* FAILURE */
  +           System.err.println("File cannot be deleted: " + file.toString());
  +           return;
  +          }
  +        }
  +
  +        file.mkdir();
  +      } else if (value instanceof String) { /* Text file */
  +        IOUtils.serializeString(file, (String) value);
  +      } else { /* Serialized Object */
  +        IOUtils.serializeObject(file, value);
  +      }
  +    } catch (Exception e) { /* FAILURE */
  +      e.printStackTrace();
  +    }
  +  }
  +
  +  /**
  +   * Holds the given object in a volatile state.
  +   */ 
  +  public void hold(Object key, Object value) {
  +    this.store(key, value);
  +    File file = (File) this.get(key);
  +    if (file != null) {
  +      file.deleteOnExit();
  +    }
  +  }
  +  
  +  /**
  +   * Remove the object associated to the given key.
  +   */
  +  public void remove(Object key) {
  +    File file = fileFromKey(key);
  +    if (file != null) {
  +      file.delete();
  +    }
  +  }
  +  
  +  /**
  +   * Indicates if the given key is associated to a contained object.
  +   */
  +  public boolean containsKey(Object key) {
  +    File file = fileFromKey(key);
  +    if (file == null) {
  +      return false;
  +    }
  +    return file.exists();
  +  }
  +  
  +  /**
  +   * Returns the list of stored files as an Enumeration of Files
  +   */
  +  public Enumeration keys() {
  +    /* Not yet implemented */
  +    return null;
  +  }
  +
  +  /* Utility Methods*/
  +  protected File fileFromKey(Object key) {
  +    String name = key.toString();
  +
  +    name = IOUtils.getFullFilename(new File(name));
  +
  +    String path = IOUtils.normalizedFilename(IOUtils.pathComponent(name));
  +    String filename = name.substring(name.lastIndexOf(File.separatorChar));
  +
  +    String extension = null;
  +    int extensionPosition = filename.lastIndexOf(".");
  +    if (extensionPosition >= 0) {
  +      extension = filename.substring(extensionPosition + 1);
  +      filename = filename.substring(0, extensionPosition);
  +    }
  +
  +    filename = IOUtils.normalizedFilename(filename);
  +
  +    if (extension != null) {
  +      filename += "." + extension;
  +    }
  +
  +    return new File(this.directoryPath + path + File.separator + filename);
  +  }
  +
  +  public String getString(Object key) throws IOException {
  +    File file = (File) this.get(key);
  +    if (file != null) {
  +      return IOUtils.deserializeString(file);
  +    }
  +
  +    return null;
  +  }
  +
  +  public Object getObject(Object key)
  +    throws IOException, ClassNotFoundException
  +  {
  +    File file = (File) this.get(key);
  +    if (file != null) {
  +      return IOUtils.deserializeObject(file);
  +    }
  +
  +    return null;
  +  }
  +
  +  public String normalizedFilename(String filename) {
  +    return IOUtils.normalizedFilename(filename);
  +  }
  +}
  
  
  
  1.1.2.3   +77 -77    xml-cocoon/src/org/apache/cocoon/components/store/Attic/MemoryStore.java
  
  Index: MemoryStore.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/store/Attic/MemoryStore.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- MemoryStore.java	2000/07/11 03:09:52	1.1.2.2
  +++ MemoryStore.java	2000/07/22 20:41:43	1.1.2.3
  @@ -1,78 +1,78 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.store;
  -
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import org.apache.avalon.Component;
  -
  -/**
  - *
  - * @author <a href="mailto:scoobie@betaversion.org">Federico Barbieri</a>
  - *         (Betaversion Productions)
  - * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - *         (Apache Software Foundation)
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:09:52 $
  - */
  -public class MemoryStore implements Store {
  -    
  -    /** The shared store */
  -    private static Hashtable table=null;
  -    
  -    public MemoryStore() {
  -        if (table==null) table=new Hashtable();
  -    }
  -
  -    /**
  -     * Get the object associated to the given unique key.
  -     */
  -    public Object get(Object key) {
  -        return(table.get(key));
  -    }
  -    
  -    /**
  -     * Store the given object in a persistent state. It is up to the
  -     * caller to ensure that the key has a persistent state across
  -     * different JVM executions.
  -     */ 
  -    public void store(Object key, Object value) {
  -        this.hold(key,value);
  -    }
  -
  -    /**
  -     * Holds the given object in a volatile state. This means
  -     * the object store will discard held objects if the
  -     * virtual machine is restarted or some error happens.
  -     */ 
  -    public void hold(Object key, Object value) {
  -        table.put(key,value);
  -    }
  -    
  -    /**
  -     * Remove the object associated to the given key.
  -     */
  -    public void remove(Object key) {
  -        table.remove(key);
  -    }
  -    
  -    /**
  -     * Indicates if the given key is associated to a contained object.
  -     */
  -    public boolean containsKey(Object key) {
  -        return(table.containsKey(key));
  -    }
  -    
  -    /**
  -     * Returns the list of used keys as an Enumeration of Objects.
  -     */
  -    public Enumeration keys() {
  -        return(table.keys());
  -    }
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.store;
  +
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import org.apache.avalon.Component;
  +
  +/**
  + *
  + * @author <a href="mailto:scoobie@betaversion.org">Federico Barbieri</a>
  + *         (Betaversion Productions)
  + * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + *         (Apache Software Foundation)
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:43 $
  + */
  +public class MemoryStore implements Store {
  +    
  +    /** The shared store */
  +    private static Hashtable table=null;
  +    
  +    public MemoryStore() {
  +        if (table==null) table=new Hashtable();
  +    }
  +
  +    /**
  +     * Get the object associated to the given unique key.
  +     */
  +    public Object get(Object key) {
  +        return(table.get(key));
  +    }
  +    
  +    /**
  +     * Store the given object in a persistent state. It is up to the
  +     * caller to ensure that the key has a persistent state across
  +     * different JVM executions.
  +     */ 
  +    public void store(Object key, Object value) {
  +        this.hold(key,value);
  +    }
  +
  +    /**
  +     * Holds the given object in a volatile state. This means
  +     * the object store will discard held objects if the
  +     * virtual machine is restarted or some error happens.
  +     */ 
  +    public void hold(Object key, Object value) {
  +        table.put(key,value);
  +    }
  +    
  +    /**
  +     * Remove the object associated to the given key.
  +     */
  +    public void remove(Object key) {
  +        table.remove(key);
  +    }
  +    
  +    /**
  +     * Indicates if the given key is associated to a contained object.
  +     */
  +    public boolean containsKey(Object key) {
  +        return(table.containsKey(key));
  +    }
  +    
  +    /**
  +     * Returns the list of used keys as an Enumeration of Objects.
  +     */
  +    public Enumeration keys() {
  +        return(table.keys());
  +    }
   }
  
  
  
  1.1.2.5   +58 -58    xml-cocoon/src/org/apache/cocoon/components/store/Attic/Store.java
  
  Index: Store.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/store/Attic/Store.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- Store.java	2000/07/11 03:09:52	1.1.2.4
  +++ Store.java	2000/07/22 20:41:43	1.1.2.5
  @@ -1,59 +1,59 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.store;
  -
  -import java.util.Enumeration;
  -import org.apache.avalon.Component;
  -
  -/**
  - *
  - * @author <a href="mailto:scoobie@betaversion.org">Federico Barbieri</a>
  - *         (Betaversion Productions)
  - * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - *         (Apache Software Foundation)
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/11 03:09:52 $
  - */
  -public interface Store extends Component {
  -
  -    /**
  -     * Get the object associated to the given unique key.
  -     */
  -    public Object get(Object key);
  -    
  -    /**
  -     * Store the given object in a persistent state. It is up to the
  -     * caller to ensure that the key has a persistent state across
  -     * different JVM executions.
  -     */ 
  -    public void store(Object key, Object value);
  -
  -    /**
  -     * Holds the given object in a volatile state. This means
  -     * the object store will discard held objects if the
  -     * virtual machine is restarted or some error happens.
  -     */ 
  -    public void hold(Object key, Object value);
  -    
  -    /**
  -     * Remove the object associated to the given key.
  -     */
  -    public void remove(Object key);
  -    
  -    /**
  -     * Indicates if the given key is associated to a contained object.
  -     */
  -    public boolean containsKey(Object key);
  -    
  -    /**
  -     * Returns the list of used keys as an Enumeration of Objects.
  -     */
  -    public Enumeration keys();
  -    
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.components.store;
  +
  +import java.util.Enumeration;
  +import org.apache.avalon.Component;
  +
  +/**
  + *
  + * @author <a href="mailto:scoobie@betaversion.org">Federico Barbieri</a>
  + *         (Betaversion Productions)
  + * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + *         (Apache Software Foundation)
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:43 $
  + */
  +public interface Store extends Component {
  +
  +    /**
  +     * Get the object associated to the given unique key.
  +     */
  +    public Object get(Object key);
  +    
  +    /**
  +     * Store the given object in a persistent state. It is up to the
  +     * caller to ensure that the key has a persistent state across
  +     * different JVM executions.
  +     */ 
  +    public void store(Object key, Object value);
  +
  +    /**
  +     * Holds the given object in a volatile state. This means
  +     * the object store will discard held objects if the
  +     * virtual machine is restarted or some error happens.
  +     */ 
  +    public void hold(Object key, Object value);
  +    
  +    /**
  +     * Remove the object associated to the given key.
  +     */
  +    public void remove(Object key);
  +    
  +    /**
  +     * Indicates if the given key is associated to a contained object.
  +     */
  +    public boolean containsKey(Object key);
  +    
  +    /**
  +     * Returns the list of used keys as an Enumeration of Objects.
  +     */
  +    public Enumeration keys();
  +    
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +14 -14    xml-cocoon/src/org/apache/cocoon/environment/Attic/Environment.java
  
  Index: Environment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/environment/Attic/Environment.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Environment.java	2000/07/18 22:59:31	1.1.2.1
  +++ Environment.java	2000/07/22 20:41:44	1.1.2.2
  @@ -1,14 +1,14 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.environment;
  -
  -public interface Environment {
  -    public void addUriPrefix (String prefix);
  -    public String getView ();
  -    public String getUri ();
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.environment;
  +
  +public interface Environment {
  +    public void addUriPrefix (String prefix);
  +    public String getView ();
  +    public String getUri ();
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +81 -81    xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpEnvironment.java
  
  Index: HttpEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpEnvironment.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- HttpEnvironment.java	2000/07/19 22:19:50	1.1.2.2
  +++ HttpEnvironment.java	2000/07/22 20:41:44	1.1.2.3
  @@ -1,81 +1,81 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.environment.http;
  -
  -import org.apache.cocoon.environment.Environment;
  -
  -import javax.servlet.http.HttpServletRequest;
  -import javax.servlet.http.HttpServletResponse;
  -
  -public class HttpEnvironment implements Environment {
  -
  -    /** The current uri in progress */
  -    private String uri = null;
  -
  -    /** The current prefix to strip off from the request uri */
  -    private StringBuffer prefix = new StringBuffer();
  -
  -    /** The View requested */
  -    private String view = "";
  -
  -    /** The HttpServletRequest */
  -    private HttpRequest req = null;
  -
  -    /** The HttpServletResponse */
  -    private HttpResponse res = null;
  -
  -    /**
  -     * Constructs a HttpEnvironment object from a HttpServletRequest 
  -     * and HttpServletResponse objects
  -     */
  -    public HttpEnvironment (HttpServletRequest req, HttpServletResponse res) {
  -        this.uri = req.getRequestURI();
  -        this.view = req.getHeader("cocoon-view");
  -        this.req = new HttpRequest (req, this);
  -        this.res = new HttpResponse (res);
  -    }
  -    /**
  -     * Adds an prefix to the overall stripped off prefix from the request uri
  -     */
  -    public void addUriPrefix (String prefix) {
  -        if (uri.startsWith (prefix)) {
  -            this.prefix.append (prefix);
  -            uri = uri.substring(prefix.length());
  -        } else {
  -            //FIXME: should we throw an error here ?
  -        }
  -    }
  -
  -    /**
  -     * Returns the request view
  -     */
  -    public String getView () {
  -        return this.view;
  -    }
  -
  -    /**
  -     * Returns the uri in progress. The prefix is stripped off
  -     */
  -    public String getUri () {
  -        return this.uri;
  -    }
  -
  -    /**
  -     * Returns a wrapped HttpRequest object of the real HttpRequest in progress
  -     */
  -    public HttpServletRequest getRequest () {
  -        return this.req;
  -    }
  -
  -    /**
  -     * Returns a wrapped HttpResponse object of the real HttpResponse in progress
  -     */
  -    public HttpServletResponse getResponse () {
  -        return this.res;
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.environment.http;
  +
  +import org.apache.cocoon.environment.Environment;
  +
  +import javax.servlet.http.HttpServletRequest;
  +import javax.servlet.http.HttpServletResponse;
  +
  +public class HttpEnvironment implements Environment {
  +
  +    /** The current uri in progress */
  +    private String uri = null;
  +
  +    /** The current prefix to strip off from the request uri */
  +    private StringBuffer prefix = new StringBuffer();
  +
  +    /** The View requested */
  +    private String view = "";
  +
  +    /** The HttpServletRequest */
  +    private HttpRequest req = null;
  +
  +    /** The HttpServletResponse */
  +    private HttpResponse res = null;
  +
  +    /**
  +     * Constructs a HttpEnvironment object from a HttpServletRequest 
  +     * and HttpServletResponse objects
  +     */
  +    public HttpEnvironment (String uri, HttpServletRequest req, HttpServletResponse res) {
  +        this.uri = uri;
  +        this.view = req.getHeader("cocoon-view");
  +        this.req = new HttpRequest (req, this);
  +        this.res = new HttpResponse (res);
  +    }
  +    /**
  +     * Adds an prefix to the overall stripped off prefix from the request uri
  +     */
  +    public void addUriPrefix (String prefix) {
  +        if (uri.startsWith (prefix)) {
  +            this.prefix.append (prefix);
  +            uri = uri.substring(prefix.length());
  +        } else {
  +            //FIXME: should we throw an error here ?
  +        }
  +    }
  +
  +    /**
  +     * Returns the request view
  +     */
  +    public String getView () {
  +        return this.view;
  +    }
  +
  +    /**
  +     * Returns the uri in progress. The prefix is stripped off
  +     */
  +    public String getUri () {
  +        return this.uri;
  +    }
  +
  +    /**
  +     * Returns a wrapped HttpRequest object of the real HttpRequest in progress
  +     */
  +    public HttpServletRequest getRequest () {
  +        return this.req;
  +    }
  +
  +    /**
  +     * Returns a wrapped HttpResponse object of the real HttpResponse in progress
  +     */
  +    public HttpServletResponse getResponse () {
  +        return this.res;
  +    }
  +}
  
  
  
  1.1.2.3   +246 -246  xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpRequest.java
  
  Index: HttpRequest.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpRequest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- HttpRequest.java	2000/07/19 22:19:51	1.1.2.2
  +++ HttpRequest.java	2000/07/22 20:41:44	1.1.2.3
  @@ -1,246 +1,246 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.environment.http;
  -
  -import java.io.BufferedReader;
  -import java.io.IOException;
  -import java.io.UnsupportedEncodingException;
  -import java.util.Enumeration;
  -import java.util.Locale;
  -
  -import javax.servlet.ServletInputStream;
  -import javax.servlet.RequestDispatcher;
  -
  -import javax.servlet.http.Cookie;
  -import javax.servlet.http.HttpServletRequest;
  -import javax.servlet.http.HttpSession;
  -
  -/**
  - *
  - * Implements the {@link javax.servlet.http.HttpServletRequest} interface
  - * to provide request information for HTTP servlets. 
  - */
  -
  -public class HttpRequest implements HttpServletRequest {
  -
  -    /** The real HttpServletRequest object */
  -    private HttpServletRequest req = null;
  -
  -    /** The HttpEnvironment object */
  -    private HttpEnvironment env = null;
  -
  -    /**
  -     * Creates a HttpServletRequest based on a real HttpServletRequest object
  -     */
  -    protected HttpRequest (HttpServletRequest req, HttpEnvironment env) {
  -        super ();
  -        this.req = req;
  -        this.env = env;
  -    }
  -
  -    /* The HttpServletRequest interface methods */
  -
  -    public String getAuthType() {
  -        return this.req.getAuthType();
  -    }
  -
  -    public Cookie[] getCookies() {
  -        return this.req.getCookies();
  -    }    
  -
  -    public long getDateHeader(String name) {
  -        return this.req.getDateHeader(name);
  -    }
  -
  -    public String getHeader(String name) {
  -        return this.req.getHeader(name); 
  -    }
  -
  -    public Enumeration getHeaders(String name) {
  -        return this.req.getHeaders(name); 
  -    }
  -
  -    public Enumeration getHeaderNames() {
  -        return this.req.getHeaderNames();
  -    }
  -
  -    public int getIntHeader(String name) {
  -        return this.req.getIntHeader(name);
  -    }
  -
  -    public String getMethod() {
  -        return this.req.getMethod();
  -    }
  -     
  -    public String getPathInfo() {
  -        return this.req.getPathInfo();
  -    }
  -
  -    public String getPathTranslated() {
  -        return this.req.getPathTranslated();
  -    }
  -
  -    public String getContextPath() {
  -        return this.req.getContextPath();
  -    }
  -
  -    public String getQueryString() {
  -        return this.req.getQueryString();
  -    }
  -
  -    public String getRemoteUser() {
  -        return this.req.getRemoteUser();
  -    }
  -
  -    public boolean isUserInRole(String role) {
  -        return this.req.isUserInRole(role);
  -    }
  -
  -    public java.security.Principal getUserPrincipal() {
  -        return this.req.getUserPrincipal();
  -    }
  -
  -    public String getRequestedSessionId() {
  -        return this.req.getRequestedSessionId();
  -    }
  -
  -    public String getRequestURI() {
  -        return this.env.getUri();
  -    }
  -
  -    public String getServletPath() {
  -        return this.req.getServletPath();
  -    }
  -
  -    public HttpSession getSession(boolean create) {
  -        return this.req.getSession(create);
  -    }
  -
  -    public HttpSession getSession() {
  -        return this.req.getSession();
  -    }
  -
  -    public boolean isRequestedSessionIdValid() {
  -        return this.req.isRequestedSessionIdValid();
  -    }
  -
  -    public boolean isRequestedSessionIdFromCookie()  {
  -        return this.req.isRequestedSessionIdFromCookie();
  -    }
  -    
  -    public boolean isRequestedSessionIdFromURL() {
  -        return this.req.isRequestedSessionIdFromURL();
  -    }
  -
  -    /**
  -     * @deprecated		As of Version 2.1 of the Java Servlet
  -     *				API, use {@link #isRequestedSessionIdFromURL}
  -     *				instead.
  -     */
  -    public boolean isRequestedSessionIdFromUrl() {
  -        return this.req.isRequestedSessionIdFromUrl();
  -    }
  -
  -    /* The ServletRequest interface methods */
  -
  -    public Object getAttribute(String name) {
  -        return this.req.getAttribute(name);
  -    }
  -
  -    public Enumeration getAttributeNames() {
  -        return this.req.getAttributeNames();
  -    }
  -
  -    public String getCharacterEncoding() {
  -        return this.req.getCharacterEncoding();
  -    }
  -
  -    public int getContentLength() {
  -        return this.req.getContentLength();
  -    }
  -
  -    public String getContentType() {
  -        return this.req.getContentType();
  -    }
  -
  -    public ServletInputStream getInputStream() throws IOException {
  -        return this.req.getInputStream(); 
  -    }
  -
  -    public String getParameter(String name) {
  -        return this.req.getParameter(name);
  -    }
  -     
  -    public Enumeration getParameterNames() {
  -        return this.req.getParameterNames();
  -    }
  -
  -    public String[] getParameterValues(String name) {
  -        return this.req.getParameterValues(name);
  -    }
  -    
  -    public String getProtocol() {
  -        return this.req.getProtocol();
  -    }
  -
  -    public String getScheme() {
  -        return this.req.getScheme();
  -    }
  -
  -    public String getServerName() {
  -        return this.req.getServerName();
  -    }
  -
  -    public int getServerPort() {
  -        return this.req.getServerPort();
  -    }
  -
  -    public BufferedReader getReader() throws IOException {
  -        return this.req.getReader();
  -    }
  -    
  -    public String getRemoteAddr() {
  -        return this.req.getRemoteAddr();
  -    }
  -
  -    public String getRemoteHost() {
  -        return this.req.getRemoteHost();
  -    }
  -
  -    public void setAttribute(String name, Object o) {
  -        this.req.setAttribute(name, o);
  -    }
  -
  -    public void removeAttribute(String name) {
  -        this.req.removeAttribute(name);
  -    }
  -
  -    public Locale getLocale() {
  -        return this.req.getLocale();
  -    }
  -
  -    public Enumeration getLocales() {
  -        return this.req.getLocales();
  -    }
  -
  -    public boolean isSecure() {
  -        return this.req.isSecure();
  -    }
  -
  -    public RequestDispatcher getRequestDispatcher(String path) {
  -        return this.req.getRequestDispatcher(path);
  -    }
  -
  -    /**
  -     * @deprecated 	As of Version 2.1 of the Java Servlet API,
  -     * 			use {@link ServletContext#getRealPath} instead.
  -     */
  -    public String getRealPath(String path) {
  -        return this.req.getRealPath(path);
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.environment.http;
  +
  +import java.io.BufferedReader;
  +import java.io.IOException;
  +import java.io.UnsupportedEncodingException;
  +import java.util.Enumeration;
  +import java.util.Locale;
  +
  +import javax.servlet.ServletInputStream;
  +import javax.servlet.RequestDispatcher;
  +
  +import javax.servlet.http.Cookie;
  +import javax.servlet.http.HttpServletRequest;
  +import javax.servlet.http.HttpSession;
  +
  +/**
  + *
  + * Implements the {@link javax.servlet.http.HttpServletRequest} interface
  + * to provide request information for HTTP servlets. 
  + */
  +
  +public class HttpRequest implements HttpServletRequest {
  +
  +    /** The real HttpServletRequest object */
  +    private HttpServletRequest req = null;
  +
  +    /** The HttpEnvironment object */
  +    private HttpEnvironment env = null;
  +
  +    /**
  +     * Creates a HttpServletRequest based on a real HttpServletRequest object
  +     */
  +    protected HttpRequest (HttpServletRequest req, HttpEnvironment env) {
  +        super ();
  +        this.req = req;
  +        this.env = env;
  +    }
  +
  +    /* The HttpServletRequest interface methods */
  +
  +    public String getAuthType() {
  +        return this.req.getAuthType();
  +    }
  +
  +    public Cookie[] getCookies() {
  +        return this.req.getCookies();
  +    }    
  +
  +    public long getDateHeader(String name) {
  +        return this.req.getDateHeader(name);
  +    }
  +
  +    public String getHeader(String name) {
  +        return this.req.getHeader(name); 
  +    }
  +
  +    public Enumeration getHeaders(String name) {
  +        return this.req.getHeaders(name); 
  +    }
  +
  +    public Enumeration getHeaderNames() {
  +        return this.req.getHeaderNames();
  +    }
  +
  +    public int getIntHeader(String name) {
  +        return this.req.getIntHeader(name);
  +    }
  +
  +    public String getMethod() {
  +        return this.req.getMethod();
  +    }
  +     
  +    public String getPathInfo() {
  +        return this.req.getPathInfo();
  +    }
  +
  +    public String getPathTranslated() {
  +        return this.req.getPathTranslated();
  +    }
  +
  +    public String getContextPath() {
  +        return this.req.getContextPath();
  +    }
  +
  +    public String getQueryString() {
  +        return this.req.getQueryString();
  +    }
  +
  +    public String getRemoteUser() {
  +        return this.req.getRemoteUser();
  +    }
  +
  +    public boolean isUserInRole(String role) {
  +        return this.req.isUserInRole(role);
  +    }
  +
  +    public java.security.Principal getUserPrincipal() {
  +        return this.req.getUserPrincipal();
  +    }
  +
  +    public String getRequestedSessionId() {
  +        return this.req.getRequestedSessionId();
  +    }
  +
  +    public String getRequestURI() {
  +        return this.env.getUri();
  +    }
  +
  +    public String getServletPath() {
  +        return this.req.getServletPath();
  +    }
  +
  +    public HttpSession getSession(boolean create) {
  +        return this.req.getSession(create);
  +    }
  +
  +    public HttpSession getSession() {
  +        return this.req.getSession();
  +    }
  +
  +    public boolean isRequestedSessionIdValid() {
  +        return this.req.isRequestedSessionIdValid();
  +    }
  +
  +    public boolean isRequestedSessionIdFromCookie()  {
  +        return this.req.isRequestedSessionIdFromCookie();
  +    }
  +    
  +    public boolean isRequestedSessionIdFromURL() {
  +        return this.req.isRequestedSessionIdFromURL();
  +    }
  +
  +    /**
  +     * @deprecated		As of Version 2.1 of the Java Servlet
  +     *				API, use {@link #isRequestedSessionIdFromURL}
  +     *				instead.
  +     */
  +    public boolean isRequestedSessionIdFromUrl() {
  +        return this.req.isRequestedSessionIdFromUrl();
  +    }
  +
  +    /* The ServletRequest interface methods */
  +
  +    public Object getAttribute(String name) {
  +        return this.req.getAttribute(name);
  +    }
  +
  +    public Enumeration getAttributeNames() {
  +        return this.req.getAttributeNames();
  +    }
  +
  +    public String getCharacterEncoding() {
  +        return this.req.getCharacterEncoding();
  +    }
  +
  +    public int getContentLength() {
  +        return this.req.getContentLength();
  +    }
  +
  +    public String getContentType() {
  +        return this.req.getContentType();
  +    }
  +
  +    public ServletInputStream getInputStream() throws IOException {
  +        return this.req.getInputStream(); 
  +    }
  +
  +    public String getParameter(String name) {
  +        return this.req.getParameter(name);
  +    }
  +     
  +    public Enumeration getParameterNames() {
  +        return this.req.getParameterNames();
  +    }
  +
  +    public String[] getParameterValues(String name) {
  +        return this.req.getParameterValues(name);
  +    }
  +    
  +    public String getProtocol() {
  +        return this.req.getProtocol();
  +    }
  +
  +    public String getScheme() {
  +        return this.req.getScheme();
  +    }
  +
  +    public String getServerName() {
  +        return this.req.getServerName();
  +    }
  +
  +    public int getServerPort() {
  +        return this.req.getServerPort();
  +    }
  +
  +    public BufferedReader getReader() throws IOException {
  +        return this.req.getReader();
  +    }
  +    
  +    public String getRemoteAddr() {
  +        return this.req.getRemoteAddr();
  +    }
  +
  +    public String getRemoteHost() {
  +        return this.req.getRemoteHost();
  +    }
  +
  +    public void setAttribute(String name, Object o) {
  +        this.req.setAttribute(name, o);
  +    }
  +
  +    public void removeAttribute(String name) {
  +        this.req.removeAttribute(name);
  +    }
  +
  +    public Locale getLocale() {
  +        return this.req.getLocale();
  +    }
  +
  +    public Enumeration getLocales() {
  +        return this.req.getLocales();
  +    }
  +
  +    public boolean isSecure() {
  +        return this.req.isSecure();
  +    }
  +
  +    public RequestDispatcher getRequestDispatcher(String path) {
  +        return this.req.getRequestDispatcher(path);
  +    }
  +
  +    /**
  +     * @deprecated 	As of Version 2.1 of the Java Servlet API,
  +     * 			use {@link ServletContext#getRealPath} instead.
  +     */
  +    public String getRealPath(String path) {
  +        return this.req.getRealPath(path);
  +    }
  +}
  
  
  
  1.1.2.2   +180 -180  xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpResponse.java
  
  Index: HttpResponse.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpResponse.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- HttpResponse.java	2000/07/18 22:59:34	1.1.2.1
  +++ HttpResponse.java	2000/07/22 20:41:45	1.1.2.2
  @@ -1,180 +1,180 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.environment.http;
  -
  -import java.io.IOException;
  -import java.io.PrintWriter;
  -import java.io.UnsupportedEncodingException;
  -import java.util.Locale;
  -
  -import javax.servlet.http.HttpServletResponse;
  -import javax.servlet.http.Cookie;
  -import javax.servlet.ServletException;
  -import javax.servlet.ServletOutputStream;
  -
  -/**
  - *
  - * Implements the {@link HttpServletResponse} interface to provide HTTP-specific
  - * functionality in sending a response.  For example, it has methods
  - * to access HTTP headers and cookies.
  - */
  -
  -public class HttpResponse implements HttpServletResponse {
  -
  -    /** The real HttpServletResponse object */
  -    private HttpServletResponse res = null;
  -
  -    /**
  -     * Creates a HttpServletResponse based on a real HttpServletResponse object
  -     */
  -    protected HttpResponse (HttpServletResponse res) {
  -        super ();
  -        this.res = res;
  -    }
  -
  -    /* The HttpServletResponse interface methods */
  -
  -    public void addCookie(Cookie cookie) {
  -        this.res.addCookie(cookie);
  -    }
  -
  -    public boolean containsHeader(String name) {
  -        return this.res.containsHeader(name);
  -    }
  -
  -    public String encodeURL(String url) {
  -        return this.res.encodeURL(url);
  -    }
  -
  -    public String encodeRedirectURL(String url) {
  -        return this.res.encodeRedirectURL(url);
  -    }
  -
  -    public void sendError(int sc, String msg) throws IOException {
  -        this.res.sendError(sc, msg);
  -    }
  -
  -    public void sendError(int sc) throws IOException {
  -        this.res.sendError(sc);
  -    }
  -
  -    public void sendRedirect(String location) throws IOException {
  -        this.res.sendRedirect(location);
  -    }
  -
  -    public void setDateHeader(String name, long date) {
  -        this.res.setDateHeader(name, date);
  -    }
  -
  -    public void addDateHeader(String name, long date) {
  -        this.res.addDateHeader(name, date);
  -    }
  -
  -    public void setHeader(String name, String value) {
  -        this.res.setHeader(name, value);
  -    }
  -
  -    public void addHeader(String name, String value) {
  -        this.res.addHeader(name, value);
  -    }
  -
  -    public void setIntHeader(String name, int value) {
  -        this.res.setIntHeader(name, value);
  -    }
  -
  -    public void addIntHeader(String name, int value) {
  -        this.res.addIntHeader(name, value);
  -    }
  -
  -    public void setStatus(int sc) {
  -        this.res.setStatus(sc);
  -    }
  -
  -    /**
  -     * @deprecated	As of version 2.1, use encodeURL(String url) instead
  -     */
  -    public String encodeUrl(String url) {
  -        return this.res.encodeUrl(url);
  -    }
  -
  -    /**
  -     * @deprecated	As of version 2.1, use 
  -     *			encodeRedirectURL(String url) instead
  -     */
  -    public String encodeRedirectUrl(String url) {
  -        return this.res.encodeRedirectUrl(url);
  -    }
  -
  -    /**
  -     * @deprecated As of version 2.1, due to ambiguous meaning of the 
  -     * message parameter. To set a status code 
  -     * use <code>setStatus(int)</code>, to send an error with a description
  -     * use <code>sendError(int, String)</code>.
  -     */
  -    public void setStatus(int sc, String sm) {
  -        this.res.setStatus(sc, sm);
  -    }
  -
  -    /* The ServletResponse interface methods */
  -  
  -    public String getCharacterEncoding() {
  -        return this.res.getCharacterEncoding();
  -    }
  -
  -    public ServletOutputStream getOutputStream() throws IOException {
  -        //FIXME: How to query if a Serializer/Reader is calleng this ?
  -        if (1==1 /* is the calling object not a serializer/reader ? */) {
  -            throw new IllegalStateException ("you are not a serializer or reader");
  -        }
  -        return this.res.getOutputStream();
  -    }
  -
  -    public PrintWriter getWriter() throws IOException {
  -        if (1==1 /* is the calling object not a serializer/reader ? */) {
  -            throw new IllegalStateException ("you are not a serializer or reader");
  -        }
  -        return this.res.getWriter();
  -    }
  -
  -    public void setContentLength(int len) {
  -        this.res.setContentLength(len);
  -    }
  -
  -    public void setContentType(String type) {
  -        this.res.setContentType(type);
  -    }
  -
  -    public void setBufferSize(int size) {
  -        this.res.setBufferSize(size);
  -    }
  -
  -    public int getBufferSize() {
  -        return this.res.getBufferSize();
  -    }
  -
  -    public void flushBuffer() throws IOException {
  -        this.res.flushBuffer();
  -    }
  -
  -    public boolean isCommitted() {
  -        return this.res.isCommitted();
  -    }
  -
  -    public void reset() {
  -        this.res.reset();
  -    }
  -
  -    public void setLocale(Locale loc) {
  -        this.res.setLocale(loc);
  -    }
  -
  -    public Locale getLocale() {
  -        return this.res.getLocale();
  -    }
  -}
  -
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.environment.http;
  +
  +import java.io.IOException;
  +import java.io.PrintWriter;
  +import java.io.UnsupportedEncodingException;
  +import java.util.Locale;
  +
  +import javax.servlet.http.HttpServletResponse;
  +import javax.servlet.http.Cookie;
  +import javax.servlet.ServletException;
  +import javax.servlet.ServletOutputStream;
  +
  +/**
  + *
  + * Implements the {@link HttpServletResponse} interface to provide HTTP-specific
  + * functionality in sending a response.  For example, it has methods
  + * to access HTTP headers and cookies.
  + */
  +
  +public class HttpResponse implements HttpServletResponse {
  +
  +    /** The real HttpServletResponse object */
  +    private HttpServletResponse res = null;
  +
  +    /**
  +     * Creates a HttpServletResponse based on a real HttpServletResponse object
  +     */
  +    protected HttpResponse (HttpServletResponse res) {
  +        super ();
  +        this.res = res;
  +    }
  +
  +    /* The HttpServletResponse interface methods */
  +
  +    public void addCookie(Cookie cookie) {
  +        this.res.addCookie(cookie);
  +    }
  +
  +    public boolean containsHeader(String name) {
  +        return this.res.containsHeader(name);
  +    }
  +
  +    public String encodeURL(String url) {
  +        return this.res.encodeURL(url);
  +    }
  +
  +    public String encodeRedirectURL(String url) {
  +        return this.res.encodeRedirectURL(url);
  +    }
  +
  +    public void sendError(int sc, String msg) throws IOException {
  +        this.res.sendError(sc, msg);
  +    }
  +
  +    public void sendError(int sc) throws IOException {
  +        this.res.sendError(sc);
  +    }
  +
  +    public void sendRedirect(String location) throws IOException {
  +        this.res.sendRedirect(location);
  +    }
  +
  +    public void setDateHeader(String name, long date) {
  +        this.res.setDateHeader(name, date);
  +    }
  +
  +    public void addDateHeader(String name, long date) {
  +        this.res.addDateHeader(name, date);
  +    }
  +
  +    public void setHeader(String name, String value) {
  +        this.res.setHeader(name, value);
  +    }
  +
  +    public void addHeader(String name, String value) {
  +        this.res.addHeader(name, value);
  +    }
  +
  +    public void setIntHeader(String name, int value) {
  +        this.res.setIntHeader(name, value);
  +    }
  +
  +    public void addIntHeader(String name, int value) {
  +        this.res.addIntHeader(name, value);
  +    }
  +
  +    public void setStatus(int sc) {
  +        this.res.setStatus(sc);
  +    }
  +
  +    /**
  +     * @deprecated	As of version 2.1, use encodeURL(String url) instead
  +     */
  +    public String encodeUrl(String url) {
  +        return this.res.encodeUrl(url);
  +    }
  +
  +    /**
  +     * @deprecated	As of version 2.1, use 
  +     *			encodeRedirectURL(String url) instead
  +     */
  +    public String encodeRedirectUrl(String url) {
  +        return this.res.encodeRedirectUrl(url);
  +    }
  +
  +    /**
  +     * @deprecated As of version 2.1, due to ambiguous meaning of the 
  +     * message parameter. To set a status code 
  +     * use <code>setStatus(int)</code>, to send an error with a description
  +     * use <code>sendError(int, String)</code>.
  +     */
  +    public void setStatus(int sc, String sm) {
  +        this.res.setStatus(sc, sm);
  +    }
  +
  +    /* The ServletResponse interface methods */
  +  
  +    public String getCharacterEncoding() {
  +        return this.res.getCharacterEncoding();
  +    }
  +
  +    public ServletOutputStream getOutputStream() throws IOException {
  +        //FIXME: How to query if a Serializer/Reader is calleng this ?
  +        if (1==1 /* is the calling object not a serializer/reader ? */) {
  +            throw new IllegalStateException ("you are not a serializer or reader");
  +        }
  +        return this.res.getOutputStream();
  +    }
  +
  +    public PrintWriter getWriter() throws IOException {
  +        if (1==1 /* is the calling object not a serializer/reader ? */) {
  +            throw new IllegalStateException ("you are not a serializer or reader");
  +        }
  +        return this.res.getWriter();
  +    }
  +
  +    public void setContentLength(int len) {
  +        this.res.setContentLength(len);
  +    }
  +
  +    public void setContentType(String type) {
  +        this.res.setContentType(type);
  +    }
  +
  +    public void setBufferSize(int size) {
  +        this.res.setBufferSize(size);
  +    }
  +
  +    public int getBufferSize() {
  +        return this.res.getBufferSize();
  +    }
  +
  +    public void flushBuffer() throws IOException {
  +        this.res.flushBuffer();
  +    }
  +
  +    public boolean isCommitted() {
  +        return this.res.isCommitted();
  +    }
  +
  +    public void reset() {
  +        this.res.reset();
  +    }
  +
  +    public void setLocale(Locale loc) {
  +        this.res.setLocale(loc);
  +    }
  +
  +    public Locale getLocale() {
  +        return this.res.getLocale();
  +    }
  +}
  +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +39 -43    xml-cocoon/src/org/apache/cocoon/generation/Attic/AbstractGenerator.java
  
  Index: AbstractGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/AbstractGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- AbstractGenerator.java	2000/07/11 23:45:02	1.1.2.1
  +++ AbstractGenerator.java	2000/07/22 20:41:46	1.1.2.2
  @@ -1,43 +1,39 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:02 $
  - */
  -public abstract class AbstractGenerator extends AbstractXMLProducer
  -implements Generator {
  -
  -    /** The current <code>Request</code>. */
  -    protected Request request=null;
  -    /** The current <code>Response</code>. */
  -    protected Response response=null;
  -    /** The current <code>Parameters</code>. */
  -    protected Parameters parameters=null;
  -    /** The source URI associated with the request or <b>null</b>. */
  -    protected String source=null;
  -
  -    /**
  -     * Set the <code>Request</code>, <code>Response</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Request req, Response res, String src, Parameters par) {
  -        this.request=req;
  -        this.response=res;
  -        this.source=src;
  -        this.parameters=par;
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.xml.AbstractXMLProducer;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:46 $
  + */
  +public abstract class AbstractGenerator extends AbstractXMLProducer
  +implements Generator {
  +
  +    /** The current <code>Environment</code>. */
  +    protected Environment environment=null;
  +    /** The current <code>Parameters</code>. */
  +    protected Parameters parameters=null;
  +    /** The source URI associated with the request or <b>null</b>. */
  +    protected String source=null;
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +        this.environment=environment;
  +        this.source=src;
  +        this.parameters=par;
  +    }
  +}
  
  
  
  1.1.2.2   +132 -132  xml-cocoon/src/org/apache/cocoon/generation/Attic/AbstractServerPage.java
  
  Index: AbstractServerPage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/AbstractServerPage.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- AbstractServerPage.java	2000/07/11 23:45:03	1.1.2.1
  +++ AbstractServerPage.java	2000/07/22 20:41:46	1.1.2.2
  @@ -1,132 +1,132 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import org.apache.avalon.Modifiable;
  -
  -import java.io.File;
  -import org.apache.cocoon.Request;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -import org.xml.sax.SAXException;
  -
  -/**
  - * Base implementation of <code>ServerPagesGenerator</code>. This class
  - * declares variables that must be explicitly initialized by code generators.
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:03 $
  - */
  -public abstract class AbstractServerPage
  -  extends ComposerGenerator
  -  implements Modifiable
  -{
  -  /**
  -   * Code generators should produce a static
  -   * block that initializes the generator's
  -   * creation date and file dependency list.
  -   * Example:
  -   *
  -   *  static {
  -   *    dateCreated = 958058788948L;
  -   *    dependencies = new File[] {
  -   *      new File("source.xml"),
  -   *    };
  -   *  }
  -   *
  -   */
  -
  -  /** The creation date */
  -  protected static long dateCreated = -1L;
  -  /** The dependency file list */
  -  protected static File[] dependencies = null;
  -
  -  /**
  -   * Determines whether this generator's source files have changed
  -   *
  -   * @return Whether any of the files this generator depends on has changed
  -   * since it was created
  -   */
  -  public final boolean modifiedSince(long date) {
  -    if (dateCreated < date) {
  -      return true;
  -    }
  -
  -    for (int i = 0; i < dependencies.length; i++) {
  -      if (dateCreated < dependencies[i].lastModified()) {
  -        return true;
  -      }
  -    }
  -
  -    return false;
  -  }
  -
  -  /**
  -   * Determines whether generated content has changed since
  -   * last invocation. Users may override this method to take
  -   * advantage of SAX event cacheing
  -   *
  -   * @param request The request whose data must be inspected to assert whether
  -   * dynamically generated content has changed
  -   * @return Whether content has changes for this request's data
  -   */
  -  public boolean hasContentChanged(Request request) {
  -    return true;
  -  }
  -
  -  // FIXME: Add more methods!
  -  /* SAX Utility Methods */
  -  /**
  -   * Add an attribute
  -   *
  -   * @param attr The attribute list to add to
  -   * @param name The attribute name
  -   * @param value The attribute value
  -   */
  -  protected void attribute(AttributesImpl attr, String name, String value) {
  -    attr.addAttribute("", name, name, "CDATA", value);
  -  } 
  -
  -  /**
  -   * Start an element 
  -   *
  -   * @param name The element name
  -   * @param attr The element attributes
  -   */
  -  protected void start(String name, AttributesImpl attr) throws SAXException {
  -    this.contentHandler.startElement("", name, name, attr);
  -    attr.clear();
  -  } 
  -
  -  /**
  -   * End an element
  -   * 
  -   * @param name The element name
  -   */
  -  protected void end(String name) throws SAXException {
  -    this.contentHandler.endElement("", name, name);
  -  } 
  -
  -  /**
  -   * Add character data
  -   * 
  -   * @param data The character data
  -   */
  -  protected void characters(String data) throws SAXException {
  -    this.contentHandler.characters(data.toCharArray(), 0, data.length());
  -  } 
  -
  -  /**
  -   * Add a comment
  -   * 
  -   * @param comment The comment data
  -   */
  -  protected void comment(String data) throws SAXException {
  -    this.lexicalHandler.comment(data.toCharArray(), 0, data.length());
  -  } 
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import org.apache.avalon.Modifiable;
  +
  +import java.io.File;
  +import org.apache.cocoon.Request;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + * Base implementation of <code>ServerPagesGenerator</code>. This class
  + * declares variables that must be explicitly initialized by code generators.
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:46 $
  + */
  +public abstract class AbstractServerPage
  +  extends ComposerGenerator
  +  implements Modifiable
  +{
  +  /**
  +   * Code generators should produce a static
  +   * block that initializes the generator's
  +   * creation date and file dependency list.
  +   * Example:
  +   *
  +   *  static {
  +   *    dateCreated = 958058788948L;
  +   *    dependencies = new File[] {
  +   *      new File("source.xml"),
  +   *    };
  +   *  }
  +   *
  +   */
  +
  +  /** The creation date */
  +  protected static long dateCreated = -1L;
  +  /** The dependency file list */
  +  protected static File[] dependencies = null;
  +
  +  /**
  +   * Determines whether this generator's source files have changed
  +   *
  +   * @return Whether any of the files this generator depends on has changed
  +   * since it was created
  +   */
  +  public final boolean modifiedSince(long date) {
  +    if (dateCreated < date) {
  +      return true;
  +    }
  +
  +    for (int i = 0; i < dependencies.length; i++) {
  +      if (dateCreated < dependencies[i].lastModified()) {
  +        return true;
  +      }
  +    }
  +
  +    return false;
  +  }
  +
  +  /**
  +   * Determines whether generated content has changed since
  +   * last invocation. Users may override this method to take
  +   * advantage of SAX event cacheing
  +   *
  +   * @param request The request whose data must be inspected to assert whether
  +   * dynamically generated content has changed
  +   * @return Whether content has changes for this request's data
  +   */
  +  public boolean hasContentChanged(Request request) {
  +    return true;
  +  }
  +
  +  // FIXME: Add more methods!
  +  /* SAX Utility Methods */
  +  /**
  +   * Add an attribute
  +   *
  +   * @param attr The attribute list to add to
  +   * @param name The attribute name
  +   * @param value The attribute value
  +   */
  +  protected void attribute(AttributesImpl attr, String name, String value) {
  +    attr.addAttribute("", name, name, "CDATA", value);
  +  } 
  +
  +  /**
  +   * Start an element 
  +   *
  +   * @param name The element name
  +   * @param attr The element attributes
  +   */
  +  protected void start(String name, AttributesImpl attr) throws SAXException {
  +    this.contentHandler.startElement("", name, name, attr);
  +    attr.clear();
  +  } 
  +
  +  /**
  +   * End an element
  +   * 
  +   * @param name The element name
  +   */
  +  protected void end(String name) throws SAXException {
  +    this.contentHandler.endElement("", name, name);
  +  } 
  +
  +  /**
  +   * Add character data
  +   * 
  +   * @param data The character data
  +   */
  +  protected void characters(String data) throws SAXException {
  +    this.contentHandler.characters(data.toCharArray(), 0, data.length());
  +  } 
  +
  +  /**
  +   * Add a comment
  +   * 
  +   * @param comment The comment data
  +   */
  +  protected void comment(String data) throws SAXException {
  +    this.lexicalHandler.comment(data.toCharArray(), 0, data.length());
  +  } 
  +}
  
  
  
  1.1.2.2   +33 -33    xml-cocoon/src/org/apache/cocoon/generation/Attic/ComposerGenerator.java
  
  Index: ComposerGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/ComposerGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ComposerGenerator.java	2000/07/11 23:45:04	1.1.2.1
  +++ ComposerGenerator.java	2000/07/22 20:41:47	1.1.2.2
  @@ -1,33 +1,33 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.ComponentManager;
  -import org.apache.cocoon.Cocoon;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:04 $
  - */
  -public abstract class ComposerGenerator extends AbstractGenerator
  -implements Composer {
  -
  -    /** The component manager instance */
  -    protected ComponentManager manager=null;
  -
  -    /**
  -     * Set the current <code>ComponentManager</code> instance used by this
  -     * <code>Composer</code>.
  -     */
  -    public void setComponentManager(ComponentManager manager) {
  -        this.manager=manager;
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.ComponentManager;
  +import org.apache.cocoon.Cocoon;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $
  + */
  +public abstract class ComposerGenerator extends AbstractGenerator
  +implements Composer {
  +
  +    /** The component manager instance */
  +    protected ComponentManager manager=null;
  +
  +    /**
  +     * Set the current <code>ComponentManager</code> instance used by this
  +     * <code>Composer</code>.
  +     */
  +    public void setComponentManager(ComponentManager manager) {
  +        this.manager=manager;
  +    }
  +}
  
  
  
  1.1.2.2   +249 -252  xml-cocoon/src/org/apache/cocoon/generation/Attic/DirectoryGenerator.java
  
  Index: DirectoryGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/DirectoryGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DirectoryGenerator.java	2000/07/11 23:45:05	1.1.2.1
  +++ DirectoryGenerator.java	2000/07/22 20:41:47	1.1.2.2
  @@ -1,252 +1,249 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import java.io.File;
  -import java.io.IOException;
  -import java.net.URL;
  -import java.text.SimpleDateFormat;
  -import java.util.Date;
  -import org.xml.sax.EntityResolver;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.AttributesImpl;
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -
  -/**
  - * Generates an XML directory listing.
  - * <p>
  - * The root node of the generated document will normally be a
  - * <code>directory</code> node, and a directory node can contain zero
  - * or more <code>file</code> or directory nodes. A file node has no
  - * children. Each node will contain the following attributes:
  - * <blockquote>
  - *   <dl>
  - *   <dt> name
  - *   <dd> the name of the file or directory
  - *   <dt> lastModified
  - *   <dd> the time the file was last modified, measured as the number of
  - *   milliseconds since the epoch (as in java.io.File.lastModified)
  - *   <dt> date (optional)
  - *   <dd> the time the file was last modified in human-readable form
  - *   </dl>
  - * </blockquote>
  - * <p>
  - * <b>Configuration options:</b>
  - * <dl>
  - * <dt> <i>depth</i> (optional)
  - * <dd> Sets how deep DirectoryGenerator should delve into the
  - * directory structure. If set to 1 (the default), only the starting
  - * directory's immediate contents will be returned.
  - * <dt> <i>dateFormat</i> (optional)
  - * <dd> Sets the format for the date attribute of each node, as
  - * described in java.text.SimpleDateFormat. If unset, the default
  - * format for the current locale will be used.
  - * </dl>
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:05 $ */
  -public class DirectoryGenerator extends ComposerGenerator {
  -
  -    /** The URI of the namespace of this generator. */
  -    protected static final String URI =
  -	"http://xml.apache.org/cocoon/2.0/DirectoryGenerator";
  -
  -    /* Node and attribute names */
  -    protected static final String DIR_NODE_NAME		= "directory";
  -    protected static final String FILE_NODE_NAME		= "file";
  -
  -    protected static final String FILENAME_ATTR_NAME	= "name";
  -    protected static final String LASTMOD_ATTR_NAME	= "lastModified";
  -    protected static final String DATE_ATTR_NAME		= "date";
  -
  -    /*
  -     * Variables set per-request
  -     * 
  -     * FIXME: SimpleDateFormat is not supported by all locales!
  -     */
  -    protected int depth;
  -    protected AttributesImpl attributes = new AttributesImpl();
  -    protected SimpleDateFormat dateFormatter;
  -
  -    /**
  -     * Set the request parameters. Must be called before the generate
  -     * method.
  -     *
  -     * @param	req
  -     * 		the incoming request object
  -     * @param	res
  -     * 		the outgoing response object
  -     * @param	src
  -     * 		the URI for this request (?)
  -     * @param	par
  -     * 		configuration parameters
  -     */
  -    public void setup(Request req, Response res, String src, Parameters par) {
  -	super.setup(req, res, src, par);
  -
  -	String dateFormatString = par.getParameter("dateFormat", null);
  -
  -	if (dateFormatString != null) {
  -	    this.dateFormatter = new SimpleDateFormat(dateFormatString);
  -	} else {
  -	    this.dateFormatter = new SimpleDateFormat();
  -	}
  -
  -	this.depth = par.getParameterAsInteger("depth", 1);
  -
  -	/* Create a reusable attributes for creating nodes */
  -	AttributesImpl attributes = new AttributesImpl();
  -    }
  -
  -
  -    /**
  -     * Generate XML data.
  -     * 
  -     * @throws	SAXException
  -     * 		if an error occurs while outputting the document
  -     * @throws	IOException
  -     * 		if the requsted URI isn't a directory on the local
  -     * 		filesystem
  -     */
  -    public void generate()
  -    throws SAXException, IOException {
  -
  -        EntityResolver resolver;
  -        InputSource input;
  -
  -	URL url;
  -	File path;
  -
  -	resolver = (EntityResolver)super.manager.getComponent("cocoon");
  -	input = resolver.resolveEntity(null,super.source);
  -        url = new URL(input.getSystemId());
  -        path = new File(url.getFile());
  -
  -        if (!path.isDirectory()) {
  -            throw new IOException("Cannot read directory from "
  -				  + url.toString() + "\"");
  -	}
  -
  -        this.contentHandler.startDocument();
  -        this.contentHandler.startPrefixMapping("",URI);
  -	addPath(path, depth);
  -        this.contentHandler.endPrefixMapping("");
  -        this.contentHandler.endDocument();
  -
  -    }
  -
  -    /**
  -     * Adds a single node to the generated document. If the path is a
  -     * directory, and depth is greater than zero, then recursive calls
  -     * are made to add nodes for the directory's children.
  -     *
  -     * @param	path
  -     * 		the file/directory to process
  -     * @param	depth
  -     * 		how deep to scan the directory
  -     *
  -     * @throws	SAXException
  -     * 		if an error occurs while constructing nodes
  -     */
  -    protected void addPath(File path, int depth)
  -    throws SAXException {
  -
  -	if (path.isDirectory()) {
  -
  -	    startNode(DIR_NODE_NAME, path);
  -
  -	    if (depth>0) {
  -		File contents[] = path.listFiles();
  -
  -		for (int i=0; i<contents.length; i++) {
  -		    addPath(contents[i], depth-1);
  -		}
  -	    }
  -
  -	    endNode(DIR_NODE_NAME);
  -
  -	} else {
  -
  -	    startNode(FILE_NODE_NAME, path);
  -	    endNode(FILE_NODE_NAME);
  -
  -	}
  -
  -    }
  -
  -    /**
  -     * Begins a named node, and calls setNodeAttributes to set its
  -	 * attributes.
  -     *
  -     * @param	nodeName
  -     * 		the name of the new node
  -     * @param	path
  -     * 		the file/directory to use when setting attributes
  -     * 
  -     * @throws	SAXException
  -     * 		if an error occurs while creating the node
  -     */
  -    protected void startNode(String nodeName, File path)
  -    throws SAXException {
  -
  -	setNodeAttributes(path);
  -	super.contentHandler.startElement(URI, nodeName, nodeName, attributes);
  -    }
  -
  -	/**
  -	 * Sets the attributes for a given path. The default method sets attributes 
  -	 * for the name of thefile/directory and for the last modification time 
  -	 * of the path.
  -	 *
  -	 * @param path
  -	 *        the file/directory to use when setting attributes
  -	 *
  -	 * @throws SAXException
  -	 *         if an error occurs while setting the attributes
  -	 */
  -	protected void setNodeAttributes(File path) throws SAXException {
  -	
  -	long lastModified = path.lastModified();
  -	attributes.clear();
  -	attributes.addAttribute("", FILENAME_ATTR_NAME,
  -				FILENAME_ATTR_NAME, "CDATA",
  -				path.getName());
  -	attributes.addAttribute("", LASTMOD_ATTR_NAME,
  -				LASTMOD_ATTR_NAME, "CDATA",
  -				Long.toString(path.lastModified()));
  -	attributes.addAttribute("", LASTMOD_ATTR_NAME,
  -				LASTMOD_ATTR_NAME, "CDATA",
  -				Long.toString(lastModified));
  -	attributes.addAttribute("", DATE_ATTR_NAME,
  -				DATE_ATTR_NAME, "CDATA",
  -				dateFormatter.format(new Date(lastModified)));
  -	
  -	}
  -
  -
  -    /**
  -     * Ends the named node.
  -     *
  -     * @param	nodeName
  -     * 		the name of the new node
  -     * @param	path
  -     * 		the file/directory to use when setting attributes
  -     * 
  -     * @throws	SAXException
  -     * 		if an error occurs while closing the node
  -     */
  -    protected void endNode(String nodeName)
  -    throws SAXException {
  -	super.contentHandler.endElement(URI, nodeName, nodeName);
  -    }
  -
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import java.io.File;
  +import java.io.IOException;
  +import java.net.URL;
  +import java.text.SimpleDateFormat;
  +import java.util.Date;
  +import org.xml.sax.EntityResolver;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.helpers.AttributesImpl;
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.environment.Environment;
  +
  +/**
  + * Generates an XML directory listing.
  + * <p>
  + * The root node of the generated document will normally be a
  + * <code>directory</code> node, and a directory node can contain zero
  + * or more <code>file</code> or directory nodes. A file node has no
  + * children. Each node will contain the following attributes:
  + * <blockquote>
  + *   <dl>
  + *   <dt> name
  + *   <dd> the name of the file or directory
  + *   <dt> lastModified
  + *   <dd> the time the file was last modified, measured as the number of
  + *   milliseconds since the epoch (as in java.io.File.lastModified)
  + *   <dt> date (optional)
  + *   <dd> the time the file was last modified in human-readable form
  + *   </dl>
  + * </blockquote>
  + * <p>
  + * <b>Configuration options:</b>
  + * <dl>
  + * <dt> <i>depth</i> (optional)
  + * <dd> Sets how deep DirectoryGenerator should delve into the
  + * directory structure. If set to 1 (the default), only the starting
  + * directory's immediate contents will be returned.
  + * <dt> <i>dateFormat</i> (optional)
  + * <dd> Sets the format for the date attribute of each node, as
  + * described in java.text.SimpleDateFormat. If unset, the default
  + * format for the current locale will be used.
  + * </dl>
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $ */
  +public class DirectoryGenerator extends ComposerGenerator {
  +
  +    /** The URI of the namespace of this generator. */
  +    protected static final String URI =
  +	"http://xml.apache.org/cocoon/2.0/DirectoryGenerator";
  +
  +    /* Node and attribute names */
  +    protected static final String DIR_NODE_NAME		= "directory";
  +    protected static final String FILE_NODE_NAME		= "file";
  +
  +    protected static final String FILENAME_ATTR_NAME	= "name";
  +    protected static final String LASTMOD_ATTR_NAME	= "lastModified";
  +    protected static final String DATE_ATTR_NAME		= "date";
  +
  +    /*
  +     * Variables set per-request
  +     * 
  +     * FIXME: SimpleDateFormat is not supported by all locales!
  +     */
  +    protected int depth;
  +    protected AttributesImpl attributes = new AttributesImpl();
  +    protected SimpleDateFormat dateFormatter;
  +
  +    /**
  +     * Set the request parameters. Must be called before the generate
  +     * method.
  +     *
  +     * @param	environment
  +     * 		the calling environment object
  +     * @param	src
  +     * 		the URI for this request (?)
  +     * @param	par
  +     * 		configuration parameters
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +	super.setup(environment, src, par);
  +
  +	String dateFormatString = par.getParameter("dateFormat", null);
  +
  +	if (dateFormatString != null) {
  +	    this.dateFormatter = new SimpleDateFormat(dateFormatString);
  +	} else {
  +	    this.dateFormatter = new SimpleDateFormat();
  +	}
  +
  +	this.depth = par.getParameterAsInteger("depth", 1);
  +
  +	/* Create a reusable attributes for creating nodes */
  +	AttributesImpl attributes = new AttributesImpl();
  +    }
  +
  +
  +    /**
  +     * Generate XML data.
  +     * 
  +     * @throws	SAXException
  +     * 		if an error occurs while outputting the document
  +     * @throws	IOException
  +     * 		if the requsted URI isn't a directory on the local
  +     * 		filesystem
  +     */
  +    public void generate()
  +    throws SAXException, IOException {
  +
  +        EntityResolver resolver;
  +        InputSource input;
  +
  +	URL url;
  +	File path;
  +
  +	resolver = (EntityResolver)super.manager.getComponent("cocoon");
  +	input = resolver.resolveEntity(null,super.source);
  +        url = new URL(input.getSystemId());
  +        path = new File(url.getFile());
  +
  +        if (!path.isDirectory()) {
  +            throw new IOException("Cannot read directory from "
  +				  + url.toString() + "\"");
  +	}
  +
  +        this.contentHandler.startDocument();
  +        this.contentHandler.startPrefixMapping("",URI);
  +	addPath(path, depth);
  +        this.contentHandler.endPrefixMapping("");
  +        this.contentHandler.endDocument();
  +
  +    }
  +
  +    /**
  +     * Adds a single node to the generated document. If the path is a
  +     * directory, and depth is greater than zero, then recursive calls
  +     * are made to add nodes for the directory's children.
  +     *
  +     * @param	path
  +     * 		the file/directory to process
  +     * @param	depth
  +     * 		how deep to scan the directory
  +     *
  +     * @throws	SAXException
  +     * 		if an error occurs while constructing nodes
  +     */
  +    protected void addPath(File path, int depth)
  +    throws SAXException {
  +
  +	if (path.isDirectory()) {
  +
  +	    startNode(DIR_NODE_NAME, path);
  +
  +	    if (depth>0) {
  +		File contents[] = path.listFiles();
  +
  +		for (int i=0; i<contents.length; i++) {
  +		    addPath(contents[i], depth-1);
  +		}
  +	    }
  +
  +	    endNode(DIR_NODE_NAME);
  +
  +	} else {
  +
  +	    startNode(FILE_NODE_NAME, path);
  +	    endNode(FILE_NODE_NAME);
  +
  +	}
  +
  +    }
  +
  +    /**
  +     * Begins a named node, and calls setNodeAttributes to set its
  +	 * attributes.
  +     *
  +     * @param	nodeName
  +     * 		the name of the new node
  +     * @param	path
  +     * 		the file/directory to use when setting attributes
  +     * 
  +     * @throws	SAXException
  +     * 		if an error occurs while creating the node
  +     */
  +    protected void startNode(String nodeName, File path)
  +    throws SAXException {
  +
  +	setNodeAttributes(path);
  +	super.contentHandler.startElement(URI, nodeName, nodeName, attributes);
  +    }
  +
  +	/**
  +	 * Sets the attributes for a given path. The default method sets attributes 
  +	 * for the name of thefile/directory and for the last modification time 
  +	 * of the path.
  +	 *
  +	 * @param path
  +	 *        the file/directory to use when setting attributes
  +	 *
  +	 * @throws SAXException
  +	 *         if an error occurs while setting the attributes
  +	 */
  +	protected void setNodeAttributes(File path) throws SAXException {
  +	
  +	long lastModified = path.lastModified();
  +	attributes.clear();
  +	attributes.addAttribute("", FILENAME_ATTR_NAME,
  +				FILENAME_ATTR_NAME, "CDATA",
  +				path.getName());
  +	attributes.addAttribute("", LASTMOD_ATTR_NAME,
  +				LASTMOD_ATTR_NAME, "CDATA",
  +				Long.toString(path.lastModified()));
  +	attributes.addAttribute("", LASTMOD_ATTR_NAME,
  +				LASTMOD_ATTR_NAME, "CDATA",
  +				Long.toString(lastModified));
  +	attributes.addAttribute("", DATE_ATTR_NAME,
  +				DATE_ATTR_NAME, "CDATA",
  +				dateFormatter.format(new Date(lastModified)));
  +	
  +	}
  +
  +
  +    /**
  +     * Ends the named node.
  +     *
  +     * @param	nodeName
  +     * 		the name of the new node
  +     * @param	path
  +     * 		the file/directory to use when setting attributes
  +     * 
  +     * @throws	SAXException
  +     * 		if an error occurs while closing the node
  +     */
  +    protected void endNode(String nodeName)
  +    throws SAXException {
  +	super.contentHandler.endElement(URI, nodeName, nodeName);
  +    }
  +
  +}
  
  
  
  1.1.2.2   +35 -35    xml-cocoon/src/org/apache/cocoon/generation/Attic/FileGenerator.java
  
  Index: FileGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/FileGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- FileGenerator.java	2000/07/11 23:45:05	1.1.2.1
  +++ FileGenerator.java	2000/07/22 20:41:47	1.1.2.2
  @@ -1,35 +1,35 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import java.io.IOException;
  -import org.apache.cocoon.Cocoon;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.ProcessingException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:05 $
  - */
  -public class FileGenerator extends ComposerGenerator {
  -
  -    /**
  -     * Generate XML data.
  -     */
  -    public void generate()
  -    throws IOException, SAXException {
  -        Parser parser=(Parser)this.manager.getComponent("parser");
  -        Cocoon cocoon=(Cocoon)this.manager.getComponent("cocoon");
  -        parser.setContentHandler(this.contentHandler);
  -        parser.setLexicalHandler(this.lexicalHandler);
  -        parser.parse(cocoon.resolveEntity(this.source));
  -    }    
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import java.io.IOException;
  +import org.apache.cocoon.Cocoon;
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.ProcessingException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $
  + */
  +public class FileGenerator extends ComposerGenerator {
  +
  +    /**
  +     * Generate XML data.
  +     */
  +    public void generate()
  +    throws IOException, SAXException {
  +        Parser parser=(Parser)this.manager.getComponent("parser");
  +        Cocoon cocoon=(Cocoon)this.manager.getComponent("cocoon");
  +        parser.setContentHandler(this.contentHandler);
  +        parser.setLexicalHandler(this.lexicalHandler);
  +        parser.parse(cocoon.resolveEntity(this.source));
  +    }    
  +}
  
  
  
  1.1.2.2   +27 -27    xml-cocoon/src/org/apache/cocoon/generation/Attic/Generator.java
  
  Index: Generator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/Generator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Generator.java	2000/07/11 23:45:06	1.1.2.1
  +++ Generator.java	2000/07/22 20:41:47	1.1.2.2
  @@ -1,27 +1,27 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import java.io.IOException;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.xml.XMLProducer;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:06 $
  - */
  -public interface Generator extends XMLProducer, SitemapComponent {
  -
  -    public void generate()
  -    throws IOException, SAXException, ProcessingException;
  -    
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import java.io.IOException;
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.xml.XMLProducer;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $
  + */
  +public interface Generator extends XMLProducer, SitemapComponent {
  +
  +    public void generate()
  +    throws IOException, SAXException, ProcessingException;
  +    
  +}
  
  
  
  1.1.2.2   +160 -160  xml-cocoon/src/org/apache/cocoon/generation/Attic/ImageDirectoryGenerator.java
  
  Index: ImageDirectoryGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/ImageDirectoryGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ImageDirectoryGenerator.java	2000/07/11 23:45:07	1.1.2.1
  +++ ImageDirectoryGenerator.java	2000/07/22 20:41:47	1.1.2.2
  @@ -1,160 +1,160 @@
  -package org.apache.cocoon.generation;
  -
  -import java.io.*;
  -import java.util.*;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * An extension of DirectoryGenerators that adds extra attributes for image
  - * files.
  - *
  - * @author <a href="mailto:balld@webslingerZ.com">Donald A. Ball Jr.</a>
  - * @version $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:07 $
  - */
  -public class ImageDirectoryGenerator extends DirectoryGenerator {
  -
  -	protected static String IMAGE_WIDTH_ATTR_NAME = "width";
  -	protected static String IMAGE_HEIGHT_ATTR_NAME = "height";
  -
  -	/**
  -	 * Extends the <code>setNodeAttributes</code> method from the 
  -	 * <code>DirectoryGenerator</code> by adding width and height attributes
  -	 * if the path is a GIF or a JPEG file.
  -	 */
  -	protected void setNodeAttributes(File path) throws SAXException {
  -		super.setNodeAttributes(path);
  -		if (path.isDirectory()) {
  -			return;
  -		}
  -		try {
  -			int dim[] = getSize(path);
  -			attributes.addAttribute("",IMAGE_WIDTH_ATTR_NAME,IMAGE_WIDTH_ATTR_NAME,"CDATA",""+dim[0]);
  -			attributes.addAttribute("",IMAGE_HEIGHT_ATTR_NAME,IMAGE_HEIGHT_ATTR_NAME,"CDATA",""+dim[1]);
  -		} catch (RuntimeException e) {}
  -		catch (Exception e) {
  -			throw new SAXException(e);
  -		}
  -	}
  -
  -	// returns width as first element, height as second
  -	public static int[] getSize(File file) throws FileNotFoundException, IOException {
  -		String type = getFileType(file);
  -		try {
  -			if(type.equals("gif")) return getGifSize(file);
  -			else return getJpegSize(file);
  -		} catch(Exception e) {
  -			throw new RuntimeException("File is not a valid GIF or Jpeg");
  -		}
  -
  -	}
  -
  -	// returns width as first element, height as second
  -	public static int[] getJpegSize(File file) throws FileNotFoundException, IOException {
  -		BufferedReader in = null;
  -		try {
  -			in = new BufferedReader(new FileReader(file));
  -			// check for "magic" header
  -			char[] buf = new char[2];
  -			int count = in.read(buf, 0, 2);
  -			if(count < 2) throw new RuntimeException("Not a valid Jpeg file!");
  -			if((buf[0]) != 0xFF 
  -			|| (buf[1]) != 0xD8 )
  -			throw new RuntimeException("Not a valid Jpeg file!");
  -
  -			int width = 0;
  -			int height = 0;
  -
  -			boolean done = false;
  -			int ch = 0;
  -
  -			try {
  -				while(ch != 0xDA && !done) {
  -					/* Find next marker (JPEG markers begin with 0xFF) */
  -					while (ch != 0xFF) { ch = in.read(); }
  -					/* JPEG markers can be padded with unlimited 0xFF's */
  -					while (ch == 0xFF) { ch = in.read(); }
  -					/* Now, ch contains the value of the marker. */
  -					if(ch >= 0xC0 && ch <= 0xC3) {
  -						// skip 3 bytes
  -						in.read();
  -						in.read();
  -						in.read();
  -						height = 256 * in.read();
  -						height += in.read();
  -						width = 256 * in.read();
  -						width += in.read();
  -						done = true;
  -					} else {
  -						/* We MUST skip variables, since FF's within variable names are NOT valid JPEG markers */
  -						int length = 256 * in.read();
  -						length += in.read();
  -						if(length < 2) throw new RuntimeException("Erroneous JPEG marker length");
  -						for(int foo = 0; foo<length-2; foo++)
  -							in.read();
  -					}
  -				}
  -			} catch(Exception e) {
  -				throw new RuntimeException("Not a valid Jpeg file!");
  -			}
  -
  -			int[] dim = { width, height };
  -			return dim;
  -
  -		} finally {
  -			if(in != null) try { in.close(); } catch(Exception e) {}
  -		}
  -	}
  -
  -	// returns width as first element, height as second
  -	public static int[] getGifSize(File file) throws FileNotFoundException, IOException {
  -		BufferedReader in = null;
  -		try {
  -			in = new BufferedReader(new FileReader(file));
  -			char[] buf = new char[10];
  -			int count = in.read(buf, 0, 10);
  -			if(count < 10) throw new RuntimeException("Not a valid GIF file!");
  -			if((buf[0]) != 'G' 
  -			|| (buf[1]) != 'I' 
  -			|| (buf[2]) != 'F' )
  -			throw new RuntimeException("Not a valid GIF file!");
  -
  -			int w1 = (int)buf[6];
  -			int w2 = (int)buf[7];
  -			int h1 = (int)buf[8];
  -			int h2 = (int)buf[9];
  -
  -			int width = w1 + (256 * w2);
  -			int height = h1 + (256 * h2);
  -			
  -			int[] dim = { width, height };
  -			return dim;
  -
  -		} finally {
  -			if(in != null) try { in.close(); } catch(Exception e) {}
  -		}
  -	}
  -
  -	// returns "gif", "jpeg" or NULL
  -	public static String getFileType(File file) throws FileNotFoundException, IOException {
  -		BufferedReader in = null;
  -		try {
  -			in = new BufferedReader(new FileReader(file));
  -			char[] buf = new char[3];
  -			int count = in.read(buf, 0, 3);
  -			if(count < 3) return null;
  -			if((buf[0]) == 'G' 
  -			&& (buf[1]) == 'I' 
  -			&& (buf[2]) == 'F' )
  -			return "gif";
  -
  -			if((buf[0]) == 0xFF
  -			&& (buf[1]) == 0xD8 )
  -			return "jpeg";
  -
  -			return null;
  -
  -		} finally {
  -			if(in != null) try { in.close(); } catch(Exception e) {}
  -		}
  -	}
  -}
  +package org.apache.cocoon.generation;
  +
  +import java.io.*;
  +import java.util.*;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * An extension of DirectoryGenerators that adds extra attributes for image
  + * files.
  + *
  + * @author <a href="mailto:balld@webslingerZ.com">Donald A. Ball Jr.</a>
  + * @version $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $
  + */
  +public class ImageDirectoryGenerator extends DirectoryGenerator {
  +
  +	protected static String IMAGE_WIDTH_ATTR_NAME = "width";
  +	protected static String IMAGE_HEIGHT_ATTR_NAME = "height";
  +
  +	/**
  +	 * Extends the <code>setNodeAttributes</code> method from the 
  +	 * <code>DirectoryGenerator</code> by adding width and height attributes
  +	 * if the path is a GIF or a JPEG file.
  +	 */
  +	protected void setNodeAttributes(File path) throws SAXException {
  +		super.setNodeAttributes(path);
  +		if (path.isDirectory()) {
  +			return;
  +		}
  +		try {
  +			int dim[] = getSize(path);
  +			attributes.addAttribute("",IMAGE_WIDTH_ATTR_NAME,IMAGE_WIDTH_ATTR_NAME,"CDATA",""+dim[0]);
  +			attributes.addAttribute("",IMAGE_HEIGHT_ATTR_NAME,IMAGE_HEIGHT_ATTR_NAME,"CDATA",""+dim[1]);
  +		} catch (RuntimeException e) {}
  +		catch (Exception e) {
  +			throw new SAXException(e);
  +		}
  +	}
  +
  +	// returns width as first element, height as second
  +	public static int[] getSize(File file) throws FileNotFoundException, IOException {
  +		String type = getFileType(file);
  +		try {
  +			if(type.equals("gif")) return getGifSize(file);
  +			else return getJpegSize(file);
  +		} catch(Exception e) {
  +			throw new RuntimeException("File is not a valid GIF or Jpeg");
  +		}
  +
  +	}
  +
  +	// returns width as first element, height as second
  +	public static int[] getJpegSize(File file) throws FileNotFoundException, IOException {
  +		BufferedReader in = null;
  +		try {
  +			in = new BufferedReader(new FileReader(file));
  +			// check for "magic" header
  +			char[] buf = new char[2];
  +			int count = in.read(buf, 0, 2);
  +			if(count < 2) throw new RuntimeException("Not a valid Jpeg file!");
  +			if((buf[0]) != 0xFF 
  +			|| (buf[1]) != 0xD8 )
  +			throw new RuntimeException("Not a valid Jpeg file!");
  +
  +			int width = 0;
  +			int height = 0;
  +
  +			boolean done = false;
  +			int ch = 0;
  +
  +			try {
  +				while(ch != 0xDA && !done) {
  +					/* Find next marker (JPEG markers begin with 0xFF) */
  +					while (ch != 0xFF) { ch = in.read(); }
  +					/* JPEG markers can be padded with unlimited 0xFF's */
  +					while (ch == 0xFF) { ch = in.read(); }
  +					/* Now, ch contains the value of the marker. */
  +					if(ch >= 0xC0 && ch <= 0xC3) {
  +						// skip 3 bytes
  +						in.read();
  +						in.read();
  +						in.read();
  +						height = 256 * in.read();
  +						height += in.read();
  +						width = 256 * in.read();
  +						width += in.read();
  +						done = true;
  +					} else {
  +						/* We MUST skip variables, since FF's within variable names are NOT valid JPEG markers */
  +						int length = 256 * in.read();
  +						length += in.read();
  +						if(length < 2) throw new RuntimeException("Erroneous JPEG marker length");
  +						for(int foo = 0; foo<length-2; foo++)
  +							in.read();
  +					}
  +				}
  +			} catch(Exception e) {
  +				throw new RuntimeException("Not a valid Jpeg file!");
  +			}
  +
  +			int[] dim = { width, height };
  +			return dim;
  +
  +		} finally {
  +			if(in != null) try { in.close(); } catch(Exception e) {}
  +		}
  +	}
  +
  +	// returns width as first element, height as second
  +	public static int[] getGifSize(File file) throws FileNotFoundException, IOException {
  +		BufferedReader in = null;
  +		try {
  +			in = new BufferedReader(new FileReader(file));
  +			char[] buf = new char[10];
  +			int count = in.read(buf, 0, 10);
  +			if(count < 10) throw new RuntimeException("Not a valid GIF file!");
  +			if((buf[0]) != 'G' 
  +			|| (buf[1]) != 'I' 
  +			|| (buf[2]) != 'F' )
  +			throw new RuntimeException("Not a valid GIF file!");
  +
  +			int w1 = (int)buf[6];
  +			int w2 = (int)buf[7];
  +			int h1 = (int)buf[8];
  +			int h2 = (int)buf[9];
  +
  +			int width = w1 + (256 * w2);
  +			int height = h1 + (256 * h2);
  +			
  +			int[] dim = { width, height };
  +			return dim;
  +
  +		} finally {
  +			if(in != null) try { in.close(); } catch(Exception e) {}
  +		}
  +	}
  +
  +	// returns "gif", "jpeg" or NULL
  +	public static String getFileType(File file) throws FileNotFoundException, IOException {
  +		BufferedReader in = null;
  +		try {
  +			in = new BufferedReader(new FileReader(file));
  +			char[] buf = new char[3];
  +			int count = in.read(buf, 0, 3);
  +			if(count < 3) return null;
  +			if((buf[0]) == 'G' 
  +			&& (buf[1]) == 'I' 
  +			&& (buf[2]) == 'F' )
  +			return "gif";
  +
  +			if((buf[0]) == 0xFF
  +			&& (buf[1]) == 0xD8 )
  +			return "jpeg";
  +
  +			return null;
  +
  +		} finally {
  +			if(in != null) try { in.close(); } catch(Exception e) {}
  +		}
  +	}
  +}
  
  
  
  1.1.2.2   +230 -230  xml-cocoon/src/org/apache/cocoon/generation/Attic/PhpGenerator.java
  
  Index: PhpGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/PhpGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- PhpGenerator.java	2000/07/11 23:45:08	1.1.2.1
  +++ PhpGenerator.java	2000/07/22 20:41:47	1.1.2.2
  @@ -1,230 +1,230 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import java.io.*;
  -import java.util.*;
  -import java.net.*;
  -
  -import javax.servlet.*;
  -
  -import net.php.servlet;
  -import net.php.reflect;
  -
  -import org.apache.cocoon.Response;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Cocoon;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.ProcessingException;
  -
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * Allows PHP to be used as a generator.  Builds upon the PHP servlet
  - * functionallity.  Taking a step back, the PHP functionality needs to
  - * be restructured so that faking out all this servlet infrastructure
  - * is not required in order to simply get a response produced from a
  - * request...
  - *
  - * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:08 $
  - */
  -public class PhpGenerator extends ComposerGenerator {
  -
  -    /**
  -     * Stub implementation of Servlet Context
  -     */
  -    class Context implements ServletContext {
  -        Vector v = new Vector();
  -        public ServletContext getContext(String uripath) { return null; }
  -        public int getMajorVersion() { return 0; }
  -        public int getMinorVersion() { return 0; }
  -        public String getMimeType(String file) { return ""; }
  -        public java.net.URL getResource(String path) { return null; }
  -        public InputStream getResourceAsStream(String path) { return null; }
  -        public RequestDispatcher getRequestDispatcher(String path) 
  -               { return null; }
  -        public RequestDispatcher getNamedDispatcher(String name) 
  -               { return null; }
  -        public void log(String msg) {}
  -        public void log(String message, Throwable throwable) {}
  -        public String getRealPath(String path) { return ""; }
  -        public String getServerInfo() { return "Cocoon PhpGenerator"; }
  -        public String getInitParameter(String name) { return ""; }
  -        public Enumeration getInitParameterNames() { return v.elements(); }
  -        public Object getAttribute(String name) { return null; }
  -        public Enumeration getAttributeNames() { return v.elements(); }
  -        public void setAttribute(String name, Object object) {};
  -        public void removeAttribute(String name) {};
  -
  -        /**
  -         * @deprecated
  -         */
  -        public Servlet getServlet(String name) { return null; };
  -        /**
  -         * @deprecated
  -         */
  -        public Enumeration getServlets() { return v.elements(); }
  -        /**
  -         * @deprecated
  -         */
  -        public Enumeration getServletNames() { return v.elements(); }
  -        /**
  -         * @deprecated
  -         */
  -        public void log(Exception exception, String msg) {}
  -    }
  -
  -    /**
  -     * Stub implementation of Servlet Config
  -     */
  -    class Config implements ServletConfig {
  -        Context c = new Context();
  -        public String getServletName() { return "PhpGenerator"; }
  -        public Enumeration getInitParameterNames() 
  -               { return c.getInitParameterNames(); }
  -        public ServletContext getServletContext() { return c; }
  -        public String getInitParameter(String name) { return null; }
  -    }
  -
  -    /**
  -     * Subclass the PHP servlet implementation, replacing calls to the
  -     * javax.servlet objects like request and response with the cocoon
  -     * equivalents.
  -     */
  -    public class PhpServlet extends net.php.servlet implements Runnable {
  -
  -        Request request;
  -        Response response;
  -        OutputStream output;
  -        String source;
  -
  -        /******************************************************************/
  -        /*                       php sapi callbacks                       */ 
  -        /******************************************************************/
  -
  -        public String readPost(int bytes) {
  -            String result;
  -
  -            Enumeration e = request.getParameterNames();
  -            result="";
  -            String concat="";
  -            while (e.hasMoreElements()) {
  -                String name = (String)e.nextElement();
  -                String value = request.getParameter(name);
  -                result+=concat+name+"="+URLEncoder.encode(value);
  -                concat="&";
  -            }
  -
  -            return result; 
  -        }
  -
  -        public String readCookies() {
  -            reflect.setResult(define("request"), request);
  -            reflect.setResult(define("response"), response);
  -            reflect.setResult(define("PHP_SELF"), request.getUri());
  -            return request.getHeader("cookie");
  -        }
  -
  -        public void header(String data) {
  -
  -            try {
  -                if (data.startsWith("Content-type: ")) {
  -                    response.setContentType(data.substring(data.indexOf(" ")+0));
  -                } else {
  -                    int colon = data.indexOf(": ");
  -                    if (colon > 0) {
  -                        response.setHeader(data.substring(0,colon), 
  -                                           data.substring(colon+2) );
  -                    } else {
  -                        output.write((data+"\n").getBytes());
  -                    }
  -                }
  -            } catch (IOException e) {
  -                  e.printStackTrace(System.err);
  -            }
  -
  -        }
  -
  -        public void write(String data) {
  -            try {
  -                output.write(data.getBytes());
  -            } catch (IOException e) {
  -                e.printStackTrace(System.err);
  -            }
  -        }
  -
  -        /******************************************************************/
  -        /*                        servlet interface                       */ 
  -        /******************************************************************/
  -
  -        public void service(Request request, Response response, 
  -                            OutputStream output, String source)
  -        {
  -            this.request=request;
  -            this.response=response;
  -            this.output=output;
  -            this.source=source;
  -        }
  -
  -        /******************************************************************/
  -        /*                       runnable interface                       */ 
  -        /******************************************************************/
  -
  -        public void run() {
  -            send("GET", null, request.getUri(), source, null, -1, null, false);
  -
  -            try {
  -                output.close();
  -            } catch (IOException e) {
  -                // should never happen
  -            }
  -        }
  -
  -    }
  -
  -    /**
  -     * Generate XML data from PHP.
  -     */
  -    public void generate() throws IOException, SAXException {
  -        Cocoon cocoon=(Cocoon)this.manager.getComponent("cocoon");
  -        Parser parser=(Parser)this.manager.getComponent("parser");
  -        parser.setContentHandler(this.contentHandler);
  -        parser.setLexicalHandler(this.lexicalHandler);
  -        
  -        // ensure that we are serving a file...
  -        String systemId = cocoon.resolveEntity(this.source).getSystemId();
  -        if (!systemId.startsWith("file:/"))
  -            throw new IOException("protocol not supported: " + systemId);
  -
  -        try {
  -            // construct both ends of the pipe
  -            PipedInputStream input = new PipedInputStream();
  -            PipedOutputStream output = new PipedOutputStream(input);
  -        
  -            // start PHP producing results into the pipe
  -            PhpServlet php = new PhpServlet();
  -            php.init(new Config());
  -            php.service(request, response, output, systemId.substring(6));
  -            new Thread(php).start();
  -
  -            // pipe the results into the parser
  -            parser.parse(new InputSource(input));
  -
  -            // clean up
  -            php.destroy();
  -        } catch (SAXException e) {
  -            throw e;
  -        } catch (IOException e) {
  -            throw e;
  -        } catch (Exception e) {
  -            throw new IOException(e.toString());
  -        }
  -    }    
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import java.io.*;
  +import java.util.*;
  +import java.net.*;
  +
  +import javax.servlet.*;
  +
  +import net.php.servlet;
  +import net.php.reflect;
  +
  +import org.apache.cocoon.Response;
  +import org.apache.cocoon.Request;
  +import org.apache.cocoon.Cocoon;
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.ProcessingException;
  +
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * Allows PHP to be used as a generator.  Builds upon the PHP servlet
  + * functionallity.  Taking a step back, the PHP functionality needs to
  + * be restructured so that faking out all this servlet infrastructure
  + * is not required in order to simply get a response produced from a
  + * request...
  + *
  + * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $
  + */
  +public class PhpGenerator extends ComposerGenerator {
  +
  +    /**
  +     * Stub implementation of Servlet Context
  +     */
  +    class Context implements ServletContext {
  +        Vector v = new Vector();
  +        public ServletContext getContext(String uripath) { return null; }
  +        public int getMajorVersion() { return 0; }
  +        public int getMinorVersion() { return 0; }
  +        public String getMimeType(String file) { return ""; }
  +        public java.net.URL getResource(String path) { return null; }
  +        public InputStream getResourceAsStream(String path) { return null; }
  +        public RequestDispatcher getRequestDispatcher(String path) 
  +               { return null; }
  +        public RequestDispatcher getNamedDispatcher(String name) 
  +               { return null; }
  +        public void log(String msg) {}
  +        public void log(String message, Throwable throwable) {}
  +        public String getRealPath(String path) { return ""; }
  +        public String getServerInfo() { return "Cocoon PhpGenerator"; }
  +        public String getInitParameter(String name) { return ""; }
  +        public Enumeration getInitParameterNames() { return v.elements(); }
  +        public Object getAttribute(String name) { return null; }
  +        public Enumeration getAttributeNames() { return v.elements(); }
  +        public void setAttribute(String name, Object object) {};
  +        public void removeAttribute(String name) {};
  +
  +        /**
  +         * @deprecated
  +         */
  +        public Servlet getServlet(String name) { return null; };
  +        /**
  +         * @deprecated
  +         */
  +        public Enumeration getServlets() { return v.elements(); }
  +        /**
  +         * @deprecated
  +         */
  +        public Enumeration getServletNames() { return v.elements(); }
  +        /**
  +         * @deprecated
  +         */
  +        public void log(Exception exception, String msg) {}
  +    }
  +
  +    /**
  +     * Stub implementation of Servlet Config
  +     */
  +    class Config implements ServletConfig {
  +        Context c = new Context();
  +        public String getServletName() { return "PhpGenerator"; }
  +        public Enumeration getInitParameterNames() 
  +               { return c.getInitParameterNames(); }
  +        public ServletContext getServletContext() { return c; }
  +        public String getInitParameter(String name) { return null; }
  +    }
  +
  +    /**
  +     * Subclass the PHP servlet implementation, replacing calls to the
  +     * javax.servlet objects like request and response with the cocoon
  +     * equivalents.
  +     */
  +    public class PhpServlet extends net.php.servlet implements Runnable {
  +
  +        Request request;
  +        Response response;
  +        OutputStream output;
  +        String source;
  +
  +        /******************************************************************/
  +        /*                       php sapi callbacks                       */ 
  +        /******************************************************************/
  +
  +        public String readPost(int bytes) {
  +            String result;
  +
  +            Enumeration e = request.getParameterNames();
  +            result="";
  +            String concat="";
  +            while (e.hasMoreElements()) {
  +                String name = (String)e.nextElement();
  +                String value = request.getParameter(name);
  +                result+=concat+name+"="+URLEncoder.encode(value);
  +                concat="&";
  +            }
  +
  +            return result; 
  +        }
  +
  +        public String readCookies() {
  +            reflect.setResult(define("request"), request);
  +            reflect.setResult(define("response"), response);
  +            reflect.setResult(define("PHP_SELF"), request.getUri());
  +            return request.getHeader("cookie");
  +        }
  +
  +        public void header(String data) {
  +
  +            try {
  +                if (data.startsWith("Content-type: ")) {
  +                    response.setContentType(data.substring(data.indexOf(" ")+0));
  +                } else {
  +                    int colon = data.indexOf(": ");
  +                    if (colon > 0) {
  +                        response.setHeader(data.substring(0,colon), 
  +                                           data.substring(colon+2) );
  +                    } else {
  +                        output.write((data+"\n").getBytes());
  +                    }
  +                }
  +            } catch (IOException e) {
  +                  e.printStackTrace(System.err);
  +            }
  +
  +        }
  +
  +        public void write(String data) {
  +            try {
  +                output.write(data.getBytes());
  +            } catch (IOException e) {
  +                e.printStackTrace(System.err);
  +            }
  +        }
  +
  +        /******************************************************************/
  +        /*                        servlet interface                       */ 
  +        /******************************************************************/
  +
  +        public void service(Request request, Response response, 
  +                            OutputStream output, String source)
  +        {
  +            this.request=request;
  +            this.response=response;
  +            this.output=output;
  +            this.source=source;
  +        }
  +
  +        /******************************************************************/
  +        /*                       runnable interface                       */ 
  +        /******************************************************************/
  +
  +        public void run() {
  +            send("GET", null, request.getUri(), source, null, -1, null, false);
  +
  +            try {
  +                output.close();
  +            } catch (IOException e) {
  +                // should never happen
  +            }
  +        }
  +
  +    }
  +
  +    /**
  +     * Generate XML data from PHP.
  +     */
  +    public void generate() throws IOException, SAXException {
  +        Cocoon cocoon=(Cocoon)this.manager.getComponent("cocoon");
  +        Parser parser=(Parser)this.manager.getComponent("parser");
  +        parser.setContentHandler(this.contentHandler);
  +        parser.setLexicalHandler(this.lexicalHandler);
  +        
  +        // ensure that we are serving a file...
  +        String systemId = cocoon.resolveEntity(this.source).getSystemId();
  +        if (!systemId.startsWith("file:/"))
  +            throw new IOException("protocol not supported: " + systemId);
  +
  +        try {
  +            // construct both ends of the pipe
  +            PipedInputStream input = new PipedInputStream();
  +            PipedOutputStream output = new PipedOutputStream(input);
  +        
  +            // start PHP producing results into the pipe
  +            PhpServlet php = new PhpServlet();
  +            php.init(new Config());
  +            php.service(request, response, output, systemId.substring(6));
  +            new Thread(php).start();
  +
  +            // pipe the results into the parser
  +            parser.parse(new InputSource(input));
  +
  +            // clean up
  +            php.destroy();
  +        } catch (SAXException e) {
  +            throw e;
  +        } catch (IOException e) {
  +            throw e;
  +        } catch (Exception e) {
  +            throw new IOException(e.toString());
  +        }
  +    }    
  +}
  
  
  
  1.1.2.2   +133 -129  xml-cocoon/src/org/apache/cocoon/generation/Attic/RequestGenerator.java
  
  Index: RequestGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/RequestGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- RequestGenerator.java	2000/07/11 23:45:09	1.1.2.1
  +++ RequestGenerator.java	2000/07/22 20:41:47	1.1.2.2
  @@ -1,129 +1,133 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import java.util.Enumeration;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:09 $
  - */
  -public class RequestGenerator extends AbstractGenerator {
  -
  -    /** The URI of the namespace of this generator. */
  -    private String URI="http://xml.apache.org/cocoon/2.0/RequestGenerator";
  -
  -    /**
  -     * Generate XML data.
  -     */
  -    public void generate()
  -    throws SAXException {
  -        this.contentHandler.startDocument();
  -        this.contentHandler.startPrefixMapping("",URI);
  -        AttributesImpl attr=new AttributesImpl();
  -        
  -        this.attribute(attr,"target",this.request.getUri());
  -        this.attribute(attr,"source",this.source);
  -        this.start("request",attr);
  -        this.data("\n");
  -        this.data("\n");
  -
  -        this.data("  ");
  -        this.start("requestHeaders",attr);
  -        this.data("\n");
  -        Enumeration headers=super.request.getHeaderNames();
  -        while (headers.hasMoreElements()) {
  -            String header=(String)headers.nextElement();
  -            this.attribute(attr,"name",header);
  -            this.data("    ");
  -            this.start("header",attr);
  -            this.data(this.request.getHeader(header));
  -            this.end("header");
  -            this.data("\n");
  -        }
  -        this.data("  ");
  -        this.end("requestHeaders");
  -        this.data("\n");
  -        this.data("\n");
  -
  -        this.data("  ");
  -        this.start("requestParameters",attr);
  -        this.data("\n");
  -        Enumeration parameters=super.request.getParameterNames();
  -        while (parameters.hasMoreElements()) {
  -            String parameter=(String)parameters.nextElement();
  -            this.attribute(attr,"name",parameter);
  -            this.data("    ");
  -            this.start("parameter",attr);
  -            this.data("\n");
  -            String values[]=super.request.getParameterValues(parameter);
  -            if (values!=null) for (int x=0; x<values.length; x++) {
  -                this.data("      ");
  -                this.start("value",attr);
  -                this.data(values[x]);
  -                this.end("value");
  -                this.data("\n");
  -            }
  -            this.data("    ");
  -            this.end("parameter");
  -            this.data("\n");
  -        }
  -        this.data("  ");
  -        this.end("requestParameters");
  -        this.data("\n");
  -        this.data("\n");
  -
  -        this.data("  ");
  -        this.start("configurationParameters",attr);
  -        this.data("\n");
  -        Enumeration confparams=super.parameters.getParameterNames();
  -        while (confparams.hasMoreElements()) {
  -            String parameter=(String)confparams.nextElement();
  -            this.attribute(attr,"name",parameter);
  -            this.data("    ");
  -            this.start("parameter",attr);
  -            this.data(super.parameters.getParameter(parameter,""));
  -            this.end("parameter");
  -            this.data("\n");
  -        }
  -        this.data("  ");
  -        this.end("configurationParameters");
  -        this.data("\n");
  -        this.data("\n");
  -
  -        this.end("request");
  -
  -        // Finish
  -        this.contentHandler.endPrefixMapping("");
  -        this.contentHandler.endDocument();
  -    }
  -    
  -    private void attribute(AttributesImpl attr, String name, String value) {
  -        attr.addAttribute("",name,name,"CDATA",value);
  -    }
  -    
  -    private void start(String name, AttributesImpl attr)
  -    throws SAXException {
  -        super.contentHandler.startElement(URI,name,name,attr);
  -        attr.clear();
  -    }
  -
  -    private void end(String name)
  -    throws SAXException {
  -        super.contentHandler.endElement(URI,name,name);
  -    }
  -    
  -    private void data(String data)
  -    throws SAXException {
  -        super.contentHandler.characters(data.toCharArray(),0,data.length());
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +
  +import java.util.Enumeration;
  +
  +import org.xml.sax.SAXException;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $
  + */
  +public class RequestGenerator extends AbstractGenerator {
  +
  +    /** The URI of the namespace of this generator. */
  +    private String URI="http://xml.apache.org/cocoon/2.0/RequestGenerator";
  +
  +    /**
  +     * Generate XML data.
  +     */
  +    public void generate()
  +    throws SAXException {
  +        this.contentHandler.startDocument();
  +        this.contentHandler.startPrefixMapping("",URI);
  +        AttributesImpl attr=new AttributesImpl();
  +        
  +        this.attribute(attr,"target",this.environment.getUri());
  +        this.attribute(attr,"source",this.source);
  +        this.start("request",attr);
  +        this.data("\n");
  +        this.data("\n");
  +
  +        this.data("  ");
  +        this.start("requestHeaders",attr);
  +        this.data("\n");
  +        Enumeration headers=((HttpEnvironment)(super.environment)).getRequest().getHeaderNames();
  +        while (headers.hasMoreElements()) {
  +            String header=(String)headers.nextElement();
  +            this.attribute(attr,"name",header);
  +            this.data("    ");
  +            this.start("header",attr);
  +            this.data(((HttpEnvironment)(super.environment)).getRequest().getHeader(header));
  +            this.end("header");
  +            this.data("\n");
  +        }
  +        this.data("  ");
  +        this.end("requestHeaders");
  +        this.data("\n");
  +        this.data("\n");
  +
  +        this.data("  ");
  +        this.start("requestParameters",attr);
  +        this.data("\n");
  +        Enumeration parameters=((HttpEnvironment)(super.environment)).getRequest().getParameterNames();
  +        while (parameters.hasMoreElements()) {
  +            String parameter=(String)parameters.nextElement();
  +            this.attribute(attr,"name",parameter);
  +            this.data("    ");
  +            this.start("parameter",attr);
  +            this.data("\n");
  +            String values[]=((HttpEnvironment)(super.environment)).getRequest().getParameterValues(parameter);
  +            if (values!=null) for (int x=0; x<values.length; x++) {
  +                this.data("      ");
  +                this.start("value",attr);
  +                this.data(values[x]);
  +                this.end("value");
  +                this.data("\n");
  +            }
  +            this.data("    ");
  +            this.end("parameter");
  +            this.data("\n");
  +        }
  +        this.data("  ");
  +        this.end("requestParameters");
  +        this.data("\n");
  +        this.data("\n");
  +
  +        this.data("  ");
  +        this.start("configurationParameters",attr);
  +        this.data("\n");
  +        Enumeration confparams=super.parameters.getParameterNames();
  +        while (confparams.hasMoreElements()) {
  +            String parameter=(String)confparams.nextElement();
  +            this.attribute(attr,"name",parameter);
  +            this.data("    ");
  +            this.start("parameter",attr);
  +            this.data(super.parameters.getParameter(parameter,""));
  +            this.end("parameter");
  +            this.data("\n");
  +        }
  +        this.data("  ");
  +        this.end("configurationParameters");
  +        this.data("\n");
  +        this.data("\n");
  +
  +        this.end("request");
  +
  +        // Finish
  +        this.contentHandler.endPrefixMapping("");
  +        this.contentHandler.endDocument();
  +    }
  +    
  +    private void attribute(AttributesImpl attr, String name, String value) {
  +        attr.addAttribute("",name,name,"CDATA",value);
  +    }
  +    
  +    private void start(String name, AttributesImpl attr)
  +    throws SAXException {
  +        super.contentHandler.startElement(URI,name,name,attr);
  +        attr.clear();
  +    }
  +
  +    private void end(String name)
  +    throws SAXException {
  +        super.contentHandler.endElement(URI,name,name);
  +    }
  +    
  +    private void data(String data)
  +    throws SAXException {
  +        super.contentHandler.characters(data.toCharArray(),0,data.length());
  +    }
  +}
  
  
  
  1.1.2.2   +371 -371  xml-cocoon/src/org/apache/cocoon/generation/Attic/ServerPagesGenerator.java
  
  Index: ServerPagesGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/ServerPagesGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ServerPagesGenerator.java	2000/07/11 23:45:10	1.1.2.1
  +++ ServerPagesGenerator.java	2000/07/22 20:41:47	1.1.2.2
  @@ -1,371 +1,371 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import java.io.File;
  -import java.net.URL;
  -
  -import org.xml.sax.InputSource;
  -import org.xml.sax.EntityResolver;
  -
  -import java.util.Stack;
  -import org.xml.sax.Locator;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.ext.LexicalHandler;
  -
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.ComponentManager;
  -import org.apache.cocoon.components.language.generator.ProgramGenerator;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -import java.net.MalformedURLException;
  -import org.apache.cocoon.ProcessingException;
  -
  -/**
  - * This class acts as a proxy to a dynamically loaded<code>Generator</code>
  - * delegating actual SAX event generation.
  - *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:45:10 $
  - */
  -public class ServerPagesGenerator
  -  extends ComposerGenerator
  -  implements ContentHandler, LexicalHandler
  -{
  -  /**
  -   * The sitemap-defined server pages program generator
  -   */
  -  protected static ProgramGenerator programGenerator = null;
  -
  -  /**
  -   * Set the global component manager. This method sets the sitemap-defined
  -   * program generator
  -   *
  -   * @param manager The global component manager
  -   */
  -  public void setComponentManager(ComponentManager manager) {
  -    super.setComponentManager(manager);
  -
  -    if (programGenerator == null) {
  -      programGenerator = (ProgramGenerator)
  -        this.manager.getComponent("program-generator");
  -    }
  -  }
  -
  -  /**
  -   * The loaded generator's <code>MarkupLanguage</code>
  -   */
  -  protected String markupLanguage;
  -
  -  /**
  -   * The loaded generator's <code>ProgrammingLanguage</code>
  -   */
  -  protected String programmingLanguage;
  -
  -  /**
  -   * The default <code>MarkupLanguage</code>
  -   */
  -  public final static String DEFAULT_MARKUP_LANGUAGE = "xsp";
  -
  -  /**
  -   * The default <code>ProgrammingLanguage</code>
  -   */
  -  public final static String DEFAULT_PROGRAMMING_LANGUAGE = "java";
  -
  -
  -  /**
  -   * Generate XML data. This method loads a server pages generator associated
  -   * with its (file) input source and delegates SAX event generator to it
  -   * taking care of "closing" any event left open by the loaded generator as a
  -   * result of its possible "premature" return (a common situation in server
  -   * pages)
  -   *
  -   * @exception IOException IO Error
  -   * @exception SAXException SAX event generation error
  -   * @exception ProcessingException Error during load/execution
  -   */
  -  public void generate() throws IOException, SAXException, ProcessingException {
  -    EntityResolver resolver =
  -      (EntityResolver) this.manager.getComponent("cocoon");
  -    InputSource inputSource = resolver.resolveEntity(null, this.source);
  -
  -    String systemId = inputSource.getSystemId();
  -
  -    URL url = new URL(systemId);
  -    if (!url.getProtocol().equals("file")) {
  -      throw new IOException("Not a file: " + url.toString());
  -    } 
  -
  -    File file = new File(url.getFile());
  -
  -    if (!file.canRead()) {
  -      throw new IOException("Can't read file: " + url.toString());
  -    }
  -
  -    String markupLanguage = this.parameters.getParameter(
  -      "markup-language", DEFAULT_MARKUP_LANGUAGE
  -    );
  -    String programmingLanguage = this.parameters.getParameter(
  -      "programming-language", DEFAULT_PROGRAMMING_LANGUAGE
  -    );
  -
  -    Generator generator = null;
  -
  -    try {
  -      generator = (Generator)
  -        programGenerator.load(file, markupLanguage, programmingLanguage);
  -    } catch (Exception e) {
  -e.printStackTrace();
  -      throw new ProcessingException(e.getMessage());
  -    }
  -
  -    // Delegate XML production to loaded generator
  -    if (generator instanceof Composer) {
  -      ((Composer) generator).setComponentManager(this.manager);
  -    }
  -
  -    generator.setContentHandler(this);
  -    generator.setLexicalHandler(this);
  -    generator.setup(this.request, this.response, this.source, this.parameters);
  -
  -    generator.generate();
  -
  -    // End any started events in case of premature return
  -    while (!this.eventStack.empty()) {
  -      EventData eventData = (EventData) this.eventStack.pop();
  -
  -      switch (eventData.eventType) {
  -        case DOCUMENT:
  -	  this.contentHandler.endDocument();
  -	  break;
  -	case ELEMENT:
  -	  this.contentHandler.endElement(
  -	    eventData.getNamespaceURI(),
  -	    eventData.getLocalName(),
  -	    eventData.getRawName()
  -	  );
  -	  break;
  -	case PREFIX_MAPPING:
  -	  this.contentHandler.endPrefixMapping(eventData.getPrefix());
  -	  break;
  -	case CDATA:
  -	  this.lexicalHandler.endCDATA();
  -	  break;
  -	case DTD:
  -	  this.lexicalHandler.endDTD();
  -	  break;
  -	case ENTITY:
  -	  this.lexicalHandler.endEntity(eventData.getName());
  -	  break;
  -      }
  -    }
  -  }    
  -
  -  /* Handlers */
  -
  -  /**
  -   * The SAX event stack. Used for "completing" pendind SAX events left "open"
  -   * by prematurely returning server pages generators
  -   */
  -  protected Stack eventStack = new Stack();
  -
  -    /**
  -     * Receive notification of character data.
  -     */
  -  public void characters(char[] ch, int start, int length) throws SAXException {
  -    this.contentHandler.characters(ch, start, length);
  -  }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -  public void endDocument() throws SAXException {
  -    this.eventStack.pop();
  -    this.contentHandler.endDocument();
  -  }
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     */
  -  public void endElement(String namespaceURI, String localName, String rawName)
  -    throws SAXException
  -  {
  -    this.eventStack.pop();
  -    this.contentHandler.endElement(namespaceURI, localName, rawName);
  -  }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -  public void endPrefixMapping(String prefix) throws SAXException {
  -    this.eventStack.pop();
  -    this.contentHandler.endPrefixMapping(prefix);
  -  }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     */
  -  public void ignorableWhitespace(char[] ch, int start, int length)
  -    throws SAXException
  -  {
  -    this.contentHandler.ignorableWhitespace(ch, start, length);
  -  }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     */
  -  public void processingInstruction(String target, String data)
  -    throws SAXException
  -  {
  -    this.contentHandler.processingInstruction(target, data);
  -  }
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     */
  -  public void setDocumentLocator(Locator locator) {
  -    this.contentHandler.setDocumentLocator(locator);
  -  }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     */
  -  public void skippedEntity(String name)
  -    throws SAXException
  -  {
  -    this.contentHandler.skippedEntity(name);
  -  }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -  public void startDocument() throws SAXException {
  -    this.contentHandler.startDocument();
  -    this.eventStack.push(new EventData(DOCUMENT));
  -  }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -  public void startElement(
  -    String namespaceURI, String localName, String rawName, Attributes atts
  -  )
  -    throws SAXException
  -  {
  -    this.contentHandler.startElement(namespaceURI, localName, rawName, atts);
  -    this.eventStack.push(new EventData(ELEMENT, namespaceURI, localName, rawName));
  -  }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -  public void startPrefixMapping(String prefix, String uri) throws SAXException
  -  {
  -    this.contentHandler.startPrefixMapping(prefix, uri);
  -    this.eventStack.push(new EventData(PREFIX_MAPPING, prefix));
  -  }
  -
  -  public void comment(char[] ch, int start, int length) throws SAXException {
  -    this.lexicalHandler.comment(ch, start, length);
  -  }
  -
  -  public void endCDATA() throws SAXException {
  -    this.lexicalHandler.endCDATA();
  -    this.eventStack.pop();
  -  }
  -
  -  public void endDTD() throws SAXException {
  -    this.lexicalHandler.endDTD();
  -    this.eventStack.pop();
  -  }
  -
  -  public void endEntity(String name) throws SAXException {
  -    this.lexicalHandler.endEntity(name);
  -    this.eventStack.pop();
  -  }
  -
  -  public void startCDATA() throws SAXException {
  -    this.lexicalHandler.startCDATA();
  -    this.eventStack.push(new EventData(CDATA));
  -  }
  -  
  -  public void startDTD(String name, String publicId, String systemId)
  -    throws SAXException
  -  {
  -    this.lexicalHandler.startDTD(name, publicId, systemId);
  -    this.eventStack.push(new EventData(DTD, name, publicId, systemId));
  -  }
  -
  -  public void startEntity(String name) throws SAXException {
  -    this.lexicalHandler.startEntity(name);
  -    this.eventStack.push(new EventData(ENTITY, name));
  -  }
  -
  -  protected final static int DOCUMENT = 0;
  -  protected final static int ELEMENT = 1;
  -  protected final static int PREFIX_MAPPING = 2;
  -  protected final static int CDATA = 3;
  -  protected final static int DTD = 4;
  -  protected final static int ENTITY = 5;
  -
  -  protected class EventData {
  -    protected int eventType;
  -    protected String namespaceURI;
  -    protected String localName;
  -    protected String rawName;
  -    protected String prefix;
  -    protected String publicId;
  -    protected String systemId;
  -    protected String name;
  -
  -    protected EventData(int eventType) {
  -      this.eventType = eventType; // DOCUMENT | CDATA
  -    }
  -
  -    protected EventData(
  -      int eventType, String data1, String data2, String data3
  -    )
  -    {
  -      this.eventType = eventType;
  -      switch (this.eventType) {
  -        case ELEMENT:
  -          this.namespaceURI = data1;
  -          this.localName = data2;
  -          this.rawName = data3;
  -	  break;
  -        case DTD:
  -          this.name = data1;
  -          this.publicId = data2;
  -          this.systemId = data3;
  -	  break;
  -      }
  -    }
  -
  -    protected EventData(int eventType, String data) {
  -      this.eventType = eventType;
  -      switch (this.eventType) {
  -        case PREFIX_MAPPING:
  -	  this.prefix = data;
  -	  break;
  -	case ENTITY:
  -	  this.name = data;
  -	  break;
  -      }
  -    }
  -
  -    protected String getNamespaceURI() { return this.namespaceURI; }
  -    protected String getLocalName() { return this.localName; }
  -    protected String getRawName() { return this.rawName; }
  -    protected String getPrefix() { return this.prefix; }
  -    protected String getPublicId() { return this.publicId; }
  -    protected String getSystemId() { return this.systemId; }
  -    protected String getName() { return this.name; }
  -  }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import java.io.File;
  +import java.net.URL;
  +
  +import org.xml.sax.InputSource;
  +import org.xml.sax.EntityResolver;
  +
  +import java.util.Stack;
  +import org.xml.sax.Locator;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.ext.LexicalHandler;
  +
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.ComponentManager;
  +import org.apache.cocoon.components.language.generator.ProgramGenerator;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +import java.net.MalformedURLException;
  +import org.apache.cocoon.ProcessingException;
  +
  +/**
  + * This class acts as a proxy to a dynamically loaded<code>Generator</code>
  + * delegating actual SAX event generation.
  + *
  + * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $
  + */
  +public class ServerPagesGenerator
  +  extends ComposerGenerator
  +  implements ContentHandler, LexicalHandler
  +{
  +  /**
  +   * The sitemap-defined server pages program generator
  +   */
  +  protected static ProgramGenerator programGenerator = null;
  +
  +  /**
  +   * Set the global component manager. This method sets the sitemap-defined
  +   * program generator
  +   *
  +   * @param manager The global component manager
  +   */
  +  public void setComponentManager(ComponentManager manager) {
  +    super.setComponentManager(manager);
  +
  +    if (programGenerator == null) {
  +      programGenerator = (ProgramGenerator)
  +        this.manager.getComponent("program-generator");
  +    }
  +  }
  +
  +  /**
  +   * The loaded generator's <code>MarkupLanguage</code>
  +   */
  +  protected String markupLanguage;
  +
  +  /**
  +   * The loaded generator's <code>ProgrammingLanguage</code>
  +   */
  +  protected String programmingLanguage;
  +
  +  /**
  +   * The default <code>MarkupLanguage</code>
  +   */
  +  public final static String DEFAULT_MARKUP_LANGUAGE = "xsp";
  +
  +  /**
  +   * The default <code>ProgrammingLanguage</code>
  +   */
  +  public final static String DEFAULT_PROGRAMMING_LANGUAGE = "java";
  +
  +
  +  /**
  +   * Generate XML data. This method loads a server pages generator associated
  +   * with its (file) input source and delegates SAX event generator to it
  +   * taking care of "closing" any event left open by the loaded generator as a
  +   * result of its possible "premature" return (a common situation in server
  +   * pages)
  +   *
  +   * @exception IOException IO Error
  +   * @exception SAXException SAX event generation error
  +   * @exception ProcessingException Error during load/execution
  +   */
  +  public void generate() throws IOException, SAXException, ProcessingException {
  +    EntityResolver resolver =
  +      (EntityResolver) this.manager.getComponent("cocoon");
  +    InputSource inputSource = resolver.resolveEntity(null, this.source);
  +
  +    String systemId = inputSource.getSystemId();
  +
  +    URL url = new URL(systemId);
  +    if (!url.getProtocol().equals("file")) {
  +      throw new IOException("Not a file: " + url.toString());
  +    } 
  +
  +    File file = new File(url.getFile());
  +
  +    if (!file.canRead()) {
  +      throw new IOException("Can't read file: " + url.toString());
  +    }
  +
  +    String markupLanguage = this.parameters.getParameter(
  +      "markup-language", DEFAULT_MARKUP_LANGUAGE
  +    );
  +    String programmingLanguage = this.parameters.getParameter(
  +      "programming-language", DEFAULT_PROGRAMMING_LANGUAGE
  +    );
  +
  +    Generator generator = null;
  +
  +    try {
  +      generator = (Generator)
  +        programGenerator.load(file, markupLanguage, programmingLanguage);
  +    } catch (Exception e) {
  +e.printStackTrace();
  +      throw new ProcessingException(e.getMessage());
  +    }
  +
  +    // Delegate XML production to loaded generator
  +    if (generator instanceof Composer) {
  +      ((Composer) generator).setComponentManager(this.manager);
  +    }
  +
  +    generator.setContentHandler(this);
  +    generator.setLexicalHandler(this);
  +    generator.setup(this.environment, this.source, this.parameters);
  +
  +    generator.generate();
  +
  +    // End any started events in case of premature return
  +    while (!this.eventStack.empty()) {
  +      EventData eventData = (EventData) this.eventStack.pop();
  +
  +      switch (eventData.eventType) {
  +        case DOCUMENT:
  +	  this.contentHandler.endDocument();
  +	  break;
  +	case ELEMENT:
  +	  this.contentHandler.endElement(
  +	    eventData.getNamespaceURI(),
  +	    eventData.getLocalName(),
  +	    eventData.getRawName()
  +	  );
  +	  break;
  +	case PREFIX_MAPPING:
  +	  this.contentHandler.endPrefixMapping(eventData.getPrefix());
  +	  break;
  +	case CDATA:
  +	  this.lexicalHandler.endCDATA();
  +	  break;
  +	case DTD:
  +	  this.lexicalHandler.endDTD();
  +	  break;
  +	case ENTITY:
  +	  this.lexicalHandler.endEntity(eventData.getName());
  +	  break;
  +      }
  +    }
  +  }    
  +
  +  /* Handlers */
  +
  +  /**
  +   * The SAX event stack. Used for "completing" pendind SAX events left "open"
  +   * by prematurely returning server pages generators
  +   */
  +  protected Stack eventStack = new Stack();
  +
  +    /**
  +     * Receive notification of character data.
  +     */
  +  public void characters(char[] ch, int start, int length) throws SAXException {
  +    this.contentHandler.characters(ch, start, length);
  +  }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +  public void endDocument() throws SAXException {
  +    this.eventStack.pop();
  +    this.contentHandler.endDocument();
  +  }
  +
  +    /**
  +     * Receive notification of the end of an element.
  +     */
  +  public void endElement(String namespaceURI, String localName, String rawName)
  +    throws SAXException
  +  {
  +    this.eventStack.pop();
  +    this.contentHandler.endElement(namespaceURI, localName, rawName);
  +  }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     */
  +  public void endPrefixMapping(String prefix) throws SAXException {
  +    this.eventStack.pop();
  +    this.contentHandler.endPrefixMapping(prefix);
  +  }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     */
  +  public void ignorableWhitespace(char[] ch, int start, int length)
  +    throws SAXException
  +  {
  +    this.contentHandler.ignorableWhitespace(ch, start, length);
  +  }
  +
  +    /**
  +     * Receive notification of a processing instruction.
  +     */
  +  public void processingInstruction(String target, String data)
  +    throws SAXException
  +  {
  +    this.contentHandler.processingInstruction(target, data);
  +  }
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     */
  +  public void setDocumentLocator(Locator locator) {
  +    this.contentHandler.setDocumentLocator(locator);
  +  }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     */
  +  public void skippedEntity(String name)
  +    throws SAXException
  +  {
  +    this.contentHandler.skippedEntity(name);
  +  }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +  public void startDocument() throws SAXException {
  +    this.contentHandler.startDocument();
  +    this.eventStack.push(new EventData(DOCUMENT));
  +  }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +  public void startElement(
  +    String namespaceURI, String localName, String rawName, Attributes atts
  +  )
  +    throws SAXException
  +  {
  +    this.contentHandler.startElement(namespaceURI, localName, rawName, atts);
  +    this.eventStack.push(new EventData(ELEMENT, namespaceURI, localName, rawName));
  +  }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     */
  +  public void startPrefixMapping(String prefix, String uri) throws SAXException
  +  {
  +    this.contentHandler.startPrefixMapping(prefix, uri);
  +    this.eventStack.push(new EventData(PREFIX_MAPPING, prefix));
  +  }
  +
  +  public void comment(char[] ch, int start, int length) throws SAXException {
  +    this.lexicalHandler.comment(ch, start, length);
  +  }
  +
  +  public void endCDATA() throws SAXException {
  +    this.lexicalHandler.endCDATA();
  +    this.eventStack.pop();
  +  }
  +
  +  public void endDTD() throws SAXException {
  +    this.lexicalHandler.endDTD();
  +    this.eventStack.pop();
  +  }
  +
  +  public void endEntity(String name) throws SAXException {
  +    this.lexicalHandler.endEntity(name);
  +    this.eventStack.pop();
  +  }
  +
  +  public void startCDATA() throws SAXException {
  +    this.lexicalHandler.startCDATA();
  +    this.eventStack.push(new EventData(CDATA));
  +  }
  +  
  +  public void startDTD(String name, String publicId, String systemId)
  +    throws SAXException
  +  {
  +    this.lexicalHandler.startDTD(name, publicId, systemId);
  +    this.eventStack.push(new EventData(DTD, name, publicId, systemId));
  +  }
  +
  +  public void startEntity(String name) throws SAXException {
  +    this.lexicalHandler.startEntity(name);
  +    this.eventStack.push(new EventData(ENTITY, name));
  +  }
  +
  +  protected final static int DOCUMENT = 0;
  +  protected final static int ELEMENT = 1;
  +  protected final static int PREFIX_MAPPING = 2;
  +  protected final static int CDATA = 3;
  +  protected final static int DTD = 4;
  +  protected final static int ENTITY = 5;
  +
  +  protected class EventData {
  +    protected int eventType;
  +    protected String namespaceURI;
  +    protected String localName;
  +    protected String rawName;
  +    protected String prefix;
  +    protected String publicId;
  +    protected String systemId;
  +    protected String name;
  +
  +    protected EventData(int eventType) {
  +      this.eventType = eventType; // DOCUMENT | CDATA
  +    }
  +
  +    protected EventData(
  +      int eventType, String data1, String data2, String data3
  +    )
  +    {
  +      this.eventType = eventType;
  +      switch (this.eventType) {
  +        case ELEMENT:
  +          this.namespaceURI = data1;
  +          this.localName = data2;
  +          this.rawName = data3;
  +	  break;
  +        case DTD:
  +          this.name = data1;
  +          this.publicId = data2;
  +          this.systemId = data3;
  +	  break;
  +      }
  +    }
  +
  +    protected EventData(int eventType, String data) {
  +      this.eventType = eventType;
  +      switch (this.eventType) {
  +        case PREFIX_MAPPING:
  +	  this.prefix = data;
  +	  break;
  +	case ENTITY:
  +	  this.name = data;
  +	  break;
  +      }
  +    }
  +
  +    protected String getNamespaceURI() { return this.namespaceURI; }
  +    protected String getLocalName() { return this.localName; }
  +    protected String getRawName() { return this.rawName; }
  +    protected String getPrefix() { return this.prefix; }
  +    protected String getPublicId() { return this.publicId; }
  +    protected String getSystemId() { return this.systemId; }
  +    protected String getName() { return this.name; }
  +  }
  +}
  
  
  
  1.1.2.2   +189 -189  xml-cocoon/src/org/apache/cocoon/generation/Attic/StatusGenerator.java
  
  Index: StatusGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/StatusGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- StatusGenerator.java	2000/07/12 22:15:09	1.1.2.1
  +++ StatusGenerator.java	2000/07/22 20:41:48	1.1.2.2
  @@ -1,189 +1,189 @@
  -/*****************************************************************************
  -* Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  -
  -import java.util.Calendar;
  -import java.util.Date;
  -import java.text.DateFormat;
  -import java.net.InetAddress;
  -import java.net.UnknownHostException;
  -
  -import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.AttributesImpl;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.ContentHandler;
  -
  -
  -/** Generates an XML representation of the current status of Cocoon.
  - * Potted DTD:
  - *
  - * <code>
  - * &lt;!ELEMENT statusinfo (group|value)*&gt;
  - *
  - * &lt;!ATTLIST statusinfo
  - *     date CDATA #IMPLIED
  - *     host CDATA #IMPLIED
  - * &gt;
  - *
  - * &lt;!ELEMENT group (group|value)*&gt;
  - * &lt;!ATTLIST group
  - *     name CDATA #IMPLIED
  - * &gt;
  - *
  - * &lt;!ELEMENT value (#PCDATA)&gt;
  - * &lt;!ATTLIST value
  - *     name CDATA #REQUIRED
  - * &gt;
  - * </code>
  - * 
  - * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a> (Luminas Limited)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/12 22:15:09 $
  - */
  -public class StatusGenerator extends ComposerGenerator {
  -
  -	/** The XML namespace for the output document.
  -	 */
  -	protected static final String namespace =
  -		"http://apache.org/cocoon/status";
  -
  -	/** The XML namespace for xlink
  -	 */
  -	protected static final String xlinkNamespace =
  -		"http://www.w3.org/1999/xlink";
  -		
  -	/** Generate the status information in XML format.
  -	 * @throws SAXException
  -	 *	when there is a problem creating the output SAX events.
  -	 */
  -	public void generate() throws SAXException {
  -	
  -		// Start the document and set the namespace.
  -		this.contentHandler.startDocument();
  -		this.contentHandler.startPrefixMapping("", namespace);
  -		this.contentHandler.startPrefixMapping("xlink", xlinkNamespace);
  -
  -		genStatus(this.contentHandler);
  -
  -		// End the document.
  -		this.contentHandler.endPrefixMapping("xlink");
  -		this.contentHandler.endPrefixMapping("");
  -		this.contentHandler.endDocument();
  -	}
  -
  -	/** Generate the main status document.
  -	 */
  -	private void genStatus(ContentHandler ch) throws SAXException {
  -		// Root element.
  -
  -		// The current date and time.
  -		String dateTime = DateFormat.getDateTimeInstance().format(new Date());
  -
  -		String localHost;
  -
  -		// The local host.
  -		try {
  -			localHost = InetAddress.getLocalHost().getHostName();
  -		} catch ( UnknownHostException e ) {
  -			localHost = "";
  -		} catch ( SecurityException e ) {
  -			localHost = "";
  -		}
  -		
  -		AttributesImpl atts = new AttributesImpl();
  -		atts.addAttribute(namespace, "date", "date", "CDATA", dateTime);
  -		atts.addAttribute(namespace, "host", "host", "CDATA", localHost);
  -		ch.startElement(namespace, "statusinfo", "statusinfo", atts);
  -
  -		genVMStatus(ch);
  -
  -		// End root element.
  -		ch.endElement(namespace, "statusinfo", "statusinfo");
  -	}
  -
  -	private void genVMStatus(ContentHandler ch) throws SAXException {
  -		String buf;
  -		AttributesImpl atts = new AttributesImpl();
  -	
  -		startGroup(ch, "vm");
  -		// BEGIN Memory status
  -		startGroup(ch, "memory");
  -		addValue(ch, "total", String.valueOf(Runtime.getRuntime().totalMemory()));
  -		addValue(ch, "free", String.valueOf(Runtime.getRuntime().freeMemory()));
  -		endGroup(ch);
  -		// END Memory status
  -		
  -		// BEGIN JRE
  -		startGroup(ch, "jre");
  -		addValue(ch, "version", System.getProperty("java.version"));
  -		atts.clear();
  -		atts.addAttribute(xlinkNamespace, "type", "type", "CDATA", "simple");
  -		atts.addAttribute(xlinkNamespace, "href", "href", "CDATA",
  -			System.getProperty("java.vendor.url") );
  -		addValue(ch, "java-vendor", System.getProperty("java.vendor"), atts);
  -		endGroup(ch);
  -		// END JRE
  -		
  -		// BEGIN Operating system
  -		startGroup(ch, "operating-system");
  -		addValue(ch, "name", System.getProperty("os.name"));
  -		addValue(ch, "architecture", System.getProperty("os.arch"));
  -		addValue(ch, "version", System.getProperty("os.version"));
  -		endGroup(ch);
  -		// END operating system
  -		
  -		addValue(ch, "classpath", System.getProperty("java.class.path"));
  -
  -		// BEGIN OS info
  -		endGroup(ch);
  -	}
  -
  -	/** Utility function to begin a <code>group</code> tag pair. */
  -	private void startGroup(ContentHandler ch, String name) throws SAXException {
  -		startGroup(ch, name, null);
  -	}
  -	
  -	/** Utility function to begin a <code>group</code> tag pair with added attributes. */
  -	private void startGroup(ContentHandler ch, String name, Attributes atts) throws SAXException {
  -		AttributesImpl ai;
  -		if ( atts == null ) {
  -			ai = new AttributesImpl();
  -		} else {
  -			ai = new AttributesImpl(atts);
  -		}
  -		ai.addAttribute(namespace, "name", "name", "CDATA", name);
  -		ch.startElement(namespace, "group", "group", ai);
  -	}
  -
  -	/** Utility function to end a <code>group</code> tag pair. */
  -	private void endGroup(ContentHandler ch) throws SAXException {
  -		ch.endElement(namespace, "group", "group");
  -	}
  -
  -	/** Utility function to begin and end a <code>value</code> tag pair. */
  -	private void addValue(ContentHandler ch, String name, String value) throws SAXException {
  -		addValue(ch, name, value, null);
  -	}
  -
  -	/** Utility function to begin and end a <code>value</code> tag pair with added attributes. */
  -	private void addValue(ContentHandler ch, String name, String value, Attributes atts) throws SAXException {
  -		AttributesImpl ai;
  -		if ( atts == null ) {
  -			ai = new AttributesImpl();
  -		} else {
  -			ai = new AttributesImpl(atts);
  -		}
  -		ai.addAttribute(namespace, "name", "name", "CDATA", name);
  -		ch.startElement(namespace, "value", "value", ai);
  -		if ( value != null ) {
  -			ch.characters(value.toCharArray(), 0, value.length());
  -		}
  -		ch.endElement(namespace, "value", "value");
  -	}
  -}
  - 
  +/*****************************************************************************
  +* Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.generation;
  +
  +import java.util.Calendar;
  +import java.util.Date;
  +import java.text.DateFormat;
  +import java.net.InetAddress;
  +import java.net.UnknownHostException;
  +
  +import org.xml.sax.SAXException;
  +import org.xml.sax.helpers.AttributesImpl;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.ContentHandler;
  +
  +
  +/** Generates an XML representation of the current status of Cocoon.
  + * Potted DTD:
  + *
  + * <code>
  + * &lt;!ELEMENT statusinfo (group|value)*&gt;
  + *
  + * &lt;!ATTLIST statusinfo
  + *     date CDATA #IMPLIED
  + *     host CDATA #IMPLIED
  + * &gt;
  + *
  + * &lt;!ELEMENT group (group|value)*&gt;
  + * &lt;!ATTLIST group
  + *     name CDATA #IMPLIED
  + * &gt;
  + *
  + * &lt;!ELEMENT value (#PCDATA)&gt;
  + * &lt;!ATTLIST value
  + *     name CDATA #REQUIRED
  + * &gt;
  + * </code>
  + * 
  + * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a> (Luminas Limited)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:48 $
  + */
  +public class StatusGenerator extends ComposerGenerator {
  +
  +	/** The XML namespace for the output document.
  +	 */
  +	protected static final String namespace =
  +		"http://apache.org/cocoon/status";
  +
  +	/** The XML namespace for xlink
  +	 */
  +	protected static final String xlinkNamespace =
  +		"http://www.w3.org/1999/xlink";
  +		
  +	/** Generate the status information in XML format.
  +	 * @throws SAXException
  +	 *	when there is a problem creating the output SAX events.
  +	 */
  +	public void generate() throws SAXException {
  +	
  +		// Start the document and set the namespace.
  +		this.contentHandler.startDocument();
  +		this.contentHandler.startPrefixMapping("", namespace);
  +		this.contentHandler.startPrefixMapping("xlink", xlinkNamespace);
  +
  +		genStatus(this.contentHandler);
  +
  +		// End the document.
  +		this.contentHandler.endPrefixMapping("xlink");
  +		this.contentHandler.endPrefixMapping("");
  +		this.contentHandler.endDocument();
  +	}
  +
  +	/** Generate the main status document.
  +	 */
  +	private void genStatus(ContentHandler ch) throws SAXException {
  +		// Root element.
  +
  +		// The current date and time.
  +		String dateTime = DateFormat.getDateTimeInstance().format(new Date());
  +
  +		String localHost;
  +
  +		// The local host.
  +		try {
  +			localHost = InetAddress.getLocalHost().getHostName();
  +		} catch ( UnknownHostException e ) {
  +			localHost = "";
  +		} catch ( SecurityException e ) {
  +			localHost = "";
  +		}
  +		
  +		AttributesImpl atts = new AttributesImpl();
  +		atts.addAttribute(namespace, "date", "date", "CDATA", dateTime);
  +		atts.addAttribute(namespace, "host", "host", "CDATA", localHost);
  +		ch.startElement(namespace, "statusinfo", "statusinfo", atts);
  +
  +		genVMStatus(ch);
  +
  +		// End root element.
  +		ch.endElement(namespace, "statusinfo", "statusinfo");
  +	}
  +
  +	private void genVMStatus(ContentHandler ch) throws SAXException {
  +		String buf;
  +		AttributesImpl atts = new AttributesImpl();
  +	
  +		startGroup(ch, "vm");
  +		// BEGIN Memory status
  +		startGroup(ch, "memory");
  +		addValue(ch, "total", String.valueOf(Runtime.getRuntime().totalMemory()));
  +		addValue(ch, "free", String.valueOf(Runtime.getRuntime().freeMemory()));
  +		endGroup(ch);
  +		// END Memory status
  +		
  +		// BEGIN JRE
  +		startGroup(ch, "jre");
  +		addValue(ch, "version", System.getProperty("java.version"));
  +		atts.clear();
  +		atts.addAttribute(xlinkNamespace, "type", "type", "CDATA", "simple");
  +		atts.addAttribute(xlinkNamespace, "href", "href", "CDATA",
  +			System.getProperty("java.vendor.url") );
  +		addValue(ch, "java-vendor", System.getProperty("java.vendor"), atts);
  +		endGroup(ch);
  +		// END JRE
  +		
  +		// BEGIN Operating system
  +		startGroup(ch, "operating-system");
  +		addValue(ch, "name", System.getProperty("os.name"));
  +		addValue(ch, "architecture", System.getProperty("os.arch"));
  +		addValue(ch, "version", System.getProperty("os.version"));
  +		endGroup(ch);
  +		// END operating system
  +		
  +		addValue(ch, "classpath", System.getProperty("java.class.path"));
  +
  +		// BEGIN OS info
  +		endGroup(ch);
  +	}
  +
  +	/** Utility function to begin a <code>group</code> tag pair. */
  +	private void startGroup(ContentHandler ch, String name) throws SAXException {
  +		startGroup(ch, name, null);
  +	}
  +	
  +	/** Utility function to begin a <code>group</code> tag pair with added attributes. */
  +	private void startGroup(ContentHandler ch, String name, Attributes atts) throws SAXException {
  +		AttributesImpl ai;
  +		if ( atts == null ) {
  +			ai = new AttributesImpl();
  +		} else {
  +			ai = new AttributesImpl(atts);
  +		}
  +		ai.addAttribute(namespace, "name", "name", "CDATA", name);
  +		ch.startElement(namespace, "group", "group", ai);
  +	}
  +
  +	/** Utility function to end a <code>group</code> tag pair. */
  +	private void endGroup(ContentHandler ch) throws SAXException {
  +		ch.endElement(namespace, "group", "group");
  +	}
  +
  +	/** Utility function to begin and end a <code>value</code> tag pair. */
  +	private void addValue(ContentHandler ch, String name, String value) throws SAXException {
  +		addValue(ch, name, value, null);
  +	}
  +
  +	/** Utility function to begin and end a <code>value</code> tag pair with added attributes. */
  +	private void addValue(ContentHandler ch, String name, String value, Attributes atts) throws SAXException {
  +		AttributesImpl ai;
  +		if ( atts == null ) {
  +			ai = new AttributesImpl();
  +		} else {
  +			ai = new AttributesImpl(atts);
  +		}
  +		ai.addAttribute(namespace, "name", "name", "CDATA", name);
  +		ch.startElement(namespace, "value", "value", ai);
  +		if ( value != null ) {
  +			ch.characters(value.toCharArray(), 0, value.length());
  +		}
  +		ch.endElement(namespace, "value", "value");
  +	}
  +}
  + 
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +25 -25    xml-cocoon/src/org/apache/cocoon/matching/Attic/AuthenticationMatcher.java
  
  Index: AuthenticationMatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/AuthenticationMatcher.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AuthenticationMatcher.java	2000/07/20 21:57:00	1.1.2.2
  +++ AuthenticationMatcher.java	2000/07/22 20:41:49	1.1.2.3
  @@ -1,25 +1,25 @@
  -package org.apache.cocoon.matching;
  -
  -import java.util.List;
  -import java.util.ArrayList;
  -
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -
  -public abstract class AuthenticationMatcher implements Matcher {
  -
  -	protected String username_parameter = "username";
  -	protected String password_parameter = "password";
  -
  -	public List match(String pattern, Environment environment) {
  -		if (match(((HttpEnvironment)environment).getRequest().getParameter(username_parameter),
  -                         ((HttpEnvironment)environment).getRequest().getParameter(password_parameter))) {
  -                    return new ArrayList();
  -                } else {
  -                    return null;
  -                }
  -	}
  -
  -	abstract boolean match(String username, String password);
  -
  -}
  +package org.apache.cocoon.matching;
  +
  +import java.util.List;
  +import java.util.ArrayList;
  +
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +
  +public abstract class AuthenticationMatcher implements Matcher {
  +
  +	protected String username_parameter = "username";
  +	protected String password_parameter = "password";
  +
  +	public List match(String pattern, Environment environment) {
  +		if (match(((HttpEnvironment)environment).getRequest().getParameter(username_parameter),
  +                         ((HttpEnvironment)environment).getRequest().getParameter(password_parameter))) {
  +                    return new ArrayList();
  +                } else {
  +                    return null;
  +                }
  +	}
  +
  +	abstract boolean match(String username, String password);
  +
  +}
  
  
  
  1.1.2.6   +60 -60    xml-cocoon/src/org/apache/cocoon/matching/Attic/BrowserMatcherFactory.java
  
  Index: BrowserMatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/BrowserMatcherFactory.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- BrowserMatcherFactory.java	2000/07/19 22:19:53	1.1.2.5
  +++ BrowserMatcherFactory.java	2000/07/22 20:41:49	1.1.2.6
  @@ -1,60 +1,60 @@
  -/***************************************************************************** 
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching; 
  -
  -import java.util.Stack;
  -
  -import org.w3c.dom.DocumentFragment;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.traversal.TreeWalker;
  -import org.w3c.dom.traversal.NodeFilter;
  -
  -import org.apache.xerces.dom.TreeWalkerImpl;
  - 
  -/** 
  - * This class generates source code which matches a specific browser pattern
  - * for request URIs
  - * 
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/19 22:19:53 $ 
  - */ 
  -
  -public class BrowserMatcherFactory implements MatcherFactory {
  -    public String generateMethodLevel (String prefix, String test_expression, DocumentFragment conf) throws Exception {
  -        StringBuffer sb = new StringBuffer();
  -        TreeWalker tw = new TreeWalkerImpl (conf, NodeFilter.SHOW_ALL, null, false);
  -        Node node = null;
  -        Node nodea = null;
  -        NamedNodeMap nm = null;
  -
  -        sb.append ("/*\n");
  -        while ((node = tw.nextNode()) != null) {
  -            sb.append("name=")
  -              .append(node.getNodeName())
  -              .append(" type=")
  -              .append(node.getNodeType())
  -              .append(" value="+node.getNodeValue()+"\n");
  -            nm = node.getAttributes();
  -            if (nm != null) {
  -                int i = nm.getLength();
  -                for (int j = 0; j < i; j++) {
  -                    nodea = nm.item(j);
  -                    sb.append("name="+nodea.getNodeName())
  -                      .append(" type="+nodea.getNodeType())
  -                      .append(" value="+nodea.getNodeValue()+"\n");
  -                }
  -            }
  -        }
  -        return sb.append("*/\nreturn null;").toString();
  -    }
  -
  -    public String generateClassLevel (String prefix, String pattern, DocumentFragment conf) throws Exception {
  -        return "";
  -    }
  -}
  +/***************************************************************************** 
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching; 
  +
  +import java.util.Stack;
  +
  +import org.w3c.dom.DocumentFragment;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.traversal.TreeWalker;
  +import org.w3c.dom.traversal.NodeFilter;
  +
  +import org.apache.xerces.dom.TreeWalkerImpl;
  + 
  +/** 
  + * This class generates source code which matches a specific browser pattern
  + * for request URIs
  + * 
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/22 20:41:49 $ 
  + */ 
  +
  +public class BrowserMatcherFactory implements MatcherFactory {
  +    public String generateMethodLevel (String prefix, String test_expression, DocumentFragment conf) throws Exception {
  +        StringBuffer sb = new StringBuffer();
  +        TreeWalker tw = new TreeWalkerImpl (conf, NodeFilter.SHOW_ALL, null, false);
  +        Node node = null;
  +        Node nodea = null;
  +        NamedNodeMap nm = null;
  +
  +        sb.append ("/*\n");
  +        while ((node = tw.nextNode()) != null) {
  +            sb.append("name=")
  +              .append(node.getNodeName())
  +              .append(" type=")
  +              .append(node.getNodeType())
  +              .append(" value="+node.getNodeValue()+"\n");
  +            nm = node.getAttributes();
  +            if (nm != null) {
  +                int i = nm.getLength();
  +                for (int j = 0; j < i; j++) {
  +                    nodea = nm.item(j);
  +                    sb.append("name="+nodea.getNodeName())
  +                      .append(" type="+nodea.getNodeType())
  +                      .append(" value="+nodea.getNodeValue()+"\n");
  +                }
  +            }
  +        }
  +        return sb.append("*/\nreturn null;").toString();
  +    }
  +
  +    public String generateClassLevel (String prefix, String pattern, DocumentFragment conf) throws Exception {
  +        return "";
  +    }
  +}
  
  
  
  1.1.2.3   +50 -52    xml-cocoon/src/org/apache/cocoon/matching/Attic/FileAuthenticationMatcher.java
  
  Index: FileAuthenticationMatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/FileAuthenticationMatcher.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- FileAuthenticationMatcher.java	2000/07/20 21:57:01	1.1.2.2
  +++ FileAuthenticationMatcher.java	2000/07/22 20:41:49	1.1.2.3
  @@ -1,52 +1,50 @@
  -package org.apache.cocoon.matching;
  -
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.List;
  -import java.util.ArrayList;
  -
  -import org.apache.avalon.Configurable;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  -import org.apache.cocoon.environment.Environment; 
  -import org.apache.cocoon.Request; 
  -import org.apache.cocoon.Response; 
  -import org.apache.avalon.utils.Parameters; 
  -
  -public class FileAuthenticationMatcher extends AuthenticationMatcher /* implements Configurable */ {
  -
  -	private Hashtable users = new Hashtable();
  -
  -	public void setConfiguration(Configuration conf) throws ConfigurationException {
  -		Enumeration params = conf.getConfigurations("param");
  -		while (params.hasMoreElements()) {
  -			Configuration param = (Configuration)params.nextElement();
  -			String name = param.getAttribute("name");
  -			String value = param.getAttribute("value");
  -			if (!name.equals("src")) {
  -				/** load the file indicated by value (relative to what?)
  -				    fill hashtable with users/passwords (plaintext for now)
  -			     **/
  -			}
  -		}
  -	}
  -
  -	public List match(String pattern, Environment environment) {
  -            return new ArrayList();
  -        }
  -	public boolean match(String user, String password) {
  -		if (user == null || password == null) {
  -			return false;
  -		}
  -		String value = (String)users.get(user);
  -		if (value == null || !value.equals(password)) {
  -			return false;
  -		} else {
  -			return true;
  -		}
  -	}
  -
  -        public void setup (Request req, Response res, String src, Parameters param) {
  -        }
  -
  -}
  +package org.apache.cocoon.matching;
  +
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import java.util.List;
  +import java.util.ArrayList;
  +
  +import org.apache.avalon.Configurable;
  +import org.apache.avalon.Configuration;
  +import org.apache.avalon.ConfigurationException;
  +import org.apache.cocoon.environment.Environment; 
  +import org.apache.avalon.utils.Parameters; 
  +
  +public class FileAuthenticationMatcher extends AuthenticationMatcher implements Configurable {
  +
  +	private Hashtable users = new Hashtable();
  +
  +	public void setConfiguration(Configuration conf) throws ConfigurationException {
  +		Enumeration params = conf.getConfigurations("param");
  +		while (params.hasMoreElements()) {
  +			Configuration param = (Configuration)params.nextElement();
  +			String name = param.getAttribute("name");
  +			String value = param.getAttribute("value");
  +			if (!name.equals("src")) {
  +				/** load the file indicated by value (relative to what?)
  +				    fill hashtable with users/passwords (plaintext for now)
  +			     **/
  +			}
  +		}
  +	}
  +
  +	public List match(String pattern, Environment environment) {
  +            return new ArrayList();
  +        }
  +	public boolean match(String user, String password) {
  +		if (user == null || password == null) {
  +			return false;
  +		}
  +		String value = (String)users.get(user);
  +		if (value == null || !value.equals(password)) {
  +			return false;
  +		} else {
  +			return true;
  +		}
  +	}
  +
  +   public void setup (Environment environment, String src, Parameters param) {
  +   }
  +
  +}
  
  
  
  1.1.2.4   +37 -37    xml-cocoon/src/org/apache/cocoon/matching/Attic/Matcher.java
  
  Index: Matcher.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/Matcher.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- Matcher.java	2000/07/20 21:57:02	1.1.2.3
  +++ Matcher.java	2000/07/22 20:41:49	1.1.2.4
  @@ -1,37 +1,37 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching;
  -
  -import java.util.List;
  -
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.environment.Environment;
  -
  -/**
  - *
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/20 21:57:02 $
  - */
  -public interface Matcher extends SitemapComponent {
  -    /**
  -     * Matches the pattern against some <code>Request</code> values
  -     * and returns a <code>Map</code> object with replacements
  -     * for wildcards contained in the pattern. 
  -     * @param pattern The pattern to match against. Depending on the
  -     *                implementation the pattern can contain wildcards
  -     *                or regular expressions.
  -     * @param request The <code>Request</code> object which can be used
  -     *                to select values this matchers matches against.
  -     * @return Map    The returned <code>Map</code> object with
  -     *                replacements for wildcards/regular-expressions 
  -     *                contained in the pattern.
  -     *                If the return value is null there was no match.
  -     */
  -    public List match (String pattern, Environment environment);
  -}
  -
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching;
  +
  +import java.util.List;
  +
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.environment.Environment;
  +
  +/**
  + *
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:49 $
  + */
  +public interface Matcher extends SitemapComponent {
  +    /**
  +     * Matches the pattern against some <code>Request</code> values
  +     * and returns a <code>Map</code> object with replacements
  +     * for wildcards contained in the pattern. 
  +     * @param pattern The pattern to match against. Depending on the
  +     *                implementation the pattern can contain wildcards
  +     *                or regular expressions.
  +     * @param request The <code>Request</code> object which can be used
  +     *                to select values this matchers matches against.
  +     * @return Map    The returned <code>Map</code> object with
  +     *                replacements for wildcards/regular-expressions 
  +     *                contained in the pattern.
  +     *                If the return value is null there was no match.
  +     */
  +    public List match (String pattern, Environment environment);
  +}
  +
  
  
  
  1.1.2.4   +27 -27    xml-cocoon/src/org/apache/cocoon/matching/Attic/MatcherFactory.java
  
  Index: MatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/MatcherFactory.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- MatcherFactory.java	2000/07/19 22:19:53	1.1.2.3
  +++ MatcherFactory.java	2000/07/22 20:41:49	1.1.2.4
  @@ -1,27 +1,27 @@
  -/***************************************************************************** 
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching; 
  -
  -import org.w3c.dom.DocumentFragment;
  - 
  -/** 
  - * Interface a class has to implement that produces java source code 
  - * representing logic for a <code>Matcher</code>s match method. The 
  - * returned source code will be directly integrated into a method of the 
  - * generated sitemap code. 
  - * This <code>MatcherFactory</code>s generate method will be called during 
  - * sitemap code generation.
  - * 
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/19 22:19:53 $ 
  - */ 
  -
  -public interface MatcherFactory {
  -    public String generateClassLevel (String prefix, String pattern, DocumentFragment conf) throws Exception;
  -    public String generateMethodLevel (String prefix, String pattern, DocumentFragment conf) throws Exception;
  -}
  +/***************************************************************************** 
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching; 
  +
  +import org.w3c.dom.DocumentFragment;
  + 
  +/** 
  + * Interface a class has to implement that produces java source code 
  + * representing logic for a <code>Matcher</code>s match method. The 
  + * returned source code will be directly integrated into a method of the 
  + * generated sitemap code. 
  + * This <code>MatcherFactory</code>s generate method will be called during 
  + * sitemap code generation.
  + * 
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:49 $ 
  + */ 
  +
  +public interface MatcherFactory {
  +    public String generateClassLevel (String prefix, String pattern, DocumentFragment conf) throws Exception;
  +    public String generateMethodLevel (String prefix, String pattern, DocumentFragment conf) throws Exception;
  +}
  
  
  
  1.1.2.3   +74 -74    xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpURIMatcherFactory.java
  
  Index: RegexpURIMatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpURIMatcherFactory.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- RegexpURIMatcherFactory.java	2000/07/20 21:57:02	1.1.2.2
  +++ RegexpURIMatcherFactory.java	2000/07/22 20:41:49	1.1.2.3
  @@ -1,74 +1,74 @@
  -/***************************************************************************** 
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching; 
  -
  -import org.apache.regexp.RECompiler;
  -import org.apache.regexp.REProgram;
  -import org.apache.regexp.RESyntaxException;
  -
  -import org.w3c.dom.DocumentFragment;
  - 
  -/** 
  - * This class generates source code which represents a specific pattern matcher
  - * for request URIs
  - * 
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/20 21:57:02 $ 
  - */ 
  -
  -public class RegexpURIMatcherFactory implements MatcherFactory {
  -    public String generateClassLevel (String prefix, String pattern, DocumentFragment conf) throws Exception {
  -        StringBuffer sb = new StringBuffer ();
  -        RECompiler r = new RECompiler();
  -        String name         = prefix+"_re";
  -        String instructions = name + "PatternInstructions";
  -        sb.append("\n    // Pre-compiled regular expression '")
  -          .append(pattern).append("'\n")
  -          .append("    static char[] ");
  -        sb.append(instructions).append(" = \n    {");
  -        REProgram program = r.compile(pattern);
  -        int numColumns = 7;
  -        char[] p = program.getInstructions();
  -        for (int j = 0; j < p.length; j++) {
  -            if ((j % numColumns) == 0) {
  -                sb.append("\n        ");
  -            }
  -            String hex = Integer.toHexString(p[j]);
  -            while (hex.length() < 4) {
  -                hex = "0" + hex;
  -            }
  -            sb.append("0x").append(hex).append(", ");
  -        }
  -        sb.append("\n    };")
  -          .append("\n    static org.apache.regexp.RE ") 
  -          .append(name)
  -          .append("Pattern = new org.apache.regexp.RE(new org.apache.regexp.REProgram(")
  -          .append(instructions)
  -          .append("));");
  -        return sb.toString();
  -    }
  -
  -    public String generateMethodLevel (String prefix, String pattern, DocumentFragment conf) throws Exception {
  -        StringBuffer sb = new StringBuffer ();
  -        String name         = prefix+"_re";
  -        String instructions = name + "PatternInstructions";
  -        sb.append("java.util.ArrayList list = new java.util.ArrayList ();")
  -          .append("if (").append(name).append("Pattern.match(request.getURI())) {");
  -        // Count number of parens
  -        int i = 0;
  -        int j = -1;
  -        while ((j = pattern.indexOf('(', j+1)) != -1) {
  -            if (j == 0 || pattern.charAt(j-1) != '\\') {
  -                sb.append("list.add (").append(name).append("Pattern.getParen(")
  -                  .append(++i).append("));");
  -            }
  -        }
  -        sb.append("return list; } else { return null; }");
  -        return sb.toString();
  -    }
  -}
  +/***************************************************************************** 
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching; 
  +
  +import org.apache.regexp.RECompiler;
  +import org.apache.regexp.REProgram;
  +import org.apache.regexp.RESyntaxException;
  +
  +import org.w3c.dom.DocumentFragment;
  + 
  +/** 
  + * This class generates source code which represents a specific pattern matcher
  + * for request URIs
  + * 
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:49 $ 
  + */ 
  +
  +public class RegexpURIMatcherFactory implements MatcherFactory {
  +    public String generateClassLevel (String prefix, String pattern, DocumentFragment conf) throws Exception {
  +        StringBuffer sb = new StringBuffer ();
  +        RECompiler r = new RECompiler();
  +        String name         = prefix;
  +        String instructions = name + "PatternInstructions";
  +        sb.append("\n    // Pre-compiled regular expression '")
  +          .append(pattern).append("'\n")
  +          .append("    static char[] ");
  +        sb.append(instructions).append(" = \n    {");
  +        REProgram program = r.compile(pattern);
  +        int numColumns = 7;
  +        char[] p = program.getInstructions();
  +        for (int j = 0; j < p.length; j++) {
  +            if ((j % numColumns) == 0) {
  +                sb.append("\n        ");
  +            }
  +            String hex = Integer.toHexString(p[j]);
  +            while (hex.length() < 4) {
  +                hex = "0" + hex;
  +            }
  +            sb.append("0x").append(hex).append(", ");
  +        }
  +        sb.append("\n    };")
  +          .append("\n    static org.apache.regexp.RE ") 
  +          .append(name)
  +          .append("Pattern = new org.apache.regexp.RE(new org.apache.regexp.REProgram(")
  +          .append(instructions)
  +          .append("));");
  +        return sb.toString();
  +    }
  +
  +    public String generateMethodLevel (String prefix, String pattern, DocumentFragment conf) throws Exception {
  +        StringBuffer sb = new StringBuffer ();
  +        String name         = prefix;
  +        String instructions = name + "PatternInstructions";
  +        sb.append("java.util.ArrayList list = new java.util.ArrayList ();")
  +          .append("if (").append(name).append("Pattern.match(environment.getUri())) {");
  +        // Count number of parens
  +        int i = 0;
  +        int j = -1;
  +        while ((j = pattern.indexOf('(', j+1)) != -1) {
  +            if (j == 0 || pattern.charAt(j-1) != '\\') {
  +                sb.append("list.add (").append(name).append("Pattern.getParen(")
  +                  .append(++i).append("));");
  +            }
  +        }
  +        sb.append("return list; } else { return null; }");
  +        return sb.toString();
  +    }
  +}
  
  
  
  1.1.2.5   +161 -161  xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java
  
  Index: WildcardURIMatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- WildcardURIMatcherFactory.java	2000/07/20 21:57:03	1.1.2.4
  +++ WildcardURIMatcherFactory.java	2000/07/22 20:41:49	1.1.2.5
  @@ -1,161 +1,161 @@
  -/***************************************************************************** 
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching; 
  -
  -import org.apache.cocoon.sitemap.patterns.PatternTranslator; 
  -import org.apache.cocoon.sitemap.patterns.PatternException; 
  -
  -import org.w3c.dom.DocumentFragment;
  - 
  -/** 
  - * This class generates source code which represents a specific pattern matcher
  - * for request URIs
  - * 
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/20 21:57:03 $ 
  - */ 
  -
  -public class WildcardURIMatcherFactory /*extends PatternTranslator*/ implements MatcherFactory {
  -
  -    /** The int representing '*' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_FILE=-1;
  -    /** The int representing '**' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_PATH=-2;
  -    /** The int value that terminates the pattern <code>int []</code>. */
  -    protected static final int MATCH_END=-3;
  -
  -    /** The <code>int []</code> identifying the pattern to match. */
  -    protected int[] sourcePattern=null;
  -
  -    /**
  -     * Generates the matcher method level source code
  -     */
  -    public String generateMethodLevel (String prefix, String pattern, DocumentFragment conf) 
  -    throws PatternException {
  -        StringBuffer result = new StringBuffer();
  -        return result.append ("java.util.ArrayList list = new ArrayList();")
  -                     .append ("if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (list, environment.getUri(), ")
  -                     .append(prefix).append("_expr))")
  -                     .append ("return list;")
  -                     .append ("else return null;").toString();
  -    }
  -
  -    /**
  -     * Generates the matcher class level source code
  -     */
  -    public String generateClassLevel (String prefix, String pattern, DocumentFragment conf) 
  -    throws PatternException {
  -        StringBuffer result = new StringBuffer();
  -        this.setPattern (pattern);
  -   
  -        result.append ("/* pattern=\""+pattern+"\" */")
  -              .append ("int expr[] = {");
  -
  -        int j = sourcePattern.length-1;
  -        char c;
  -        for (int i = 0; i < j; i++) {
  -            result.append (sourcePattern[i])
  -                  .append (',');
  -        }
  -        return result.append (sourcePattern[j])
  -                     .append ("};").toString();
  -    }
  -
  -    /**
  -     * Set the pattern for matching.
  -     */
  -    public void setPattern(String pattern)
  -    throws PatternException {
  -        if (pattern==null) throw new PatternException("Null pattern");
  -        this.sourcePattern=this.convertPattern(pattern);
  -    }
  -
  -    /**
  -     * Translate the given <code>String</code> into a <code>int []</code>
  -     * representing the pattern matchable by this class.
  -     * <br>
  -     * This function translates a <code>String</code> into an int array
  -     * converting the special '*' and '\' characters.
  -     * <br>
  -     * Here is how the conversion algorithm works:
  -     * <ul>
  -     *   <li>The '*' character is converted to MATCH_FILE, meaning that zero
  -     *        or more characters (excluding the path separator '/') are to
  -     *        be matched.</li>
  -     *   <li>The '**' sequence is converted to MATCH_PATH, meaning that zero
  -     *       or more characters (including the path separator '/') are to
  -     *        be matched.</li>
  -     *   <li>The '\' character is used as an escape sequence ('\*' is
  -     *       translated in '*', not in MATCH_FILE). If an exact '\' character
  -     *       is to be matched the source string must contain a '\\'.
  -     *       sequence.</li>
  -     * </ul>
  -     * When more than two '*' characters, not separated by another character,
  -     * are found their value is considered as '**' (MATCH_PATH).
  -     * <br>
  -     * The array is always terminated by a special value (MATCH_END).
  -     * <br>
  -     * All MATCH* values are less than zero, while normal characters are equal
  -     * or greater.
  -     *
  -     * @parameter data The string to translate.
  -     * @return The encoded string as an int array, terminated by the MATCH_END
  -     *         value (don't consider the array length).
  -     * @exception NullPointerException If data is null.
  -     */
  -    protected int[] convertPattern(String data)
  -    throws NullPointerException {
  -        // Prepare the arrays
  -        int expr[]=new int[data.length()+1];
  -        char buff[]=data.toCharArray();
  -        // Prepare variables for the translation loop
  -        int y=0;
  -        boolean slash=false;
  -        if(buff[0]=='\\') slash=true;
  -        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  -        else expr[y++]=buff[0];
  -        // Main translation loop
  -        for (int x=1; x<buff.length; x++) {
  -            // If the previous char was '\' simply copy this char.
  -            if (slash) {
  -                expr[y++]=buff[x];
  -                slash=false;
  -            // If the previous char was not '\' we have to do a bunch of checks
  -            } else {
  -                int prev=(y-1);
  -                // If this char is '\' declare that and continue
  -                if(buff[x]=='\\') {
  -                    slash=true;
  -                // If this char is '*' check the previous one
  -                } else if(buff[x]=='*') {
  -                    // If the previous character als was '*' match a path
  -                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  -                    else expr[y++]=MATCH_FILE;
  -                } else expr[y++]=buff[x];
  -            }
  -        }
  -        // Declare the end of the array and return it
  -        expr[y]=MATCH_END;
  -        return(expr);
  -    }        
  -     
  -    /** Testing */
  -    public static void main(String argv[]) {
  -        try {
  -            if (argv.length<1) return;
  -            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  -            WildcardURIMatcherFactory wm = new WildcardURIMatcherFactory();
  -            System.out.println(wm.generateClassLevel ("", argv[0], null));
  -            System.out.println(wm.generateMethodLevel ("", argv[0], null));
  -        } catch (Exception e) {
  -            System.out.println(e.getClass().getName());
  -            System.out.println(e.getMessage());
  -        }
  -    }
  -
  -}
  +/***************************************************************************** 
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching; 
  +
  +import org.apache.cocoon.sitemap.patterns.PatternTranslator; 
  +import org.apache.cocoon.sitemap.patterns.PatternException; 
  +
  +import org.w3c.dom.DocumentFragment;
  + 
  +/** 
  + * This class generates source code which represents a specific pattern matcher
  + * for request URIs
  + * 
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:49 $ 
  + */ 
  +
  +public class WildcardURIMatcherFactory /*extends PatternTranslator*/ implements MatcherFactory {
  +
  +    /** The int representing '*' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_FILE=-1;
  +    /** The int representing '**' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_PATH=-2;
  +    /** The int value that terminates the pattern <code>int []</code>. */
  +    protected static final int MATCH_END=-3;
  +
  +    /** The <code>int []</code> identifying the pattern to match. */
  +    protected int[] sourcePattern=null;
  +
  +    /**
  +     * Generates the matcher method level source code
  +     */
  +    public String generateMethodLevel (String prefix, String pattern, DocumentFragment conf) 
  +    throws PatternException {
  +        StringBuffer result = new StringBuffer();
  +        return result.append ("java.util.ArrayList list = new ArrayList();")
  +                     .append ("if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (list, environment.getUri(), ")
  +                     .append(prefix).append("_expr))")
  +                     .append ("return list;")
  +                     .append ("else return null;").toString();
  +    }
  +
  +    /**
  +     * Generates the matcher class level source code
  +     */
  +    public String generateClassLevel (String prefix, String pattern, DocumentFragment conf) 
  +    throws PatternException {
  +        StringBuffer result = new StringBuffer();
  +        this.setPattern (pattern);
  +   
  +        result.append ("/* pattern=\""+pattern+"\" */")
  +              .append ("int expr[] = {");
  +
  +        int j = sourcePattern.length-1;
  +        char c;
  +        for (int i = 0; i < j; i++) {
  +            result.append (sourcePattern[i])
  +                  .append (',');
  +        }
  +        return result.append (sourcePattern[j])
  +                     .append ("};").toString();
  +    }
  +
  +    /**
  +     * Set the pattern for matching.
  +     */
  +    public void setPattern(String pattern)
  +    throws PatternException {
  +        if (pattern==null) throw new PatternException("Null pattern");
  +        this.sourcePattern=this.convertPattern(pattern);
  +    }
  +
  +    /**
  +     * Translate the given <code>String</code> into a <code>int []</code>
  +     * representing the pattern matchable by this class.
  +     * <br>
  +     * This function translates a <code>String</code> into an int array
  +     * converting the special '*' and '\' characters.
  +     * <br>
  +     * Here is how the conversion algorithm works:
  +     * <ul>
  +     *   <li>The '*' character is converted to MATCH_FILE, meaning that zero
  +     *        or more characters (excluding the path separator '/') are to
  +     *        be matched.</li>
  +     *   <li>The '**' sequence is converted to MATCH_PATH, meaning that zero
  +     *       or more characters (including the path separator '/') are to
  +     *        be matched.</li>
  +     *   <li>The '\' character is used as an escape sequence ('\*' is
  +     *       translated in '*', not in MATCH_FILE). If an exact '\' character
  +     *       is to be matched the source string must contain a '\\'.
  +     *       sequence.</li>
  +     * </ul>
  +     * When more than two '*' characters, not separated by another character,
  +     * are found their value is considered as '**' (MATCH_PATH).
  +     * <br>
  +     * The array is always terminated by a special value (MATCH_END).
  +     * <br>
  +     * All MATCH* values are less than zero, while normal characters are equal
  +     * or greater.
  +     *
  +     * @parameter data The string to translate.
  +     * @return The encoded string as an int array, terminated by the MATCH_END
  +     *         value (don't consider the array length).
  +     * @exception NullPointerException If data is null.
  +     */
  +    protected int[] convertPattern(String data)
  +    throws NullPointerException {
  +        // Prepare the arrays
  +        int expr[]=new int[data.length()+1];
  +        char buff[]=data.toCharArray();
  +        // Prepare variables for the translation loop
  +        int y=0;
  +        boolean slash=false;
  +        if(buff[0]=='\\') slash=true;
  +        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  +        else expr[y++]=buff[0];
  +        // Main translation loop
  +        for (int x=1; x<buff.length; x++) {
  +            // If the previous char was '\' simply copy this char.
  +            if (slash) {
  +                expr[y++]=buff[x];
  +                slash=false;
  +            // If the previous char was not '\' we have to do a bunch of checks
  +            } else {
  +                int prev=(y-1);
  +                // If this char is '\' declare that and continue
  +                if(buff[x]=='\\') {
  +                    slash=true;
  +                // If this char is '*' check the previous one
  +                } else if(buff[x]=='*') {
  +                    // If the previous character als was '*' match a path
  +                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  +                    else expr[y++]=MATCH_FILE;
  +                } else expr[y++]=buff[x];
  +            }
  +        }
  +        // Declare the end of the array and return it
  +        expr[y]=MATCH_END;
  +        return(expr);
  +    }        
  +     
  +    /** Testing */
  +    public static void main(String argv[]) {
  +        try {
  +            if (argv.length<1) return;
  +            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  +            WildcardURIMatcherFactory wm = new WildcardURIMatcherFactory();
  +            System.out.println(wm.generateClassLevel ("", argv[0], null));
  +            System.out.println(wm.generateMethodLevel ("", argv[0], null));
  +        } catch (Exception e) {
  +            System.out.println(e.getClass().getName());
  +            System.out.println(e.getMessage());
  +        }
  +    }
  +
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +205 -205  xml-cocoon/src/org/apache/cocoon/matching/helpers/Attic/WildcardURIMatcher.java
  
  Index: WildcardURIMatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/helpers/Attic/WildcardURIMatcher.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- WildcardURIMatcher.java	2000/07/11 23:46:45	1.1.2.1
  +++ WildcardURIMatcher.java	2000/07/22 20:41:51	1.1.2.2
  @@ -1,205 +1,205 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching.helpers;
  -
  -import java.util.Stack;
  -
  -/**
  - * This class is an utility class that perform wilcard-patterns matching and
  - * isolation.
  - * <br>
  - * 
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:45 $
  - */
  -public class WildcardURIMatcher {
  -
  -    /** The int representing '*' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_FILE=-1;
  -    /** The int representing '**' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_PATH=-2;
  -    /** The int value that terminates the pattern <code>int []</code>. */
  -    protected static final int MATCH_END=-3;
  -
  -    /**
  -     * match a pattern agains a string and isolates wildcard replacement into a 
  -     * <code>Stack</code>.
  -     */
  -    public static boolean match (Stack stack, String data, int[] expr) 
  -    throws NullPointerException {
  -        if (stack == null) throw new NullPointerException ("No Stack provided");
  -        if (data == null) throw new NullPointerException ("No data provided");
  -        if (expr == null) throw new NullPointerException ("No pattern expression provided");
  -        
  -        char buff[] = data.toCharArray ();
  -        // Allocate the result buffer
  -        char rslt[]=new char[expr.length+buff.length];
  -        
  -        // The previous and current position of the expression character
  -        // (MATCH_*)
  -        int charpos = 0;
  -        // Search the fist expression character
  -        while (expr[charpos] >= 0) charpos++;
  -        // The expression charater (MATCH_*)
  -        int exprchr = expr[charpos];
  -
  -        // The position in the expression, input, translation and result arrays
  -        int exprpos = 0;
  -        int buffpos = 0;
  -        int trnspos = 0;
  -        int rsltpos = 0;
  -        int offset = -1;
  -        
  -        while (true) {
  -            // Check if the data in the expression array before the current
  -            // expression character matches the data in the input buffer
  -            offset = matchArray (expr, exprpos, charpos, buff, buffpos);
  -            if (offset < 0) return(false);
  -
  -            // Copy the data from the translation buffer into the result buffer
  -            // up to the next expression character (arriving to the current in the
  -            // expression buffer)        
  -            // while (trns[trnspos] >= 0) rslt[rsltpos++] = (char)trns[trnspos++];
  -            // trnspos++;
  -                
  -            if (exprchr == MATCH_END) {
  -                if (rsltpos > 0)
  -                    stack.push (new String(rslt, 0, rsltpos));
  -                return (true);
  -            }
  -            
  -            // Search the next expression character
  -            buffpos += (charpos-exprpos);
  -            exprpos = ++charpos;
  -            while (expr[charpos] >= 0) charpos++;
  -            int prevchr = exprchr;
  -            exprchr = expr[charpos];
  -   
  -            offset = matchArray (expr, exprpos, charpos, buff, buffpos);
  -            if (offset < 0) return (false);
  -    
  -            // Copy the data from the source buffer into the result buffer
  -            // to substitute the expression character
  -            if (prevchr == MATCH_PATH) {
  -                while (buffpos < offset) rslt[rsltpos++] = buff[buffpos++];
  -            } else {
  -                // Matching file, don't copy '/'
  -                while (buffpos < offset) {
  -                    if (buff[buffpos] == '/') return (false);
  -                    rslt[rsltpos++] = buff[buffpos++];
  -                }
  -            stack.push (new String (rslt, 0, rsltpos));
  -            rsltpos = 0;
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Get the offset of a part of an int array within a char array.
  -     * <br>
  -     * This method return the index in d of the first occurrence after dpos of
  -     * that part of array specified by r, starting at rpos and terminating at
  -     * rend.
  -     *
  -     * @param r The array containing the data that need to be matched in d.
  -     * @param rpos The index of the first character in r to look for.
  -     * @param rend The index of the last character in r to look for plus 1.
  -     * @param d The array of char that should contain a part of r.
  -     * @param dpos The starting offset in d for the matching.
  -     * @return The offset in d of the part of r matched in d or -1 if that was
  -     *         not found.
  -     */
  -    protected static int matchArray (int r[], int rpos, int rend, char d[], int dpos) {
  -        // Check if pos and len are legal
  -        if (rend < rpos) throw new IllegalArgumentException ("rend < rpos");
  -        // If we need to match a zero length string return current dpos
  -        if (rend == rpos) return (d.length); //?? dpos?
  -        // If we need to match a 1 char length string do it simply
  -        if ((rend - rpos) == 1) {
  -            // Search for the specified character
  -            for (int x = dpos; x < d.length; x++) 
  -                if (r[rpos] == d[x]) return (x);
  -        }
  -        // Main string matching loop. It gets executed if the characters to
  -        // match are less then the characters left in the d buffer
  -        while ((dpos + rend - rpos) <= d.length) {
  -            // Set current startpoint in d
  -            int y = dpos;
  -            // Check every character in d for equity. If the string is matched
  -            // return dpos
  -            for (int x = rpos; x <= rend; x++) {
  -                if (x == rend) return (dpos);
  -                if (r[x] == d[y]) y++;
  -                else break;
  -            }
  -            // Increase dpos to search for the same string at next offset
  -            dpos++;
  -        }
  -        // The remaining chars in d buffer were not enough or the string 
  -        // wasn't matched
  -        return (-1);
  -    }
  -
  -    protected static int[] convertPattern(String data)
  -    throws NullPointerException {
  -        // Prepare the arrays
  -        int expr[]=new int[data.length()+1];
  -        char buff[]=data.toCharArray();
  -        // Prepare variables for the translation loop
  -        int y=0;
  -        boolean slash=false;
  -        if(buff[0]=='\\') slash=true;
  -        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  -        else expr[y++]=buff[0];
  -        // Main translation loop
  -        for (int x=1; x<buff.length; x++) {
  -            // If the previous char was '\' simply copy this char.
  -            if (slash) {
  -                expr[y++]=buff[x];
  -                slash=false;
  -            // If the previous char was not '\' we have to do a bunch of checks
  -            } else {
  -                int prev=(y-1);
  -                // If this char is '\' declare that and continue
  -                if(buff[x]=='\\') {
  -                    slash=true;
  -                // If this char is '*' check the previous one
  -                } else if(buff[x]=='*') {
  -                    // If the previous character als was '*' match a path
  -                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  -                    else expr[y++]=MATCH_FILE;
  -                } else expr[y++]=buff[x];
  -            }
  -        }
  -        // Declare the end of the array and return it
  -        expr[y]=MATCH_END;
  -        return(expr);
  -    }        
  -    
  -    /** Testing */
  -    public static void main(String argv[]) {
  -        try {
  -            if (argv.length<2) return;
  -            Stack stack = new Stack();
  -            int expr[] = convertPattern (argv[0]);
  -            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  -            System.out.println("Uri String. \""+argv[1]+"\"");
  -            if (WildcardURIMatcher.match (stack, argv[1], expr)) {
  -                System.out.println("Matched");
  -                for (int i = 0; i < stack.size(); i++)
  -                    System.out.println(i+" "+(String)stack.elementAt (i));
  -            } else
  -                System.out.println("Not matched");
  -        } catch (Exception e) {
  -            System.out.println(e.getClass().getName());
  -            System.out.println(e.getMessage());
  -        }
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.matching.helpers;
  +
  +import java.util.Stack;
  +
  +/**
  + * This class is an utility class that perform wilcard-patterns matching and
  + * isolation.
  + * <br>
  + * 
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:51 $
  + */
  +public class WildcardURIMatcher {
  +
  +    /** The int representing '*' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_FILE=-1;
  +    /** The int representing '**' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_PATH=-2;
  +    /** The int value that terminates the pattern <code>int []</code>. */
  +    protected static final int MATCH_END=-3;
  +
  +    /**
  +     * match a pattern agains a string and isolates wildcard replacement into a 
  +     * <code>Stack</code>.
  +     */
  +    public static boolean match (Stack stack, String data, int[] expr) 
  +    throws NullPointerException {
  +        if (stack == null) throw new NullPointerException ("No Stack provided");
  +        if (data == null) throw new NullPointerException ("No data provided");
  +        if (expr == null) throw new NullPointerException ("No pattern expression provided");
  +        
  +        char buff[] = data.toCharArray ();
  +        // Allocate the result buffer
  +        char rslt[]=new char[expr.length+buff.length];
  +        
  +        // The previous and current position of the expression character
  +        // (MATCH_*)
  +        int charpos = 0;
  +        // Search the fist expression character
  +        while (expr[charpos] >= 0) charpos++;
  +        // The expression charater (MATCH_*)
  +        int exprchr = expr[charpos];
  +
  +        // The position in the expression, input, translation and result arrays
  +        int exprpos = 0;
  +        int buffpos = 0;
  +        int trnspos = 0;
  +        int rsltpos = 0;
  +        int offset = -1;
  +        
  +        while (true) {
  +            // Check if the data in the expression array before the current
  +            // expression character matches the data in the input buffer
  +            offset = matchArray (expr, exprpos, charpos, buff, buffpos);
  +            if (offset < 0) return(false);
  +
  +            // Copy the data from the translation buffer into the result buffer
  +            // up to the next expression character (arriving to the current in the
  +            // expression buffer)        
  +            // while (trns[trnspos] >= 0) rslt[rsltpos++] = (char)trns[trnspos++];
  +            // trnspos++;
  +                
  +            if (exprchr == MATCH_END) {
  +                if (rsltpos > 0)
  +                    stack.push (new String(rslt, 0, rsltpos));
  +                return (true);
  +            }
  +            
  +            // Search the next expression character
  +            buffpos += (charpos-exprpos);
  +            exprpos = ++charpos;
  +            while (expr[charpos] >= 0) charpos++;
  +            int prevchr = exprchr;
  +            exprchr = expr[charpos];
  +   
  +            offset = matchArray (expr, exprpos, charpos, buff, buffpos);
  +            if (offset < 0) return (false);
  +    
  +            // Copy the data from the source buffer into the result buffer
  +            // to substitute the expression character
  +            if (prevchr == MATCH_PATH) {
  +                while (buffpos < offset) rslt[rsltpos++] = buff[buffpos++];
  +            } else {
  +                // Matching file, don't copy '/'
  +                while (buffpos < offset) {
  +                    if (buff[buffpos] == '/') return (false);
  +                    rslt[rsltpos++] = buff[buffpos++];
  +                }
  +            stack.push (new String (rslt, 0, rsltpos));
  +            rsltpos = 0;
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Get the offset of a part of an int array within a char array.
  +     * <br>
  +     * This method return the index in d of the first occurrence after dpos of
  +     * that part of array specified by r, starting at rpos and terminating at
  +     * rend.
  +     *
  +     * @param r The array containing the data that need to be matched in d.
  +     * @param rpos The index of the first character in r to look for.
  +     * @param rend The index of the last character in r to look for plus 1.
  +     * @param d The array of char that should contain a part of r.
  +     * @param dpos The starting offset in d for the matching.
  +     * @return The offset in d of the part of r matched in d or -1 if that was
  +     *         not found.
  +     */
  +    protected static int matchArray (int r[], int rpos, int rend, char d[], int dpos) {
  +        // Check if pos and len are legal
  +        if (rend < rpos) throw new IllegalArgumentException ("rend < rpos");
  +        // If we need to match a zero length string return current dpos
  +        if (rend == rpos) return (d.length); //?? dpos?
  +        // If we need to match a 1 char length string do it simply
  +        if ((rend - rpos) == 1) {
  +            // Search for the specified character
  +            for (int x = dpos; x < d.length; x++) 
  +                if (r[rpos] == d[x]) return (x);
  +        }
  +        // Main string matching loop. It gets executed if the characters to
  +        // match are less then the characters left in the d buffer
  +        while ((dpos + rend - rpos) <= d.length) {
  +            // Set current startpoint in d
  +            int y = dpos;
  +            // Check every character in d for equity. If the string is matched
  +            // return dpos
  +            for (int x = rpos; x <= rend; x++) {
  +                if (x == rend) return (dpos);
  +                if (r[x] == d[y]) y++;
  +                else break;
  +            }
  +            // Increase dpos to search for the same string at next offset
  +            dpos++;
  +        }
  +        // The remaining chars in d buffer were not enough or the string 
  +        // wasn't matched
  +        return (-1);
  +    }
  +
  +    protected static int[] convertPattern(String data)
  +    throws NullPointerException {
  +        // Prepare the arrays
  +        int expr[]=new int[data.length()+1];
  +        char buff[]=data.toCharArray();
  +        // Prepare variables for the translation loop
  +        int y=0;
  +        boolean slash=false;
  +        if(buff[0]=='\\') slash=true;
  +        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  +        else expr[y++]=buff[0];
  +        // Main translation loop
  +        for (int x=1; x<buff.length; x++) {
  +            // If the previous char was '\' simply copy this char.
  +            if (slash) {
  +                expr[y++]=buff[x];
  +                slash=false;
  +            // If the previous char was not '\' we have to do a bunch of checks
  +            } else {
  +                int prev=(y-1);
  +                // If this char is '\' declare that and continue
  +                if(buff[x]=='\\') {
  +                    slash=true;
  +                // If this char is '*' check the previous one
  +                } else if(buff[x]=='*') {
  +                    // If the previous character als was '*' match a path
  +                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  +                    else expr[y++]=MATCH_FILE;
  +                } else expr[y++]=buff[x];
  +            }
  +        }
  +        // Declare the end of the array and return it
  +        expr[y]=MATCH_END;
  +        return(expr);
  +    }        
  +    
  +    /** Testing */
  +    public static void main(String argv[]) {
  +        try {
  +            if (argv.length<2) return;
  +            Stack stack = new Stack();
  +            int expr[] = convertPattern (argv[0]);
  +            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  +            System.out.println("Uri String. \""+argv[1]+"\"");
  +            if (WildcardURIMatcher.match (stack, argv[1], expr)) {
  +                System.out.println("Matched");
  +                for (int i = 0; i < stack.size(); i++)
  +                    System.out.println(i+" "+(String)stack.elementAt (i));
  +            } else
  +                System.out.println("Not matched");
  +        } catch (Exception e) {
  +            System.out.println(e.getClass().getName());
  +            System.out.println(e.getMessage());
  +        }
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +29 -29    xml-cocoon/src/org/apache/cocoon/selection/Attic/BrowserSelectorFactory.java
  
  Index: BrowserSelectorFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/BrowserSelectorFactory.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- BrowserSelectorFactory.java	2000/07/19 22:19:57	1.1.2.3
  +++ BrowserSelectorFactory.java	2000/07/22 20:41:51	1.1.2.4
  @@ -1,29 +1,29 @@
  -/***************************************************************************** 
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.selection; 
  -
  -import org.w3c.dom.DocumentFragment;
  - 
  -/** 
  - * This class generates source code which tests a specific browser pattern
  - * agains the requesting user-agent
  - * 
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/19 22:19:57 $ 
  - */ 
  -
  -public class BrowserSelectorFactory implements SelectorFactory {
  -
  -    public String generateClassLevel (String test, String prefix, DocumentFragment conf) throws Exception {
  -        return "";
  -    }
  -
  -    public String generateMethodLevel (String test, String prefix, DocumentFragment conf) throws Exception {
  -        return "return true;";
  -    }
  -}
  +/***************************************************************************** 
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.selection; 
  +
  +import org.w3c.dom.DocumentFragment;
  + 
  +/** 
  + * This class generates source code which tests a specific browser pattern
  + * agains the requesting user-agent
  + * 
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:51 $ 
  + */ 
  +
  +public class BrowserSelectorFactory implements SelectorFactory {
  +
  +    public String generateClassLevel (String test, String prefix, DocumentFragment conf) throws Exception {
  +        return "";
  +    }
  +
  +    public String generateMethodLevel (String test, String prefix, DocumentFragment conf) throws Exception {
  +        return "return true;";
  +    }
  +}
  
  
  
  1.1.2.3   +30 -30    xml-cocoon/src/org/apache/cocoon/selection/Attic/Selector.java
  
  Index: Selector.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/Selector.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Selector.java	2000/07/17 21:06:12	1.1.2.2
  +++ Selector.java	2000/07/22 20:41:51	1.1.2.3
  @@ -1,30 +1,30 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.selection;
  -
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.Request;
  -
  -/**
  - *
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:12 $
  - */
  -public interface Selector extends SitemapComponent {
  -    /**
  -     * Selectors test pattern against some <code>Request</code> values
  -     * and signals success with the returned boolean value
  -     * @param expression The expression to test.
  -     * @param request    The <code>Request</code> object which can be used
  -     *                   to select values to test the expression.
  -     * @return boolean   Signals successfull test.
  -     */
  -    public boolean select (String expression, Request request);
  -}
  -
  -
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.selection;
  +
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.environment.Environment;
  +
  +/**
  + *
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:51 $
  + */
  +public interface Selector extends SitemapComponent {
  +    /**
  +     * Selectors test pattern against some <code>Request</code> values
  +     * and signals success with the returned boolean value
  +     * @param expression The expression to test.
  +     * @param request    The <code>Request</code> object which can be used
  +     *                   to select values to test the expression.
  +     * @return boolean   Signals successfull test.
  +     */
  +    public boolean select (String expression, Environment environment);
  +}
  +
  +
  
  
  
  1.1.2.4   +27 -27    xml-cocoon/src/org/apache/cocoon/selection/Attic/SelectorFactory.java
  
  Index: SelectorFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/SelectorFactory.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- SelectorFactory.java	2000/07/19 22:19:58	1.1.2.3
  +++ SelectorFactory.java	2000/07/22 20:41:52	1.1.2.4
  @@ -1,27 +1,27 @@
  -/***************************************************************************** 
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.selection; 
  -
  -import org.w3c.dom.DocumentFragment;
  - 
  -/** 
  - * Interface a class has to implement that produces java source code 
  - * representing logic for a <code>Selector</code>s select method. The 
  - * returned source code will be directly integrated into a method of the 
  - * generated sitemap code. 
  - * This <code>SelectorFactory</code>s generate method will be called during 
  - * sitemap code generation.
  - * 
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/19 22:19:58 $ 
  - */ 
  -
  -public interface SelectorFactory {
  -    public String generateClassLevel (String test, String prefix, DocumentFragment conf) throws Exception;
  -    public String generateMethodLevel (String test, String prefix, DocumentFragment conf) throws Exception;
  -}
  +/***************************************************************************** 
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.selection; 
  +
  +import org.w3c.dom.DocumentFragment;
  + 
  +/** 
  + * Interface a class has to implement that produces java source code 
  + * representing logic for a <code>Selector</code>s select method. The 
  + * returned source code will be directly integrated into a method of the 
  + * generated sitemap code. 
  + * This <code>SelectorFactory</code>s generate method will be called during 
  + * sitemap code generation.
  + * 
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:52 $ 
  + */ 
  +
  +public interface SelectorFactory {
  +    public String generateClassLevel (String test, String prefix, DocumentFragment conf) throws Exception;
  +    public String generateMethodLevel (String test, String prefix, DocumentFragment conf) throws Exception;
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +51 -55    xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractSerializer.java
  
  Index: AbstractSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractSerializer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- AbstractSerializer.java	2000/07/11 23:46:48	1.1.2.1
  +++ AbstractSerializer.java	2000/07/22 20:41:52	1.1.2.2
  @@ -1,55 +1,51 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  -
  -import java.io.BufferedOutputStream;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.xml.AbstractXMLConsumer;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:48 $
  - */
  -public abstract class AbstractSerializer extends AbstractXMLConsumer 
  -implements Serializer {
  -    /** The current <code>OutputStream</code>. */
  -    protected OutputStream output=null;
  -    /** The current <code>Request</code>. */
  -    protected Request request=null;
  -    /** The current <code>Response</code>. */
  -    protected Response response=null;
  -    /** The current <code>Parameters</code>. */
  -    protected Parameters parameters=null;
  -    /** The source URI associated with the request or <b>null</b>. */
  -    protected String source=null;
  -
  -    /**
  -     * Set the <code>Request</code>, <code>Response</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Request req, Response res, String src, Parameters par) {
  -        this.request=req;
  -        this.response=res;
  -        this.source=src;
  -        this.parameters=par;
  -    }
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        this.output=new BufferedOutputStream(out);
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  +
  +import java.io.BufferedOutputStream;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.xml.AbstractXMLConsumer;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:52 $
  + */
  +public abstract class AbstractSerializer extends AbstractXMLConsumer 
  +implements Serializer {
  +    /** The current <code>OutputStream</code>. */
  +    protected OutputStream output=null;
  +    /** The current <code>Environment</code>. */
  +    protected Environment environment=null;
  +    /** The current <code>Parameters</code>. */
  +    protected Parameters parameters=null;
  +    /** The source URI associated with the request or <b>null</b>. */
  +    protected String source=null;
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +        this.environment=environment;
  +        this.source=src;
  +        this.parameters=par;
  +    }
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        this.output=new BufferedOutputStream(out);
  +    }
  +}
  
  
  
  1.1.2.3   +80 -80    xml-cocoon/src/org/apache/cocoon/serialization/Attic/FO2PDFSerializer.java
  
  Index: FO2PDFSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/FO2PDFSerializer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- FO2PDFSerializer.java	2000/07/17 21:06:13	1.1.2.2
  +++ FO2PDFSerializer.java	2000/07/22 20:41:52	1.1.2.3
  @@ -1,80 +1,80 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  -
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.PrintWriter;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -import org.apache.cocoon.xml.util.DocumentHandlerWrapper; 
  -
  -import org.apache.fop.apps.Driver;
  -import org.apache.fop.apps.FOPException;
  -import org.apache.fop.apps.Version;
  -
  -//import org.xml.sax.Attributes;
  -//import org.xml.sax.AttributeList;
  -import org.xml.sax.DocumentHandler;
  -//import org.xml.sax.helpers.AttributeListImpl;
  -//import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:giacomo.pati@pwr.ch">Giacomo Pati</a>
  - *         (PWR Organisation &amp; Entwicklung)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:13 $
  - *
  - */
  -public class FO2PDFSerializer extends DocumentHandlerWrapper 
  -        implements Serializer {
  -
  -    /**
  -      * The FOP driver 
  -      */
  -    private Driver driver = null;
  -
  -    /**
  -     * Set the <code>Request</code>, <code>Response</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Request req, Response res, String src, Parameters par) {
  -        driver = new Driver();
  -        driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", Version.getVersion());
  -        driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
  -        driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
  -        res.setContentType(par.getParameter("contentType","application/pdf"));
  -        this.setDocumentHandler (driver.getDocumentHandler());
  -    }
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        driver.setWriter(new PrintWriter(out));
  -    }
  - 
  -    /** 
  -     * Receive notification of the end of a document. 
  -     */ 
  -    public void endDocument()  
  -            throws SAXException { 
  -        super.endDocument();
  -        try { 
  -            driver.format(); 
  -            driver.render(); 
  -        } catch (IOException e) { 
  -            throw new SAXException (e); 
  -        } catch (FOPException e) { 
  -            throw new SAXException (e); 
  -        } 
  -    } 
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  +
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.PrintWriter;
  +
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.xml.util.DocumentHandlerWrapper; 
  +
  +import org.apache.fop.apps.Driver;
  +import org.apache.fop.apps.FOPException;
  +import org.apache.fop.apps.Version;
  +
  +//import org.xml.sax.Attributes;
  +//import org.xml.sax.AttributeList;
  +import org.xml.sax.DocumentHandler;
  +//import org.xml.sax.helpers.AttributeListImpl;
  +//import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:giacomo.pati@pwr.ch">Giacomo Pati</a>
  + *         (PWR Organisation &amp; Entwicklung)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:52 $
  + *
  + */
  +public class FO2PDFSerializer extends DocumentHandlerWrapper 
  +        implements Serializer {
  +
  +    /**
  +      * The FOP driver 
  +      */
  +    private Driver driver = null;
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +        driver = new Driver();
  +        driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", Version.getVersion());
  +        driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
  +        driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
  +        ((HttpEnvironment)environment).getResponse().setContentType(par.getParameter("contentType","application/pdf"));
  +        this.setDocumentHandler (driver.getDocumentHandler());
  +    }
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        driver.setWriter(new PrintWriter(out));
  +    }
  + 
  +    /** 
  +     * Receive notification of the end of a document. 
  +     */ 
  +    public void endDocument()  
  +            throws SAXException { 
  +        super.endDocument();
  +        try { 
  +            driver.format(); 
  +            driver.render(); 
  +        } catch (IOException e) { 
  +            throw new SAXException (e); 
  +        } catch (FOPException e) { 
  +            throw new SAXException (e); 
  +        } 
  +    } 
  +}
  
  
  
  1.1.2.2   +371 -369  xml-cocoon/src/org/apache/cocoon/serialization/Attic/HTMLSerializer.java
  
  Index: HTMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/HTMLSerializer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- HTMLSerializer.java	2000/07/11 23:46:49	1.1.2.1
  +++ HTMLSerializer.java	2000/07/22 20:41:52	1.1.2.2
  @@ -1,369 +1,371 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  -
  -import java.io.BufferedOutputStream;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.OutputStreamWriter;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.apache.cocoon.xml.util.NamespacesTable;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:49 $
  - */
  -public class HTMLSerializer extends AbstractSerializer implements XMLConsumer {
  -    /** The namespaces table */
  -    private NamespacesTable ns=new NamespacesTable();
  -    /** The PrintStream used for output */
  -    private OutputStreamWriter out=null;
  -    /** The current locator */
  -    private Locator loc=null;
  -    /** A flag telling wether we're processing the DTD */
  -    private boolean dtd=false;
  -    /** A flag telling wether we're processing a CDATA section */
  -    private boolean cdata=false;
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        super.setOutputStream(out);
  -        this.out=new OutputStreamWriter(super.output);;
  -    }
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     *
  -     * @param locator An object that can return the location of any SAX
  -     *                document event.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -        this.loc=locator;
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        String c=super.parameters.getParameter("contentType","text/html");
  -        super.response.setContentType(c);
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -        try {
  -            this.out.flush();
  -        } catch (IOException e) {
  -            throw new SAXException("IOException flushing stream",e);
  -        }
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        this.ns.addDeclaration(prefix,uri);
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -        this.ns.removeDeclaration(prefix);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes a)
  -    throws SAXException {
  -        this.print('<');
  -
  -        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  -        for (int x=0; x<a.getLength(); x++) {
  -            String name=this.ns.resolve(a.getURI(x),a.getQName(x),null,
  -                                        a.getLocalName(x)).getQName();
  -            String value=a.getValue(x);
  -            if ((name.equals("checked"))  || (name.equals("compact"))  ||
  -                (name.equals("declare"))  || (name.equals("defer"))    ||
  -                (name.equals("disabled")) || (name.equals("ismap"))    ||
  -                (name.equals("multiple")) || (name.equals("nohref"))   ||
  -                (name.equals("noresize")) || (name.equals("noshade"))  ||
  -                (name.equals("nowrap"))   || (name.equals("readonly")) ||
  -                (name.equals("selected"))) {
  -                if(name.equals(value)) {
  -                    this.print(' ');
  -                    this.print(name);
  -                } else {
  -                    this.print(' ');
  -                    this.print(name);
  -                    this.print('=');
  -                    this.print('\"');
  -                    this.print(value);
  -                    this.print('\"');
  -                }
  -            } else {
  -                this.print(' ');
  -                this.print(name);
  -                this.print('=');
  -                this.print('\"');
  -                this.print(value);
  -                this.print('\"');
  -            }
  -
  -        }
  -        this.print('>');
  -    }
  -        
  -
  -    /**
  -     * 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.
  -     */
  -    public void endElement (String uri, String loc, String raw)
  -    throws SAXException {
  -        String name=this.ns.resolve(uri,raw,null,loc).getQName();
  -        if ((name.equalsIgnoreCase("AREA"))     || (name.equalsIgnoreCase("BASE"))     ||        
  -            (name.equalsIgnoreCase("BASEFONT")) || (name.equalsIgnoreCase("BR"))       ||          
  -            (name.equalsIgnoreCase("COL"))      || (name.equalsIgnoreCase("FRAME"))    ||       
  -            (name.equalsIgnoreCase("HR"))       || (name.equalsIgnoreCase("IMG"))      ||         
  -            (name.equalsIgnoreCase("INPUT"))    || (name.equalsIgnoreCase("ISINDEX"))  ||     
  -            (name.equalsIgnoreCase("LINK"))     || (name.equalsIgnoreCase("META"))     ||        
  -            (name.equalsIgnoreCase("PARA"))) return;
  -        this.print('<');
  -        this.print('/');
  -        this.print(name);
  -        this.print('>');
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     *
  -     * @param ch 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.
  -     */
  -    public void characters (char ch[], int start, int len)
  -    throws SAXException {
  -        if(this.cdata) this.print(ch,start,len);
  -        else this.printSafe(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     *
  -     * @param ch 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.
  -     */
  -    public void ignorableWhitespace (char ch[], int start, int len)
  -    throws SAXException {
  -        if(this.cdata) this.print(ch,start,len);
  -        else this.printSafe(ch,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.
  -     */
  -    public void processingInstruction (String target, String data)
  -    throws SAXException {
  -        this.print("<?");
  -        this.print(target);
  -        this.print(' ');
  -        this.print(data);
  -        this.print("?>");
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     *
  -     * @param name The name of the skipped entity.  If it is a  parameter
  -     *             entity, the name will begin with '%'.
  -     */
  -    public void skippedEntity (String name)
  -    throws SAXException {
  -        this.print('&');
  -        this.print(name);
  -        this.print(';');
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     *
  -     * @param name The document type name.
  -     * @param publicId The declared public identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     * @param systemId The declared system identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     */
  -    public void startDTD (String name, String publicId, String systemId)
  -    throws SAXException {
  -        this.print("<!DOCTYPE ");
  -        this.print(name);
  -        if (publicId!=null) {
  -            this.print(" PUBLIC \"");
  -            this.print(publicId);
  -            this.print('\"');
  -            if (systemId!=null) {
  -                this.print(' ');
  -                this.print('\"');
  -                this.print(systemId);
  -                this.print('\"');
  -            }
  -        } else if (systemId!=null) {
  -            this.print(" SYSTEM \"");
  -            this.print(systemId);
  -            this.print('\"');
  -        }
  -        this.print('>');
  -        this.print('\n');
  -        // Set the DTD flag now, to avoid output
  -        this.dtd=true;
  -    }        
  -    
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD ()
  -    throws SAXException {
  -        this.dtd=false;
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     *
  -     * @param name The name of the entity. If it is a parameter entity, the
  -     *             name will begin with '%'.
  -     */
  -    public void startEntity (String name)
  -    throws SAXException {
  -    }        
  -
  -    /**
  -     * Report the end of an entity.
  -     *
  -     * @param name The name of the entity that is ending.
  -     */
  -    public void endEntity (String name)
  -    throws SAXException {
  -    }        
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA ()
  -    throws SAXException {
  -        this.print("<![CDATA[");
  -        this.cdata=true;
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA ()
  -    throws SAXException {
  -        this.cdata=false;
  -        this.print("]]>");
  -    }
  -    
  -
  -    /**
  -     * 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.
  -     */
  -    public void comment (char ch[], int start, int len)
  -    throws SAXException {
  -        this.print("<!--");
  -        this.print(ch,start,len);
  -        this.print("-->");
  -    }
  -
  -    /** Print a string */
  -    private void print(String s)
  -    throws SAXException {
  -        char data[]=s.toCharArray();
  -        this.print(data,0,data.length);
  -    }
  -    
  -    /** Print data from a character array */
  -    private void print(char data[], int start, int len)
  -    throws SAXException {
  -        try {
  -            if(!this.dtd) this.out.write(data,start,len);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Print data from a character array */
  -    private void print(char c)
  -    throws SAXException {
  -        try {
  -            if(!this.dtd) this.out.write(c);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Print a string */
  -    private void printSafe(String s)
  -    throws SAXException {
  -        char data[]=s.toCharArray();
  -        this.printSafe(data,0,data.length);
  -    }
  -    
  -    /** Print data from a character array */
  -    private void printSafe(char data[], int start, int len)
  -    throws SAXException {
  -        int end=start+len;
  -        if(!this.dtd) for(int x=0; x<end; x++) this.printSafe(data[x]);
  -    }
  -
  -    /** Print data from a character array */
  -    private void printSafe(char c)
  -    throws SAXException {
  -        try {
  -            if(this.dtd) return;
  -            if(c=='&') this.print("&amp;");
  -            else if(c=='<') this.print("&lt;");
  -            else if(c=='>') this.print("&gt;");
  -            else this.out.write(c);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  +
  +import java.io.BufferedOutputStream;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.OutputStreamWriter;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.cocoon.xml.util.NamespacesTable;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:52 $
  + */
  +public class HTMLSerializer extends AbstractSerializer implements XMLConsumer {
  +    /** The namespaces table */
  +    private NamespacesTable ns=new NamespacesTable();
  +    /** The PrintStream used for output */
  +    private OutputStreamWriter out=null;
  +    /** The current locator */
  +    private Locator loc=null;
  +    /** A flag telling wether we're processing the DTD */
  +    private boolean dtd=false;
  +    /** A flag telling wether we're processing a CDATA section */
  +    private boolean cdata=false;
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        super.setOutputStream(out);
  +        this.out=new OutputStreamWriter(super.output);;
  +    }
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     *
  +     * @param locator An object that can return the location of any SAX
  +     *                document event.
  +     */
  +    public void setDocumentLocator(Locator locator) {
  +        this.loc=locator;
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +        String c=super.parameters.getParameter("contentType","text/html");
  +        ((HttpEnvironment)(super.environment)).getResponse().setContentType(c);
  +    }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument()
  +    throws SAXException {
  +        try {
  +            this.out.flush();
  +        } catch (IOException e) {
  +            throw new SAXException("IOException flushing stream",e);
  +        }
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        this.ns.addDeclaration(prefix,uri);
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +        this.ns.removeDeclaration(prefix);
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes a)
  +    throws SAXException {
  +        this.print('<');
  +
  +        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  +        for (int x=0; x<a.getLength(); x++) {
  +            String name=this.ns.resolve(a.getURI(x),a.getQName(x),null,
  +                                        a.getLocalName(x)).getQName();
  +            String value=a.getValue(x);
  +            if ((name.equals("checked"))  || (name.equals("compact"))  ||
  +                (name.equals("declare"))  || (name.equals("defer"))    ||
  +                (name.equals("disabled")) || (name.equals("ismap"))    ||
  +                (name.equals("multiple")) || (name.equals("nohref"))   ||
  +                (name.equals("noresize")) || (name.equals("noshade"))  ||
  +                (name.equals("nowrap"))   || (name.equals("readonly")) ||
  +                (name.equals("selected"))) {
  +                if(name.equals(value)) {
  +                    this.print(' ');
  +                    this.print(name);
  +                } else {
  +                    this.print(' ');
  +                    this.print(name);
  +                    this.print('=');
  +                    this.print('\"');
  +                    this.print(value);
  +                    this.print('\"');
  +                }
  +            } else {
  +                this.print(' ');
  +                this.print(name);
  +                this.print('=');
  +                this.print('\"');
  +                this.print(value);
  +                this.print('\"');
  +            }
  +
  +        }
  +        this.print('>');
  +    }
  +        
  +
  +    /**
  +     * 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.
  +     */
  +    public void endElement (String uri, String loc, String raw)
  +    throws SAXException {
  +        String name=this.ns.resolve(uri,raw,null,loc).getQName();
  +        if ((name.equalsIgnoreCase("AREA"))     || (name.equalsIgnoreCase("BASE"))     ||        
  +            (name.equalsIgnoreCase("BASEFONT")) || (name.equalsIgnoreCase("BR"))       ||          
  +            (name.equalsIgnoreCase("COL"))      || (name.equalsIgnoreCase("FRAME"))    ||       
  +            (name.equalsIgnoreCase("HR"))       || (name.equalsIgnoreCase("IMG"))      ||         
  +            (name.equalsIgnoreCase("INPUT"))    || (name.equalsIgnoreCase("ISINDEX"))  ||     
  +            (name.equalsIgnoreCase("LINK"))     || (name.equalsIgnoreCase("META"))     ||        
  +            (name.equalsIgnoreCase("PARA"))) return;
  +        this.print('<');
  +        this.print('/');
  +        this.print(name);
  +        this.print('>');
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     *
  +     * @param ch 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.
  +     */
  +    public void characters (char ch[], int start, int len)
  +    throws SAXException {
  +        if(this.cdata) this.print(ch,start,len);
  +        else this.printSafe(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     *
  +     * @param ch 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.
  +     */
  +    public void ignorableWhitespace (char ch[], int start, int len)
  +    throws SAXException {
  +        if(this.cdata) this.print(ch,start,len);
  +        else this.printSafe(ch,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.
  +     */
  +    public void processingInstruction (String target, String data)
  +    throws SAXException {
  +        this.print("<?");
  +        this.print(target);
  +        this.print(' ');
  +        this.print(data);
  +        this.print("?>");
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     *
  +     * @param name The name of the skipped entity.  If it is a  parameter
  +     *             entity, the name will begin with '%'.
  +     */
  +    public void skippedEntity (String name)
  +    throws SAXException {
  +        this.print('&');
  +        this.print(name);
  +        this.print(';');
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any.
  +     *
  +     * @param name The document type name.
  +     * @param publicId The declared public identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     * @param systemId The declared system identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     */
  +    public void startDTD (String name, String publicId, String systemId)
  +    throws SAXException {
  +        this.print("<!DOCTYPE ");
  +        this.print(name);
  +        if (publicId!=null) {
  +            this.print(" PUBLIC \"");
  +            this.print(publicId);
  +            this.print('\"');
  +            if (systemId!=null) {
  +                this.print(' ');
  +                this.print('\"');
  +                this.print(systemId);
  +                this.print('\"');
  +            }
  +        } else if (systemId!=null) {
  +            this.print(" SYSTEM \"");
  +            this.print(systemId);
  +            this.print('\"');
  +        }
  +        this.print('>');
  +        this.print('\n');
  +        // Set the DTD flag now, to avoid output
  +        this.dtd=true;
  +    }        
  +    
  +    /**
  +     * Report the end of DTD declarations.
  +     */
  +    public void endDTD ()
  +    throws SAXException {
  +        this.dtd=false;
  +    }
  +
  +    /**
  +     * Report the beginning of an entity.
  +     *
  +     * @param name The name of the entity. If it is a parameter entity, the
  +     *             name will begin with '%'.
  +     */
  +    public void startEntity (String name)
  +    throws SAXException {
  +    }        
  +
  +    /**
  +     * Report the end of an entity.
  +     *
  +     * @param name The name of the entity that is ending.
  +     */
  +    public void endEntity (String name)
  +    throws SAXException {
  +    }        
  +
  +    /**
  +     * Report the start of a CDATA section.
  +     */
  +    public void startCDATA ()
  +    throws SAXException {
  +        this.print("<![CDATA[");
  +        this.cdata=true;
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section.
  +     */
  +    public void endCDATA ()
  +    throws SAXException {
  +        this.cdata=false;
  +        this.print("]]>");
  +    }
  +    
  +
  +    /**
  +     * 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.
  +     */
  +    public void comment (char ch[], int start, int len)
  +    throws SAXException {
  +        this.print("<!--");
  +        this.print(ch,start,len);
  +        this.print("-->");
  +    }
  +
  +    /** Print a string */
  +    private void print(String s)
  +    throws SAXException {
  +        char data[]=s.toCharArray();
  +        this.print(data,0,data.length);
  +    }
  +    
  +    /** Print data from a character array */
  +    private void print(char data[], int start, int len)
  +    throws SAXException {
  +        try {
  +            if(!this.dtd) this.out.write(data,start,len);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Print data from a character array */
  +    private void print(char c)
  +    throws SAXException {
  +        try {
  +            if(!this.dtd) this.out.write(c);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Print a string */
  +    private void printSafe(String s)
  +    throws SAXException {
  +        char data[]=s.toCharArray();
  +        this.printSafe(data,0,data.length);
  +    }
  +    
  +    /** Print data from a character array */
  +    private void printSafe(char data[], int start, int len)
  +    throws SAXException {
  +        int end=start+len;
  +        if(!this.dtd) for(int x=0; x<end; x++) this.printSafe(data[x]);
  +    }
  +
  +    /** Print data from a character array */
  +    private void printSafe(char c)
  +    throws SAXException {
  +        try {
  +            if(this.dtd) return;
  +            if(c=='&') this.print("&amp;");
  +            else if(c=='<') this.print("&lt;");
  +            else if(c=='>') this.print("&gt;");
  +            else this.out.write(c);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +}
  
  
  
  1.1.2.2   +365 -366  xml-cocoon/src/org/apache/cocoon/serialization/Attic/ImageSerializer.java
  
  Index: ImageSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/ImageSerializer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ImageSerializer.java	2000/07/11 23:46:50	1.1.2.1
  +++ ImageSerializer.java	2000/07/22 20:41:52	1.1.2.2
  @@ -1,366 +1,365 @@
  -/*****************************************************************************
  - * Copyright (C) 1999 The Apache Software Foundation.   All rights reserved. *
  - * ------------------------------------------------------------------------- *
  - * This software is published under the terms of the Apache Software License *
  - * version 1.1,  a copy of wich has been included  with this distribution in *
  - * the LICENSE file.                                                         *
  - *****************************************************************************/
  -package org.apache.cocoon.serialization;
  -
  -import org.apache.avalon.*;
  -import org.apache.avalon.utils.*;
  -import org.apache.cocoon.*;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.xml.*;
  -import org.apache.cocoon.xml.util.*;
  -import com.sun.image.codec.jpeg.*;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.PrintStream;
  -import java.io.*;
  -import java.net.URL;
  -import java.awt.*;
  -import java.awt.geom.AffineTransform;
  -import java.awt.image.*;
  -import java.util.*;
  -import javax.swing.*;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.ext.*;
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.CDATASection;
  -import org.w3c.dom.Comment;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentFragment;
  -import org.w3c.dom.DocumentType;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Entity;
  -import org.w3c.dom.EntityReference;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.Notation;
  -import org.w3c.dom.ProcessingInstruction;
  -import org.w3c.dom.Text;
  -
  -/**
  - * The ImagePrinter Printer writes images.
  - *
  - * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
  - * @author Copyright 1999 &copy; <a href="http://www.apache.org">The Apache
  - *         Software Foundation</a>. All rights reserved.
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:50 $
  - */
  -public class ImageSerializer extends DOMBuilder implements Serializer, Composer {
  -   
  -    int R=0;
  -    int G=1;
  -    int B=2;
  -    int A=3;
  -
  -    /** The <code>ContentHandler</code> receiving SAX events. */
  -    private ContentHandler contentHandler=null;
  -    /** The <code>LexicalHandler</code> receiving SAX events. */
  -    private LexicalHandler lexicalHandler=null;
  -    /** The component manager instance */
  -    private ComponentManager manager=null;
  -    /** The current <code>Request</code>. */
  -    private Request request=null;
  -    /** The current <code>Response</code>. */
  -    private Response response=null;
  -    /** The current <code>Parameters</code>. */
  -    private Parameters parameters=null;
  -    /** The source URI associated with the request or <b>null</b>. */
  -    private String source=null;
  -    /** The current <code>OutputStream</code>. */
  -    private OutputStream output=null;
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        this.output=new BufferedOutputStream(out);
  -    }
  -
  -    /**
  -     * Set the <code>Request</code>, <code>Response</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Request req, Response res, String src, Parameters par) {
  -        this.request=req;
  -        this.response=res;
  -        this.source=src;
  -        this.parameters=par;
  -        super.factory=(Parser)this.manager.getComponent("parser");
  -    }
  -
  -    /**
  -     * Set the <code>XMLConsumer</code> that will receive XML data.
  -     * <br>
  -     * This method will simply call <code>setContentHandler(consumer)</code>
  -     * and <code>setLexicalHandler(consumer)</code>.
  -     */
  -    public void setConsumer(XMLConsumer consumer) {
  -        this.contentHandler=consumer;
  -        this.lexicalHandler=consumer;
  -    }
  -
  -    /**
  -     * Set the current <code>ComponentManager</code> instance used by this
  -     * <code>Composer</code>.
  -     */
  -    public void setComponentManager(ComponentManager manager) {
  -        this.manager=manager;
  -    }
  -
  -    /**
  -     * Set the <code>ContentHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>ContentHandler</code> instance
  -     * accessing the protected <code>super.contentHandler</code> field.
  -     */
  -    public void setContentHandler(ContentHandler content) {
  -        this.contentHandler=content;
  -    }
  -
  -    /**
  -     * Set the <code>LexicalHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  -     * accessing the protected <code>super.lexicalHandler</code> field.
  -     *
  -     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  -     *                                  the <code>XMLConsumer</code> were
  -     *                                  already set.
  -     */
  -    public void setLexicalHandler(LexicalHandler lexical) {
  -        this.lexicalHandler=lexical;
  -    }
  -
  -    /**
  -     * Receive notification of a successfully completed DOM tree generation.
  -     */
  -    public void notify(Document doc)
  -    throws SAXException {
  -        this.response.setContentType("image/jpeg");
  -        try {
  -            this.print(doc,this.output);
  -        } catch(IOException e) {
  -            throw new SAXException("IOException writing image ",e);
  -        }
  -    }
  -
  -    public void print(Document doc, OutputStream out)
  -    throws SAXException, IOException {
  -        // Check for proper root element
  -        Element element=doc.getDocumentElement();
  -        if (!element.getTagName().equals("image")) {
  -            throw new SAXException("Invalid document supplied");
  -        }
  -        // Check wether we have a source image
  -        String source=element.getAttribute("source");
  -        BufferedImage img=null;
  -        Graphics2D gr=null;
  -        // If we have a source image, this is taken as our source.
  -        if (source.length()>0) {
  -            ImageIcon ico=null;
  -            if (source.indexOf(":/")>=0) {
  -                ico=new ImageIcon(new URL(source).openConnection().getURL());
  -            } else ico=new ImageIcon(source);
  -
  -            if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) {
  -                throw new SAXException("Cannot load image \""+System.getProperty("user.dir")+"/"+source+"\"");
  -            }
  -            img=new BufferedImage(ico.getIconWidth(), ico.getIconHeight(),
  -                                  BufferedImage.TYPE_INT_RGB);
  -            gr=img.createGraphics();
  -            gr.drawImage(ico.getImage(),0,0,ico.getImageObserver());
  -        } else {
  -            // We don't have a source image. Build up a new getting height and
  -            // width from attributes
  -            int w=0;
  -            int h=0;
  -            try {
  -                String width=element.getAttribute("width");
  -                String height=element.getAttribute("height");
  -                w=Integer.parseInt(width);
  -                h=Integer.parseInt(height);
  -            } catch (NumberFormatException e) {
  -                throw new SAXException("Image witdth or height error");
  -            }
  -            if ((w<1) | (h<1)) {
  -                throw new SAXException("Image witdth or height unspecified");
  -            }
  -            img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
  -            gr=img.createGraphics();
  -            // Now process the bgcolor attribute for background colorization
  -            int bg=0;
  -            try {
  -                String bgcolor=element.getAttribute("bgcolor");
  -                bg=Integer.parseInt(bgcolor,16);
  -            } catch (NumberFormatException e) {
  -                throw new SAXException("Background color error");
  -            }
  -            Color c=new Color(bg);
  -            gr.setBackground(c);
  -            gr.clearRect(0,0,w,h);
  -            // Check if we have a background to tile
  -            String background=element.getAttribute("background");
  -            if (background.length()>0) {
  -                // We have a background image. Load it.
  -                ImageIcon ico=new ImageIcon(background);
  -                if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) {
  -                    throw new SAXException("Cannot load background \""+source+"\"");
  -                }
  -                // Tile the image.
  -                int x=0;
  -                int y=0;
  -                while (true) {
  -                    gr.drawImage(ico.getImage(),x,y,ico.getImageObserver());
  -                    x+=ico.getIconWidth();
  -                    if (x>w) {
  -                        x=0;
  -                        y+=ico.getIconHeight();
  -                    }
  -                    if (y>h) break;
  -                }
  -            }
  -        }
  -
  -        // Process child elements
  -        NodeList l=element.getChildNodes();
  -        for (int x=0;x<l.getLength();x++) {
  -            if (l.item(x).getNodeType()==Node.ELEMENT_NODE) {
  -                processElement((Element)l.item(x),img);
  -            }
  -        }
  -
  -        // Write out image (highest quality for jpeg data)
  -        JPEGEncodeParam jpar=JPEGCodec.getDefaultJPEGEncodeParam(img);
  -        jpar.setQuality(1,true);
  -        JPEGImageEncoder jenc=JPEGCodec.createJPEGEncoder(out,jpar);
  -        jenc.encode(img);
  -        out.flush();
  -    }
  -
  -    void processElement(Element e, BufferedImage i)
  -    throws SAXException {
  -        if (e==null) return;
  -        int R=0; int G=1; int B=2; int A=3;
  -        // Create new alpha image
  -        int w=i.getWidth();
  -        int h=i.getHeight();
  -        BufferedImage n=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  -        // Clear new alpha image
  -        int np[]=new int[]{0,0,0,0};
  -        WritableRaster nr=n.getRaster();
  -        for (int x=0;x<nr.getWidth();x++) for (int y=10;y<nr.getHeight();y++) {
  -            nr.setPixel(x,y,np);
  -        }
  -        // Check wich element is being processed.
  -        boolean ret=false;
  -        if (e.getTagName().equals("text")) ret=placeText(e,n);
  -        if(!ret) return;
  -        // Apply new image over existing
  -        WritableRaster ir=i.getRaster();
  -        int ip[]=new int[]{0,0,0,0};
  -        double ia=0;
  -        double na=1;
  -        for (int x=0;x<ir.getWidth();x++) for (int y=0;y<ir.getHeight();y++) {
  -            ir.getPixel(x,y,ip);
  -            nr.getPixel(x,y,np);
  -            if (np[A]>0) {
  -                na=((double)np[A]/255);
  -                ia=(1-na);
  -                ip[R]=(int)(((double)ip[R]*ia) + ((double)np[R]*na));
  -                ip[G]=(int)(((double)ip[G]*ia) + ((double)np[G]*na));;
  -                ip[B]=(int)(((double)ip[B]*ia) + ((double)np[B]*na));;
  -            }
  -            ir.setPixel(x,y,ip);
  -        }
  -    }
  -
  -    private boolean placeText(Element e, BufferedImage i)
  -    throws SAXException {
  -        String text=e.getAttribute("text");
  -        String font=e.getAttribute("font");
  -        String ssize=e.getAttribute("size");
  -        String sstyle=e.getAttribute("style");
  -        String scolor=e.getAttribute("color");
  -        String sx=e.getAttribute("x");
  -        String sy=e.getAttribute("y");
  -        String halign=e.getAttribute("halign");
  -        String valign=e.getAttribute("valign");
  -        // Check proper text
  -        if (text.length()<1) return(false);
  -        // Check size, x and y parameters
  -        int color,size,insx,insy;
  -        try {
  -            size=Integer.parseInt(ssize);
  -            insx=Integer.parseInt(sx);
  -            insy=Integer.parseInt(sy);
  -            color=Integer.parseInt(scolor,16);
  -        } catch (NumberFormatException ex) {
  -            throw new SAXException("Attribute size, x, y or color error");
  -        }
  -        // Get style
  -        int style=Font.PLAIN;
  -        if (sstyle.equals("bold")) style=Font.BOLD;
  -        else if (sstyle.equals("italic")) style=Font.ITALIC;
  -        else if (sstyle.equals("bolditalic")) style=Font.BOLD+Font.ITALIC;
  -        Font f=new Font(font,style,size);
  -        FontMetrics m=i.createGraphics().getFontMetrics(f);
  -        // Create temporary image
  -        int w=m.stringWidth(text)*2;
  -        int h=m.getHeight()*2;
  -        BufferedImage n=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  -        // Write out some text
  -        Graphics2D gr=n.createGraphics();
  -        gr.setColor(new Color(0x0ff000000,true));
  -        gr.setFont(f);
  -        gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
  -                            RenderingHints.VALUE_ANTIALIAS_ON);
  -        gr.drawString(text,5,h-(h/4));
  -        // Resize image
  -        int minx=w;
  -        int miny=h;
  -        int maxx=0;
  -        int maxy=0;
  -        WritableRaster nr=n.getRaster();
  -        int np[]=new int[]{0,0,0,0};
  -        for (int x=0;x<nr.getWidth();x++) for (int y=10;y<nr.getHeight();y++) {
  -            nr.getPixel(x,y,np);
  -            if (np[A]>0) {
  -                if(x<minx) minx=x;
  -                if(x>maxx) maxx=x;
  -                if(y<miny) miny=y;
  -                if(y>maxy) maxy=y;
  -            }
  -        }
  -        if (halign.equals("right")) insx=insx-((maxx-minx)+1);
  -        if (halign.equals("center")) insx=insx-(((maxx-minx)+1)/2);
  -        if (valign.equals("bottom")) insy=insy-((maxy-miny)+1);
  -        if (valign.equals("center")) insy=insy-(((maxy-miny)+1)/2);
  -        WritableRaster ir=i.getRaster();
  -        int newx,newy;
  -        newy=insy;
  -        for (int y=miny;y<=maxy;y++) {
  -            newx=insx;
  -            if(newy>=0) {
  -                for (int x=minx;x<=maxx;x++) {
  -                    nr.getPixel(x,y,np);
  -                    np[R]=(color >> 16) & 0x0ff;
  -                    np[G]=(color >> 8) & 0x0ff;
  -                    np[B]=(color & 0x0ff);
  -                    if(newx>=0) ir.setPixel(newx,newy,np);
  -                    newx++;
  -                    if(newx>=i.getWidth()) break;
  -                }
  -            }
  -            newy++;
  -            if(newy>=i.getHeight()) break;
  -        }
  -        return(true);
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) 1999 The Apache Software Foundation.   All rights reserved. *
  + * ------------------------------------------------------------------------- *
  + * This software is published under the terms of the Apache Software License *
  + * version 1.1,  a copy of wich has been included  with this distribution in *
  + * the LICENSE file.                                                         *
  + *****************************************************************************/
  +package org.apache.cocoon.serialization;
  +
  +import org.apache.avalon.*;
  +import org.apache.avalon.utils.*;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.*;
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.xml.*;
  +import org.apache.cocoon.xml.util.*;
  +import com.sun.image.codec.jpeg.*;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.PrintStream;
  +import java.io.*;
  +import java.net.URL;
  +import java.awt.*;
  +import java.awt.geom.AffineTransform;
  +import java.awt.image.*;
  +import java.util.*;
  +import javax.swing.*;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.ext.*;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.CDATASection;
  +import org.w3c.dom.Comment;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.DocumentFragment;
  +import org.w3c.dom.DocumentType;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Entity;
  +import org.w3c.dom.EntityReference;
  +import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.Notation;
  +import org.w3c.dom.ProcessingInstruction;
  +import org.w3c.dom.Text;
  +
  +/**
  + * The ImagePrinter Printer writes images.
  + *
  + * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
  + * @author Copyright 1999 &copy; <a href="http://www.apache.org">The Apache
  + *         Software Foundation</a>. All rights reserved.
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:52 $
  + */
  +public class ImageSerializer extends DOMBuilder implements Serializer, Composer {
  +   
  +    int R=0;
  +    int G=1;
  +    int B=2;
  +    int A=3;
  +
  +    /** The <code>ContentHandler</code> receiving SAX events. */
  +    private ContentHandler contentHandler=null;
  +    /** The <code>LexicalHandler</code> receiving SAX events. */
  +    private LexicalHandler lexicalHandler=null;
  +    /** The component manager instance */
  +    private ComponentManager manager=null;
  +    /** The current <code>Environment</code>. */
  +    private Environment environment=null;
  +    /** The current <code>Parameters</code>. */
  +    private Parameters parameters=null;
  +    /** The source URI associated with the request or <b>null</b>. */
  +    private String source=null;
  +    /** The current <code>OutputStream</code>. */
  +    private OutputStream output=null;
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        this.output=new BufferedOutputStream(out);
  +    }
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +        this.environment=environment;
  +        this.source=src;
  +        this.parameters=par;
  +        super.factory=(Parser)this.manager.getComponent("parser");
  +    }
  +
  +    /**
  +     * Set the <code>XMLConsumer</code> that will receive XML data.
  +     * <br>
  +     * This method will simply call <code>setContentHandler(consumer)</code>
  +     * and <code>setLexicalHandler(consumer)</code>.
  +     */
  +    public void setConsumer(XMLConsumer consumer) {
  +        this.contentHandler=consumer;
  +        this.lexicalHandler=consumer;
  +    }
  +
  +    /**
  +     * Set the current <code>ComponentManager</code> instance used by this
  +     * <code>Composer</code>.
  +     */
  +    public void setComponentManager(ComponentManager manager) {
  +        this.manager=manager;
  +    }
  +
  +    /**
  +     * Set the <code>ContentHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>ContentHandler</code> instance
  +     * accessing the protected <code>super.contentHandler</code> field.
  +     */
  +    public void setContentHandler(ContentHandler content) {
  +        this.contentHandler=content;
  +    }
  +
  +    /**
  +     * Set the <code>LexicalHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  +     * accessing the protected <code>super.lexicalHandler</code> field.
  +     *
  +     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  +     *                                  the <code>XMLConsumer</code> were
  +     *                                  already set.
  +     */
  +    public void setLexicalHandler(LexicalHandler lexical) {
  +        this.lexicalHandler=lexical;
  +    }
  +
  +    /**
  +     * Receive notification of a successfully completed DOM tree generation.
  +     */
  +    public void notify(Document doc)
  +    throws SAXException {
  +        ((HttpEnvironment)(this.environment)).getResponse().setContentType("image/jpeg");
  +        try {
  +            this.print(doc,this.output);
  +        } catch(IOException e) {
  +            throw new SAXException("IOException writing image ",e);
  +        }
  +    }
  +
  +    public void print(Document doc, OutputStream out)
  +    throws SAXException, IOException {
  +        // Check for proper root element
  +        Element element=doc.getDocumentElement();
  +        if (!element.getTagName().equals("image")) {
  +            throw new SAXException("Invalid document supplied");
  +        }
  +        // Check wether we have a source image
  +        String source=element.getAttribute("source");
  +        BufferedImage img=null;
  +        Graphics2D gr=null;
  +        // If we have a source image, this is taken as our source.
  +        if (source.length()>0) {
  +            ImageIcon ico=null;
  +            if (source.indexOf(":/")>=0) {
  +                ico=new ImageIcon(new URL(source).openConnection().getURL());
  +            } else ico=new ImageIcon(source);
  +
  +            if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) {
  +                throw new SAXException("Cannot load image \""+System.getProperty("user.dir")+"/"+source+"\"");
  +            }
  +            img=new BufferedImage(ico.getIconWidth(), ico.getIconHeight(),
  +                                  BufferedImage.TYPE_INT_RGB);
  +            gr=img.createGraphics();
  +            gr.drawImage(ico.getImage(),0,0,ico.getImageObserver());
  +        } else {
  +            // We don't have a source image. Build up a new getting height and
  +            // width from attributes
  +            int w=0;
  +            int h=0;
  +            try {
  +                String width=element.getAttribute("width");
  +                String height=element.getAttribute("height");
  +                w=Integer.parseInt(width);
  +                h=Integer.parseInt(height);
  +            } catch (NumberFormatException e) {
  +                throw new SAXException("Image witdth or height error");
  +            }
  +            if ((w<1) | (h<1)) {
  +                throw new SAXException("Image witdth or height unspecified");
  +            }
  +            img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
  +            gr=img.createGraphics();
  +            // Now process the bgcolor attribute for background colorization
  +            int bg=0;
  +            try {
  +                String bgcolor=element.getAttribute("bgcolor");
  +                bg=Integer.parseInt(bgcolor,16);
  +            } catch (NumberFormatException e) {
  +                throw new SAXException("Background color error");
  +            }
  +            Color c=new Color(bg);
  +            gr.setBackground(c);
  +            gr.clearRect(0,0,w,h);
  +            // Check if we have a background to tile
  +            String background=element.getAttribute("background");
  +            if (background.length()>0) {
  +                // We have a background image. Load it.
  +                ImageIcon ico=new ImageIcon(background);
  +                if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) {
  +                    throw new SAXException("Cannot load background \""+source+"\"");
  +                }
  +                // Tile the image.
  +                int x=0;
  +                int y=0;
  +                while (true) {
  +                    gr.drawImage(ico.getImage(),x,y,ico.getImageObserver());
  +                    x+=ico.getIconWidth();
  +                    if (x>w) {
  +                        x=0;
  +                        y+=ico.getIconHeight();
  +                    }
  +                    if (y>h) break;
  +                }
  +            }
  +        }
  +
  +        // Process child elements
  +        NodeList l=element.getChildNodes();
  +        for (int x=0;x<l.getLength();x++) {
  +            if (l.item(x).getNodeType()==Node.ELEMENT_NODE) {
  +                processElement((Element)l.item(x),img);
  +            }
  +        }
  +
  +        // Write out image (highest quality for jpeg data)
  +        JPEGEncodeParam jpar=JPEGCodec.getDefaultJPEGEncodeParam(img);
  +        jpar.setQuality(1,true);
  +        JPEGImageEncoder jenc=JPEGCodec.createJPEGEncoder(out,jpar);
  +        jenc.encode(img);
  +        out.flush();
  +    }
  +
  +    void processElement(Element e, BufferedImage i)
  +    throws SAXException {
  +        if (e==null) return;
  +        int R=0; int G=1; int B=2; int A=3;
  +        // Create new alpha image
  +        int w=i.getWidth();
  +        int h=i.getHeight();
  +        BufferedImage n=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  +        // Clear new alpha image
  +        int np[]=new int[]{0,0,0,0};
  +        WritableRaster nr=n.getRaster();
  +        for (int x=0;x<nr.getWidth();x++) for (int y=10;y<nr.getHeight();y++) {
  +            nr.setPixel(x,y,np);
  +        }
  +        // Check wich element is being processed.
  +        boolean ret=false;
  +        if (e.getTagName().equals("text")) ret=placeText(e,n);
  +        if(!ret) return;
  +        // Apply new image over existing
  +        WritableRaster ir=i.getRaster();
  +        int ip[]=new int[]{0,0,0,0};
  +        double ia=0;
  +        double na=1;
  +        for (int x=0;x<ir.getWidth();x++) for (int y=0;y<ir.getHeight();y++) {
  +            ir.getPixel(x,y,ip);
  +            nr.getPixel(x,y,np);
  +            if (np[A]>0) {
  +                na=((double)np[A]/255);
  +                ia=(1-na);
  +                ip[R]=(int)(((double)ip[R]*ia) + ((double)np[R]*na));
  +                ip[G]=(int)(((double)ip[G]*ia) + ((double)np[G]*na));;
  +                ip[B]=(int)(((double)ip[B]*ia) + ((double)np[B]*na));;
  +            }
  +            ir.setPixel(x,y,ip);
  +        }
  +    }
  +
  +    private boolean placeText(Element e, BufferedImage i)
  +    throws SAXException {
  +        String text=e.getAttribute("text");
  +        String font=e.getAttribute("font");
  +        String ssize=e.getAttribute("size");
  +        String sstyle=e.getAttribute("style");
  +        String scolor=e.getAttribute("color");
  +        String sx=e.getAttribute("x");
  +        String sy=e.getAttribute("y");
  +        String halign=e.getAttribute("halign");
  +        String valign=e.getAttribute("valign");
  +        // Check proper text
  +        if (text.length()<1) return(false);
  +        // Check size, x and y parameters
  +        int color,size,insx,insy;
  +        try {
  +            size=Integer.parseInt(ssize);
  +            insx=Integer.parseInt(sx);
  +            insy=Integer.parseInt(sy);
  +            color=Integer.parseInt(scolor,16);
  +        } catch (NumberFormatException ex) {
  +            throw new SAXException("Attribute size, x, y or color error");
  +        }
  +        // Get style
  +        int style=Font.PLAIN;
  +        if (sstyle.equals("bold")) style=Font.BOLD;
  +        else if (sstyle.equals("italic")) style=Font.ITALIC;
  +        else if (sstyle.equals("bolditalic")) style=Font.BOLD+Font.ITALIC;
  +        Font f=new Font(font,style,size);
  +        FontMetrics m=i.createGraphics().getFontMetrics(f);
  +        // Create temporary image
  +        int w=m.stringWidth(text)*2;
  +        int h=m.getHeight()*2;
  +        BufferedImage n=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  +        // Write out some text
  +        Graphics2D gr=n.createGraphics();
  +        gr.setColor(new Color(0x0ff000000,true));
  +        gr.setFont(f);
  +        gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
  +                            RenderingHints.VALUE_ANTIALIAS_ON);
  +        gr.drawString(text,5,h-(h/4));
  +        // Resize image
  +        int minx=w;
  +        int miny=h;
  +        int maxx=0;
  +        int maxy=0;
  +        WritableRaster nr=n.getRaster();
  +        int np[]=new int[]{0,0,0,0};
  +        for (int x=0;x<nr.getWidth();x++) for (int y=10;y<nr.getHeight();y++) {
  +            nr.getPixel(x,y,np);
  +            if (np[A]>0) {
  +                if(x<minx) minx=x;
  +                if(x>maxx) maxx=x;
  +                if(y<miny) miny=y;
  +                if(y>maxy) maxy=y;
  +            }
  +        }
  +        if (halign.equals("right")) insx=insx-((maxx-minx)+1);
  +        if (halign.equals("center")) insx=insx-(((maxx-minx)+1)/2);
  +        if (valign.equals("bottom")) insy=insy-((maxy-miny)+1);
  +        if (valign.equals("center")) insy=insy-(((maxy-miny)+1)/2);
  +        WritableRaster ir=i.getRaster();
  +        int newx,newy;
  +        newy=insy;
  +        for (int y=miny;y<=maxy;y++) {
  +            newx=insx;
  +            if(newy>=0) {
  +                for (int x=minx;x<=maxx;x++) {
  +                    nr.getPixel(x,y,np);
  +                    np[R]=(color >> 16) & 0x0ff;
  +                    np[G]=(color >> 8) & 0x0ff;
  +                    np[B]=(color & 0x0ff);
  +                    if(newx>=0) ir.setPixel(newx,newy,np);
  +                    newx++;
  +                    if(newx>=i.getWidth()) break;
  +                }
  +            }
  +            newy++;
  +            if(newy>=i.getHeight()) break;
  +        }
  +        return(true);
  +    }
  +}
  
  
  
  1.1.2.2   +161 -162  xml-cocoon/src/org/apache/cocoon/serialization/Attic/SVGSerializer.java
  
  Index: SVGSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/SVGSerializer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SVGSerializer.java	2000/07/11 23:46:51	1.1.2.1
  +++ SVGSerializer.java	2000/07/22 20:41:52	1.1.2.2
  @@ -1,162 +1,161 @@
  -/*****************************************************************************
  - * Copyright (C) 1999 The Apache Software Foundation.   All rights reserved. *
  - * ------------------------------------------------------------------------- *
  - * This software is published under the terms of the Apache Software License *
  - * version 1.1,  a copy of wich has been included  with this distribution in *
  - * the LICENSE file.                                                         *
  - *****************************************************************************/
  -package org.apache.cocoon.serialization;
  -
  -import org.apache.avalon.*;
  -import org.apache.avalon.utils.*;
  -import org.apache.cocoon.*;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.xml.*;
  -import org.apache.cocoon.xml.util.*;
  -import com.sun.image.codec.jpeg.*;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.PrintStream;
  -import java.io.*;
  -import java.net.URL;
  -import java.awt.*;
  -import java.awt.geom.AffineTransform;
  -import java.awt.image.*;
  -import java.util.*;
  -import javax.swing.*;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.ext.*;
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.CDATASection;
  -import org.w3c.dom.Comment;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentFragment;
  -import org.w3c.dom.DocumentType;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Entity;
  -import org.w3c.dom.EntityReference;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.Notation;
  -import org.w3c.dom.ProcessingInstruction;
  -import org.w3c.dom.Text;
  -import org.csiro.svgv.display.*;
  -
  -/**
  - * The ImagePrinter Printer writes images.
  - *
  - * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
  - * @author Copyright 1999 &copy; <a href="http://www.apache.org">The Apache
  - *         Software Foundation</a>. All rights reserved.
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:51 $
  - */
  -public class SVGSerializer extends DOMBuilder implements Serializer, Composer {
  -   
  -    int R=0;
  -    int G=1;
  -    int B=2;
  -    int A=3;
  -
  -    /** The <code>ContentHandler</code> receiving SAX events. */
  -    private ContentHandler contentHandler=null;
  -    /** The <code>LexicalHandler</code> receiving SAX events. */
  -    private LexicalHandler lexicalHandler=null;
  -    /** The component manager instance */
  -    private ComponentManager manager=null;
  -    /** The current <code>Request</code>. */
  -    private Request request=null;
  -    /** The current <code>Response</code>. */
  -    private Response response=null;
  -    /** The current <code>Parameters</code>. */
  -    private Parameters parameters=null;
  -    /** The source URI associated with the request or <b>null</b>. */
  -    private String source=null;
  -    /** The current <code>OutputStream</code>. */
  -    private OutputStream output=null;
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        this.output=new BufferedOutputStream(out);
  -    }
  -
  -    /**
  -     * Set the <code>Request</code>, <code>Response</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Request req, Response res, String src, Parameters par) {
  -        this.request=req;
  -        this.response=res;
  -        this.source=src;
  -        this.parameters=par;
  -        super.factory=(Parser)this.manager.getComponent("parser");
  -    }
  -
  -    /**
  -     * Set the <code>XMLConsumer</code> that will receive XML data.
  -     * <br>
  -     * This method will simply call <code>setContentHandler(consumer)</code>
  -     * and <code>setLexicalHandler(consumer)</code>.
  -     */
  -    public void setConsumer(XMLConsumer consumer) {
  -        this.contentHandler=consumer;
  -        this.lexicalHandler=consumer;
  -    }
  -
  -    /**
  -     * Set the current <code>ComponentManager</code> instance used by this
  -     * <code>Composer</code>.
  -     */
  -    public void setComponentManager(ComponentManager manager) {
  -        this.manager=manager;
  -    }
  -
  -    /**
  -     * Set the <code>ContentHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>ContentHandler</code> instance
  -     * accessing the protected <code>super.contentHandler</code> field.
  -     */
  -    public void setContentHandler(ContentHandler content) {
  -        this.contentHandler=content;
  -    }
  -
  -    /**
  -     * Set the <code>LexicalHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  -     * accessing the protected <code>super.lexicalHandler</code> field.
  -     *
  -     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  -     *                                  the <code>XMLConsumer</code> were
  -     *                                  already set.
  -     */
  -    public void setLexicalHandler(LexicalHandler lexical) {
  -        this.lexicalHandler=lexical;
  -    }
  -
  -    /**
  -     * Receive notification of a successfully completed DOM tree generation.
  -     */
  -    public void notify(Document doc)
  -    throws SAXException {
  -        this.response.setContentType("image/jpeg");
  -        try {
  -            BufferedImage img=SvgToAwtConverter.convert(doc,this.source);
  -            OutputStream out=this.output;
  -            // Write out image (highest quality for jpeg data)
  -            JPEGEncodeParam jpar=JPEGCodec.getDefaultJPEGEncodeParam(img);
  -            jpar.setQuality(1,true);
  -            JPEGImageEncoder jenc=JPEGCodec.createJPEGEncoder(out,jpar);
  -            jenc.encode(img);
  -            out.flush();
  -
  -        } catch(IOException e) {
  -            throw new SAXException("IOException writing image ",e);
  -        }
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) 1999 The Apache Software Foundation.   All rights reserved. *
  + * ------------------------------------------------------------------------- *
  + * This software is published under the terms of the Apache Software License *
  + * version 1.1,  a copy of wich has been included  with this distribution in *
  + * the LICENSE file.                                                         *
  + *****************************************************************************/
  +package org.apache.cocoon.serialization;
  +
  +import org.apache.avalon.*;
  +import org.apache.avalon.utils.*;
  +import org.apache.cocoon.*;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.xml.*;
  +import org.apache.cocoon.xml.util.*;
  +import com.sun.image.codec.jpeg.*;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.PrintStream;
  +import java.io.*;
  +import java.net.URL;
  +import java.awt.*;
  +import java.awt.geom.AffineTransform;
  +import java.awt.image.*;
  +import java.util.*;
  +import javax.swing.*;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.ext.*;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.CDATASection;
  +import org.w3c.dom.Comment;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.DocumentFragment;
  +import org.w3c.dom.DocumentType;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Entity;
  +import org.w3c.dom.EntityReference;
  +import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.Notation;
  +import org.w3c.dom.ProcessingInstruction;
  +import org.w3c.dom.Text;
  +import org.csiro.svgv.display.*;
  +
  +/**
  + * The ImagePrinter Printer writes images.
  + *
  + * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
  + * @author Copyright 1999 &copy; <a href="http://www.apache.org">The Apache
  + *         Software Foundation</a>. All rights reserved.
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:52 $
  + */
  +public class SVGSerializer extends DOMBuilder implements Serializer, Composer {
  +   
  +    int R=0;
  +    int G=1;
  +    int B=2;
  +    int A=3;
  +
  +    /** The <code>ContentHandler</code> receiving SAX events. */
  +    private ContentHandler contentHandler=null;
  +    /** The <code>LexicalHandler</code> receiving SAX events. */
  +    private LexicalHandler lexicalHandler=null;
  +    /** The component manager instance */
  +    private ComponentManager manager=null;
  +    /** The current <code>Environment</code>. */
  +    private Environment environment=null;
  +    /** The current <code>Parameters</code>. */
  +    private Parameters parameters=null;
  +    /** The source URI associated with the request or <b>null</b>. */
  +    private String source=null;
  +    /** The current <code>OutputStream</code>. */
  +    private OutputStream output=null;
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        this.output=new BufferedOutputStream(out);
  +    }
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +        this.environment=environment;
  +        this.source=src;
  +        this.parameters=par;
  +        super.factory=(Parser)this.manager.getComponent("parser");
  +    }
  +
  +    /**
  +     * Set the <code>XMLConsumer</code> that will receive XML data.
  +     * <br>
  +     * This method will simply call <code>setContentHandler(consumer)</code>
  +     * and <code>setLexicalHandler(consumer)</code>.
  +     */
  +    public void setConsumer(XMLConsumer consumer) {
  +        this.contentHandler=consumer;
  +        this.lexicalHandler=consumer;
  +    }
  +
  +    /**
  +     * Set the current <code>ComponentManager</code> instance used by this
  +     * <code>Composer</code>.
  +     */
  +    public void setComponentManager(ComponentManager manager) {
  +        this.manager=manager;
  +    }
  +
  +    /**
  +     * Set the <code>ContentHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>ContentHandler</code> instance
  +     * accessing the protected <code>super.contentHandler</code> field.
  +     */
  +    public void setContentHandler(ContentHandler content) {
  +        this.contentHandler=content;
  +    }
  +
  +    /**
  +     * Set the <code>LexicalHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  +     * accessing the protected <code>super.lexicalHandler</code> field.
  +     *
  +     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  +     *                                  the <code>XMLConsumer</code> were
  +     *                                  already set.
  +     */
  +    public void setLexicalHandler(LexicalHandler lexical) {
  +        this.lexicalHandler=lexical;
  +    }
  +
  +    /**
  +     * Receive notification of a successfully completed DOM tree generation.
  +     */
  +    public void notify(Document doc)
  +    throws SAXException {
  +        ((HttpEnvironment)(this.environment)).getResponse().setContentType("image/jpeg");
  +        try {
  +            BufferedImage img=SvgToAwtConverter.convert(doc,this.source);
  +            OutputStream out=this.output;
  +            // Write out image (highest quality for jpeg data)
  +            JPEGEncodeParam jpar=JPEGCodec.getDefaultJPEGEncodeParam(img);
  +            jpar.setQuality(1,true);
  +            JPEGImageEncoder jenc=JPEGCodec.createJPEGEncoder(out,jpar);
  +            jenc.encode(img);
  +            out.flush();
  +
  +        } catch(IOException e) {
  +            throw new SAXException("IOException writing image ",e);
  +        }
  +    }
  +}
  
  
  
  1.1.2.2   +27 -27    xml-cocoon/src/org/apache/cocoon/serialization/Attic/Serializer.java
  
  Index: Serializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/Serializer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Serializer.java	2000/07/11 23:46:51	1.1.2.1
  +++ Serializer.java	2000/07/22 20:41:53	1.1.2.2
  @@ -1,27 +1,27 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  -
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.xml.XMLConsumer;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:51 $
  - */
  -public interface Serializer extends XMLConsumer, SitemapComponent {
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out);
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  +
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.xml.XMLConsumer;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:53 $
  + */
  +public interface Serializer extends XMLConsumer, SitemapComponent {
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out);
  +}
  
  
  
  1.1.2.2   +388 -387  xml-cocoon/src/org/apache/cocoon/serialization/Attic/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/XMLSerializer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XMLSerializer.java	2000/07/11 23:46:52	1.1.2.1
  +++ XMLSerializer.java	2000/07/22 20:41:53	1.1.2.2
  @@ -1,387 +1,388 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  -
  -import java.io.BufferedOutputStream;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.OutputStreamWriter;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.apache.cocoon.xml.util.NamespacesTable;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:52 $
  - */
  -public class XMLSerializer extends AbstractSerializer implements XMLConsumer {
  -    /** The namespaces table */
  -    private NamespacesTable ns=new NamespacesTable();
  -    /** The PrintStream used for output */
  -    private OutputStreamWriter out=null;
  -    /** The current locator */
  -    private Locator loc=null;
  -    /** A flag representing an open element (for "/>" or ">") */
  -    private boolean openElement=false;
  -    /** A flag telling wether we're processing the DTD */
  -    private boolean dtd=false;
  -    /** A flag telling wether we're processing a CDATA section */
  -    private boolean cdata=false;
  -    /** The table of the namespaces to declare */
  -    private Hashtable nstd=new Hashtable();
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        super.setOutputStream(out);
  -        this.out=new OutputStreamWriter(super.output);;
  -    }
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     *
  -     * @param locator An object that can return the location of any SAX
  -     *                document event.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -        this.loc=locator;
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        String c=super.parameters.getParameter("contentType","text/xml");
  -        super.response.setContentType(c);
  -        this.print("<?xml version=\"1.0\"?>\n");
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -        this.closeElement();
  -        try {
  -            this.out.flush();
  -        } catch (IOException e) {
  -            throw new SAXException("IOException flushing stream",e);
  -        }
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        this.ns.addDeclaration(prefix,uri);
  -        this.nstd.put(prefix,uri);
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -        this.ns.removeDeclaration(prefix);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes a)
  -    throws SAXException {
  -        this.closeElement();
  -        this.print('<');
  -
  -        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  -        for (int x=0; x<a.getLength(); x++) {
  -            this.print(' ');
  -            this.print(this.ns.resolve(a.getURI(x),a.getQName(x),null,
  -                                       a.getLocalName(x)).getQName());
  -            this.print('=');
  -            this.print('\"');
  -            this.printSafe(a.getValue(x));
  -            this.print('\"');
  -        }
  -
  -        Enumeration e=this.nstd.keys();
  -        while (e.hasMoreElements()) {
  -            this.print(' ');
  -            String nsname=(String)e.nextElement();
  -            String nsuri=(String)this.nstd.get(nsname);
  -            if (nsname.length()>0) {
  -                this.print("xmlns:");
  -                this.print(nsname);
  -            } else this.print("xmlns");
  -            this.print('=');
  -            this.print('\"');
  -            this.printSafe(nsuri);
  -            this.print('\"');
  -        }
  -        this.nstd.clear();
  -
  -        this.openElement=true;
  -    }
  -        
  -
  -    /**
  -     * 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.
  -     */
  -    public void endElement (String uri, String loc, String raw)
  -    throws SAXException {
  -        if (this.openElement) {
  -            this.print('/');
  -            this.closeElement();
  -            return;
  -        }
  -        this.print('<');
  -        this.print('/');
  -        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  -        this.print('>');
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     *
  -     * @param ch 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.
  -     */
  -    public void characters (char ch[], int start, int len)
  -    throws SAXException {
  -        this.closeElement();
  -        if(this.cdata) this.print(ch,start,len);
  -        else this.printSafe(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     *
  -     * @param ch 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.
  -     */
  -    public void ignorableWhitespace (char ch[], int start, int len)
  -    throws SAXException {
  -        this.closeElement();
  -        if(this.cdata) this.print(ch,start,len);
  -        else this.printSafe(ch,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.
  -     */
  -    public void processingInstruction (String target, String data)
  -    throws SAXException {
  -        this.closeElement();
  -        this.print("<?");
  -        this.print(target);
  -        this.print(' ');
  -        this.print(data);
  -        this.print("?>");
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     *
  -     * @param name The name of the skipped entity.  If it is a  parameter
  -     *             entity, the name will begin with '%'.
  -     */
  -    public void skippedEntity (String name)
  -    throws SAXException {
  -        this.closeElement();
  -        this.print('&');
  -        this.print(name);
  -        this.print(';');
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     *
  -     * @param name The document type name.
  -     * @param publicId The declared public identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     * @param systemId The declared system identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     */
  -    public void startDTD (String name, String publicId, String systemId)
  -    throws SAXException {
  -        this.print("<!DOCTYPE ");
  -        this.print(name);
  -        if (publicId!=null) {
  -            this.print(" PUBLIC \"");
  -            this.print(publicId);
  -            this.print('\"');
  -            if (systemId!=null) {
  -                this.print(' ');
  -                this.print('\"');
  -                this.print(systemId);
  -                this.print('\"');
  -            }
  -        } else if (systemId!=null) {
  -            this.print(" SYSTEM \"");
  -            this.print(systemId);
  -            this.print('\"');
  -        }
  -        this.print('>');
  -        this.print('\n');
  -        // Set the DTD flag now, to avoid output
  -        this.dtd=true;
  -    }        
  -    
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD ()
  -    throws SAXException {
  -        this.dtd=false;
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     *
  -     * @param name The name of the entity. If it is a parameter entity, the
  -     *             name will begin with '%'.
  -     */
  -    public void startEntity (String name)
  -    throws SAXException {
  -        this.closeElement();
  -    }        
  -
  -    /**
  -     * Report the end of an entity.
  -     *
  -     * @param name The name of the entity that is ending.
  -     */
  -    public void endEntity (String name)
  -    throws SAXException {
  -        this.closeElement();
  -    }        
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA ()
  -    throws SAXException {
  -        this.closeElement();
  -        this.print("<![CDATA[");
  -        this.cdata=true;
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA ()
  -    throws SAXException {
  -        this.cdata=false;
  -        this.closeElement();
  -        this.print("]]>");
  -    }
  -    
  -
  -    /**
  -     * 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.
  -     */
  -    public void comment (char ch[], int start, int len)
  -    throws SAXException {
  -        this.closeElement();
  -        this.print("<!--");
  -        this.print(ch,start,len);
  -        this.print("-->");
  -    }
  -
  -    /** Print a string */
  -    private void print(String s)
  -    throws SAXException {
  -        if(s==null) return;
  -        char data[]=s.toCharArray();
  -        this.print(data,0,data.length);
  -    }
  -    
  -    /** Print data from a character array */
  -    private void print(char data[], int start, int len)
  -    throws SAXException {
  -        try {
  -            if(!this.dtd) this.out.write(data,start,len);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Print data from a character array */
  -    private void print(char c)
  -    throws SAXException {
  -        try {
  -            if(!this.dtd) this.out.write(c);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Print a string */
  -    private void printSafe(String s)
  -    throws SAXException {
  -        if(s==null) return;
  -        char data[]=s.toCharArray();
  -        this.printSafe(data,0,data.length);
  -    }
  -    
  -    /** Print data from a character array */
  -    private void printSafe(char data[], int start, int len)
  -    throws SAXException {
  -        int end=start+len;
  -        if(!this.dtd) for(int x=start; x<end; x++) this.printSafe(data[x]);
  -    }
  -
  -    /** Print data from a character array */
  -    private void printSafe(char c)
  -    throws SAXException {
  -        try {
  -            if(this.dtd) return;
  -            if(c=='&') this.print("&amp;");
  -            else if(c=='<') this.print("&lt;");
  -            else if(c=='>') this.print("&gt;");
  -            else this.out.write(c);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Close an element, if required */
  -    private void closeElement()
  -    throws SAXException {
  -        if(!this.openElement) return;
  -        this.print('>');
  -        this.openElement=false;
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.serialization;
  +
  +import java.io.BufferedOutputStream;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.OutputStreamWriter;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.cocoon.xml.util.NamespacesTable;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:53 $
  + */
  +public class XMLSerializer extends AbstractSerializer implements XMLConsumer {
  +    /** The namespaces table */
  +    private NamespacesTable ns=new NamespacesTable();
  +    /** The PrintStream used for output */
  +    private OutputStreamWriter out=null;
  +    /** The current locator */
  +    private Locator loc=null;
  +    /** A flag representing an open element (for "/>" or ">") */
  +    private boolean openElement=false;
  +    /** A flag telling wether we're processing the DTD */
  +    private boolean dtd=false;
  +    /** A flag telling wether we're processing a CDATA section */
  +    private boolean cdata=false;
  +    /** The table of the namespaces to declare */
  +    private Hashtable nstd=new Hashtable();
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        super.setOutputStream(out);
  +        this.out=new OutputStreamWriter(super.output);;
  +    }
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     *
  +     * @param locator An object that can return the location of any SAX
  +     *                document event.
  +     */
  +    public void setDocumentLocator(Locator locator) {
  +        this.loc=locator;
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +        String c=super.parameters.getParameter("contentType","text/xml");
  +        ((HttpEnvironment)(super.environment)).getResponse().setContentType(c);
  +        this.print("<?xml version=\"1.0\"?>\n");
  +    }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument()
  +    throws SAXException {
  +        this.closeElement();
  +        try {
  +            this.out.flush();
  +        } catch (IOException e) {
  +            throw new SAXException("IOException flushing stream",e);
  +        }
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        this.ns.addDeclaration(prefix,uri);
  +        this.nstd.put(prefix,uri);
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +        this.ns.removeDeclaration(prefix);
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes a)
  +    throws SAXException {
  +        this.closeElement();
  +        this.print('<');
  +
  +        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  +        for (int x=0; x<a.getLength(); x++) {
  +            this.print(' ');
  +            this.print(this.ns.resolve(a.getURI(x),a.getQName(x),null,
  +                                       a.getLocalName(x)).getQName());
  +            this.print('=');
  +            this.print('\"');
  +            this.printSafe(a.getValue(x));
  +            this.print('\"');
  +        }
  +
  +        Enumeration e=this.nstd.keys();
  +        while (e.hasMoreElements()) {
  +            this.print(' ');
  +            String nsname=(String)e.nextElement();
  +            String nsuri=(String)this.nstd.get(nsname);
  +            if (nsname.length()>0) {
  +                this.print("xmlns:");
  +                this.print(nsname);
  +            } else this.print("xmlns");
  +            this.print('=');
  +            this.print('\"');
  +            this.printSafe(nsuri);
  +            this.print('\"');
  +        }
  +        this.nstd.clear();
  +
  +        this.openElement=true;
  +    }
  +        
  +
  +    /**
  +     * 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.
  +     */
  +    public void endElement (String uri, String loc, String raw)
  +    throws SAXException {
  +        if (this.openElement) {
  +            this.print('/');
  +            this.closeElement();
  +            return;
  +        }
  +        this.print('<');
  +        this.print('/');
  +        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  +        this.print('>');
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     *
  +     * @param ch 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.
  +     */
  +    public void characters (char ch[], int start, int len)
  +    throws SAXException {
  +        this.closeElement();
  +        if(this.cdata) this.print(ch,start,len);
  +        else this.printSafe(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     *
  +     * @param ch 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.
  +     */
  +    public void ignorableWhitespace (char ch[], int start, int len)
  +    throws SAXException {
  +        this.closeElement();
  +        if(this.cdata) this.print(ch,start,len);
  +        else this.printSafe(ch,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.
  +     */
  +    public void processingInstruction (String target, String data)
  +    throws SAXException {
  +        this.closeElement();
  +        this.print("<?");
  +        this.print(target);
  +        this.print(' ');
  +        this.print(data);
  +        this.print("?>");
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     *
  +     * @param name The name of the skipped entity.  If it is a  parameter
  +     *             entity, the name will begin with '%'.
  +     */
  +    public void skippedEntity (String name)
  +    throws SAXException {
  +        this.closeElement();
  +        this.print('&');
  +        this.print(name);
  +        this.print(';');
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any.
  +     *
  +     * @param name The document type name.
  +     * @param publicId The declared public identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     * @param systemId The declared system identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     */
  +    public void startDTD (String name, String publicId, String systemId)
  +    throws SAXException {
  +        this.print("<!DOCTYPE ");
  +        this.print(name);
  +        if (publicId!=null) {
  +            this.print(" PUBLIC \"");
  +            this.print(publicId);
  +            this.print('\"');
  +            if (systemId!=null) {
  +                this.print(' ');
  +                this.print('\"');
  +                this.print(systemId);
  +                this.print('\"');
  +            }
  +        } else if (systemId!=null) {
  +            this.print(" SYSTEM \"");
  +            this.print(systemId);
  +            this.print('\"');
  +        }
  +        this.print('>');
  +        this.print('\n');
  +        // Set the DTD flag now, to avoid output
  +        this.dtd=true;
  +    }        
  +    
  +    /**
  +     * Report the end of DTD declarations.
  +     */
  +    public void endDTD ()
  +    throws SAXException {
  +        this.dtd=false;
  +    }
  +
  +    /**
  +     * Report the beginning of an entity.
  +     *
  +     * @param name The name of the entity. If it is a parameter entity, the
  +     *             name will begin with '%'.
  +     */
  +    public void startEntity (String name)
  +    throws SAXException {
  +        this.closeElement();
  +    }        
  +
  +    /**
  +     * Report the end of an entity.
  +     *
  +     * @param name The name of the entity that is ending.
  +     */
  +    public void endEntity (String name)
  +    throws SAXException {
  +        this.closeElement();
  +    }        
  +
  +    /**
  +     * Report the start of a CDATA section.
  +     */
  +    public void startCDATA ()
  +    throws SAXException {
  +        this.closeElement();
  +        this.print("<![CDATA[");
  +        this.cdata=true;
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section.
  +     */
  +    public void endCDATA ()
  +    throws SAXException {
  +        this.cdata=false;
  +        this.closeElement();
  +        this.print("]]>");
  +    }
  +    
  +
  +    /**
  +     * 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.
  +     */
  +    public void comment (char ch[], int start, int len)
  +    throws SAXException {
  +        this.closeElement();
  +        this.print("<!--");
  +        this.print(ch,start,len);
  +        this.print("-->");
  +    }
  +
  +    /** Print a string */
  +    private void print(String s)
  +    throws SAXException {
  +        if(s==null) return;
  +        char data[]=s.toCharArray();
  +        this.print(data,0,data.length);
  +    }
  +    
  +    /** Print data from a character array */
  +    private void print(char data[], int start, int len)
  +    throws SAXException {
  +        try {
  +            if(!this.dtd) this.out.write(data,start,len);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Print data from a character array */
  +    private void print(char c)
  +    throws SAXException {
  +        try {
  +            if(!this.dtd) this.out.write(c);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Print a string */
  +    private void printSafe(String s)
  +    throws SAXException {
  +        if(s==null) return;
  +        char data[]=s.toCharArray();
  +        this.printSafe(data,0,data.length);
  +    }
  +    
  +    /** Print data from a character array */
  +    private void printSafe(char data[], int start, int len)
  +    throws SAXException {
  +        int end=start+len;
  +        if(!this.dtd) for(int x=start; x<end; x++) this.printSafe(data[x]);
  +    }
  +
  +    /** Print data from a character array */
  +    private void printSafe(char c)
  +    throws SAXException {
  +        try {
  +            if(this.dtd) return;
  +            if(c=='&') this.print("&amp;");
  +            else if(c=='<') this.print("&lt;");
  +            else if(c=='>') this.print("&gt;");
  +            else this.out.write(c);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Close an element, if required */
  +    private void closeElement()
  +    throws SAXException {
  +        if(!this.openElement) return;
  +        this.print('>');
  +        this.openElement=false;
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.13  +255 -251  xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
  retrieving revision 1.1.4.12
  retrieving revision 1.1.4.13
  diff -u -r1.1.4.12 -r1.1.4.13
  --- CocoonServlet.java	2000/07/14 14:03:45	1.1.4.12
  +++ CocoonServlet.java	2000/07/22 20:41:54	1.1.4.13
  @@ -1,251 +1,255 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.servlet;
  -
  -import java.util.Date;
  -import java.io.IOException;
  -import java.io.PrintWriter;
  -import java.util.Enumeration;
  -import javax.servlet.ServletConfig;
  -import javax.servlet.ServletContext;
  -import javax.servlet.ServletException;
  -import javax.servlet.ServletOutputStream;
  -import javax.servlet.http.HttpServlet;
  -import javax.servlet.http.HttpServletRequest;
  -import javax.servlet.http.HttpServletResponse;
  -import org.apache.avalon.ConfigurationException;
  -import org.apache.avalon.ComponentNotAccessibleException;
  -import org.apache.cocoon.Cocoon;
  -import org.apache.cocoon.ProcessingException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.12 $ $Date: 2000/07/14 14:03:45 $
  - */
  -public class CocoonServlet extends HttpServlet {
  -    private Cocoon cocoon=null;
  -    private long creationTime=0;
  -    private String configurationFile=null;
  -    private Exception exception=null;
  -    private ServletContext context=null;
  -
  -    /**
  -     * Initialize this <code>CocoonServlet</code> instance.
  -     */
  -    public void init(ServletConfig conf)
  -    throws ServletException {
  -        super.init(conf);
  -        this.context=conf.getServletContext();
  -        String configFile=conf.getInitParameter("configurations");
  -        this.context.log ("this.configurationFile: "+this.configurationFile);
  -        if (configFile==null) {
  -            throw new ServletException("Servlet initialization argument "+
  -                                       "'configurations' not specified");
  -        }
  -        try {
  -            this.configurationFile=this.context.getResource(configFile).getFile();
  -            this.context.log ("this.configurationFile: "+this.configurationFile);
  -        } catch (java.net.MalformedURLException mue) {
  -            throw new ServletException("Servlet initialization argument "+
  -                                       "'configurations' not found at "+this.configurationFile);
  -        }
  -        this.cocoon=this.create();
  -    }
  -
  -    /**
  -     * Process the specified <code>HttpServletRequest</code> producing output
  -     * on the specified <code>HttpServletResponse</code>.
  -     */
  -    public void service(HttpServletRequest req, HttpServletResponse res)
  -    throws ServletException, IOException {
  -        long start = new Date().getTime();
  -        long end = 0;
  -        // Reload cocoon if configuration changed or we are reloading
  -        boolean reloaded=false;
  -        synchronized (this) {
  -            if (this.cocoon!=null) {
  -                if (this.cocoon.modifiedSince(this.creationTime)) {
  -                    this.context.log("Configuration changed reload attempt");
  -                    this.cocoon=this.create();
  -                    reloaded=true;
  -                } else if ((req.getPathInfo()==null) &&
  -                           (req.getParameter("reload")!=null)) {
  -                    this.context.log("Forced reload attempt");
  -                    this.cocoon=this.create();
  -                    reloaded=true;
  -                }
  -            } else if ((req.getPathInfo()==null) &&
  -                       (req.getParameter("reload")!=null)) {
  -                this.context.log("Invalid configurations reload");
  -                this.cocoon=this.create();
  -                reloaded=true;
  -            }
  -        }
  -
  -        ServletOutputStream out=res.getOutputStream();
  -
  -        // Check if cocoon was initialized
  -        if (this.cocoon==null) {
  -            res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  -            res.setContentType("text/html");
  -            out.println("<html><head>");
  -            out.println("<title>Cocoon Version 2.0: Not initialized</title>");
  -            out.println("<body>");
  -            out.println("<center><h1>Cocoon 2.0: Not initialized</h1></center>");
  -            out.println("<hr>");
  -            out.print("Try to <a href=\"");
  -            out.print(req.getScheme()+"://"+req.getServerName()+":");
  -            out.print(req.getServerPort()+req.getServletPath());
  -            out.print("?reload=true\">Reload</a>");
  -            out.println("<!-- PATH_INFO=\""+req.getPathInfo()+"\" -->");
  -            out.println("<hr>");
  -            this.printException(out,this.exception);
  -            if (exception instanceof SAXException) {
  -                Exception nested=((SAXException)this.exception).getException();
  -                out.println("<hr>");
  -                this.printException(out,nested);
  -            } else if (exception instanceof ComponentNotAccessibleException) {
  -                out.println("Component not accessible<br>");
  -                Exception nested=this.exception;
  -                nested=((ComponentNotAccessibleException)nested).getException();
  -                out.println("<hr>");
  -                this.printException(out,nested);
  -            }
  -            out.println("<hr></body></html>");
  -            out.flush();
  -            return;
  -        }
  -        // We got it... Process the request
  -        // We should use getRequestURI(), minus the Context path otherwise
  -        // we break compatability with Tomcat and other Servlet 2.2 engines
  -        // (like Gefion LWS and Orion)
  -        String uri=req.getRequestURI().substring(req.getContextPath().length());
  -        if (!uri.equals("")) {
  -            try {
  -                if (uri.charAt(0)=='/') uri=uri.substring(1);
  -                CocoonServletRequest request=new CocoonServletRequest(req,uri);
  -                CocoonServletResponse response=new CocoonServletResponse(res);
  -                if (!this.cocoon.process(request,response,out)) {
  -                    res.setStatus(res.SC_NOT_FOUND);
  -                    res.setContentType("text/html");
  -                    out.println("<html><head>");
  -                    out.println("<title>Cocoon Version 2.0: Not Found</title>");
  -                    out.println("<body>");
  -                    out.println("<center><h1>Cocoon 2.0: Not Found</h1></center>");
  -                    out.println("<hr>");
  -                    out.print("The requested URI \""+req.getRequestURI());
  -                    out.print("\" was not found.");
  -                    out.println("<!-- PATH_INFO=\""+uri+"\" -->");
  -                    out.println("<hr></body></html>");
  -                }
  -            } catch (Exception e) {
  -                //res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  -                res.setContentType("text/html");
  -                out.println("<html><head>");
  -                out.println("<title>Cocoon Version 2.0: Exception</title>");
  -                out.println("<body>");
  -                out.println("<center><h1>Cocoon 2.0: Exception</h1></center>");
  -                out.println("<hr>");
  -                this.printException(out,e);
  -                if (e instanceof SAXException) {
  -                    out.println("<hr>");
  -                    out.println("SAX processing exception<br>");
  -                    Exception nested=((SAXException)e).getException();
  -                    this.printException(out,nested);
  -                } else if (e instanceof ComponentNotAccessibleException) {
  -                    out.println("<hr>");
  -                    out.println("Component not accessible<br>");
  -                    Exception nested=e;
  -                    nested=((ComponentNotAccessibleException)nested).getException();
  -                    this.printException(out,nested);
  -                }
  -
  -                out.println("<hr></body></html>");
  -            }
  -        } else {
  -            res.setContentType("text/html");
  -            out.println("<html><head>");
  -            out.println("<title>Cocoon Version 2.0</title>");
  -            out.println("<body>");
  -            out.println("<center><h1>Cocoon 2.0: Version 2.0</h1></center>");
  -            out.println("<hr>");
  -            if (reloaded) out.println("Configurations reloaded.<br>");
  -            out.println("Ready to process requests...");
  -            out.println("<!-- PATH_INFO=\""+uri+"\" -->");
  -            out.println("<hr></body></html>");
  -        }
  -
  -        end = new Date().getTime();
  -        String showTime = req.getParameter("showtime");
  -        if ((showTime != null) && !showTime.equalsIgnoreCase("no")) {
  -            float time = (float) (end - start);
  -            float second = (float) 1000;
  -            float minute = (float) 60 * second;
  -            float hour = (float) 60 * minute;
  -
  -            if (showTime.equalsIgnoreCase("hide")) {
  -                out.print("<!--");
  -            } else {
  -                out.print("<p>");
  -            }
  -            out.print("Processed by Cocoon in ");
  -
  -            if (time > hour) {
  -                out.print(time / hour);
  -                out.print(" hours.");
  -            } else if (time > minute) {
  -                out.print(time / minute);
  -                out.print(" minutes.");
  -            } else if (time > second) {
  -                out.print(time / second);
  -                out.print(" seconds.");
  -            } else {
  -                out.print(time);
  -                out.print(" milliseconds.");
  -            }
  -
  -            if (showTime == "hide") {
  -                out.print("-->");
  -            } else {
  -                out.print("</p>");
  -            }
  -        }
  -
  -        out.flush();
  -    }
  -
  -    /** Create a new <code>Cocoon</code> object. */
  -    private Cocoon create() {
  -        try {
  -            this.context.log("Reloading from: "+this.configurationFile);
  -            Cocoon c=new Cocoon(this.configurationFile);
  -            this.creationTime=System.currentTimeMillis();
  -            return(c);
  -        } catch (Exception e) {
  -            this.context.log("Exception reloading: "+e.getMessage());
  -            this.exception=e;
  -        }
  -        return(null);
  -    }
  -
  -    /** Dump an exception to the specified <code>ServletOutputStream</code> */
  -    private void printException(ServletOutputStream o, Exception e) {
  -        PrintWriter out=new PrintWriter(o);
  -        out.println("Class: <b>"+e.getClass().getName()+"</b><br>");
  -        out.println("Message: <i>"+e.getMessage()+"</i><br>");
  -        out.println("<pre>");
  -        e.printStackTrace(out);
  -        out.println("</pre>");
  -        out.flush();
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.servlet;
  +
  +import java.util.Date;
  +import java.io.IOException;
  +import java.io.PrintWriter;
  +import java.util.Enumeration;
  +
  +import javax.servlet.ServletConfig;
  +import javax.servlet.ServletContext;
  +import javax.servlet.ServletException;
  +import javax.servlet.ServletOutputStream;
  +import javax.servlet.http.HttpServlet;
  +import javax.servlet.http.HttpServletRequest;
  +import javax.servlet.http.HttpServletResponse;
  +
  +import org.apache.avalon.ConfigurationException;
  +import org.apache.avalon.ComponentNotAccessibleException;
  +
  +import org.apache.cocoon.Cocoon;
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.4.13 $ $Date: 2000/07/22 20:41:54 $
  + */
  +public class CocoonServlet extends HttpServlet {
  +    private Cocoon cocoon=null;
  +    private long creationTime=0;
  +    private String configurationFile=null;
  +    private Exception exception=null;
  +    private ServletContext context=null;
  +
  +    /**
  +     * Initialize this <code>CocoonServlet</code> instance.
  +     */
  +    public void init(ServletConfig conf)
  +    throws ServletException {
  +        super.init(conf);
  +        this.context=conf.getServletContext();
  +        String configFile=conf.getInitParameter("configurations");
  +        this.context.log ("this.configurationFile: "+this.configurationFile);
  +        if (configFile==null) {
  +            throw new ServletException("Servlet initialization argument "+
  +                                       "'configurations' not specified");
  +        }
  +        try {
  +            this.configurationFile=this.context.getResource(configFile).getFile();
  +            this.context.log ("this.configurationFile: "+this.configurationFile);
  +        } catch (java.net.MalformedURLException mue) {
  +            throw new ServletException("Servlet initialization argument "+
  +                                       "'configurations' not found at "+this.configurationFile);
  +        }
  +        this.cocoon=this.create();
  +    }
  +
  +    /**
  +     * Process the specified <code>HttpServletRequest</code> producing output
  +     * on the specified <code>HttpServletResponse</code>.
  +     */
  +    public void service(HttpServletRequest req, HttpServletResponse res)
  +    throws ServletException, IOException {
  +        long start = new Date().getTime();
  +        long end = 0;
  +        // Reload cocoon if configuration changed or we are reloading
  +        boolean reloaded=false;
  +        synchronized (this) {
  +            if (this.cocoon!=null) {
  +                if (this.cocoon.modifiedSince(this.creationTime)) {
  +                    this.context.log("Configuration changed reload attempt");
  +                    this.cocoon=this.create();
  +                    reloaded=true;
  +                } else if ((req.getPathInfo()==null) &&
  +                           (req.getParameter("reload")!=null)) {
  +                    this.context.log("Forced reload attempt");
  +                    this.cocoon=this.create();
  +                    reloaded=true;
  +                }
  +            } else if ((req.getPathInfo()==null) &&
  +                       (req.getParameter("reload")!=null)) {
  +                this.context.log("Invalid configurations reload");
  +                this.cocoon=this.create();
  +                reloaded=true;
  +            }
  +        }
  +
  +        ServletOutputStream out=res.getOutputStream();
  +
  +        // Check if cocoon was initialized
  +        if (this.cocoon==null) {
  +            res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  +            res.setContentType("text/html");
  +            out.println("<html><head>");
  +            out.println("<title>Cocoon Version 2.0: Not initialized</title>");
  +            out.println("<body>");
  +            out.println("<center><h1>Cocoon 2.0: Not initialized</h1></center>");
  +            out.println("<hr>");
  +            out.print("Try to <a href=\"");
  +            out.print(req.getScheme()+"://"+req.getServerName()+":");
  +            out.print(req.getServerPort()+req.getServletPath());
  +            out.print("?reload=true\">Reload</a>");
  +            out.println("<!-- PATH_INFO=\""+req.getPathInfo()+"\" -->");
  +            out.println("<hr>");
  +            this.printException(out,this.exception);
  +            if (exception instanceof SAXException) {
  +                Exception nested=((SAXException)this.exception).getException();
  +                out.println("<hr>");
  +                this.printException(out,nested);
  +            } else if (exception instanceof ComponentNotAccessibleException) {
  +                out.println("Component not accessible<br>");
  +                Exception nested=this.exception;
  +                nested=((ComponentNotAccessibleException)nested).getException();
  +                out.println("<hr>");
  +                this.printException(out,nested);
  +            }
  +            out.println("<hr></body></html>");
  +            out.flush();
  +            return;
  +        }
  +        // We got it... Process the request
  +        // We should use getRequestURI(), minus the Context path otherwise
  +        // we break compatability with Tomcat and other Servlet 2.2 engines
  +        // (like Gefion LWS and Orion)
  +        String uri=req.getRequestURI().substring(req.getContextPath().length());
  +        if (!uri.equals("")) {
  +            try {
  +                if (uri.charAt(0)=='/') uri=uri.substring(1);
  +                HttpEnvironment env = new HttpEnvironment (uri, req, res);
  +                if (!this.cocoon.process(env,out)) {
  +                    res.setStatus(res.SC_NOT_FOUND);
  +                    res.setContentType("text/html");
  +                    out.println("<html><head>");
  +                    out.println("<title>Cocoon Version 2.0: Not Found</title>");
  +                    out.println("<body>");
  +                    out.println("<center><h1>Cocoon 2.0: Not Found</h1></center>");
  +                    out.println("<hr>");
  +                    out.print("The requested URI \""+req.getRequestURI());
  +                    out.print("\" was not found.");
  +                    out.println("<!-- PATH_INFO=\""+uri+"\" -->");
  +                    out.println("<hr></body></html>");
  +                }
  +            } catch (Exception e) {
  +                //res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  +                res.setContentType("text/html");
  +                out.println("<html><head>");
  +                out.println("<title>Cocoon Version 2.0: Exception</title>");
  +                out.println("<body>");
  +                out.println("<center><h1>Cocoon 2.0: Exception</h1></center>");
  +                out.println("<hr>");
  +                this.printException(out,e);
  +                if (e instanceof SAXException) {
  +                    out.println("<hr>");
  +                    out.println("SAX processing exception<br>");
  +                    Exception nested=((SAXException)e).getException();
  +                    this.printException(out,nested);
  +                } else if (e instanceof ComponentNotAccessibleException) {
  +                    out.println("<hr>");
  +                    out.println("Component not accessible<br>");
  +                    Exception nested=e;
  +                    nested=((ComponentNotAccessibleException)nested).getException();
  +                    this.printException(out,nested);
  +                }
  +
  +                out.println("<hr></body></html>");
  +            }
  +        } else {
  +            res.setContentType("text/html");
  +            out.println("<html><head>");
  +            out.println("<title>Cocoon Version 2.0</title>");
  +            out.println("<body>");
  +            out.println("<center><h1>Cocoon 2.0: Version 2.0</h1></center>");
  +            out.println("<hr>");
  +            if (reloaded) out.println("Configurations reloaded.<br>");
  +            out.println("Ready to process requests...");
  +            out.println("<!-- PATH_INFO=\""+uri+"\" -->");
  +            out.println("<hr></body></html>");
  +        }
  +
  +        end = new Date().getTime();
  +        String showTime = req.getParameter("showtime");
  +        if ((showTime != null) && !showTime.equalsIgnoreCase("no")) {
  +            float time = (float) (end - start);
  +            float second = (float) 1000;
  +            float minute = (float) 60 * second;
  +            float hour = (float) 60 * minute;
  +
  +            if (showTime.equalsIgnoreCase("hide")) {
  +                out.print("<!--");
  +            } else {
  +                out.print("<p>");
  +            }
  +            out.print("Processed by Cocoon in ");
  +
  +            if (time > hour) {
  +                out.print(time / hour);
  +                out.print(" hours.");
  +            } else if (time > minute) {
  +                out.print(time / minute);
  +                out.print(" minutes.");
  +            } else if (time > second) {
  +                out.print(time / second);
  +                out.print(" seconds.");
  +            } else {
  +                out.print(time);
  +                out.print(" milliseconds.");
  +            }
  +
  +            if (showTime == "hide") {
  +                out.print("-->");
  +            } else {
  +                out.print("</p>");
  +            }
  +        }
  +
  +        out.flush();
  +    }
  +
  +    /** Create a new <code>Cocoon</code> object. */
  +    private Cocoon create() {
  +        try {
  +            this.context.log("Reloading from: "+this.configurationFile);
  +            Cocoon c=new Cocoon(this.configurationFile);
  +            this.creationTime=System.currentTimeMillis();
  +            return(c);
  +        } catch (Exception e) {
  +            this.context.log("Exception reloading: "+e.getMessage());
  +            this.exception=e;
  +        }
  +        return(null);
  +    }
  +
  +    /** Dump an exception to the specified <code>ServletOutputStream</code> */
  +    private void printException(ServletOutputStream o, Exception e) {
  +        PrintWriter out=new PrintWriter(o);
  +        out.println("Class: <b>"+e.getClass().getName()+"</b><br>");
  +        out.println("Message: <i>"+e.getMessage()+"</i><br>");
  +        out.println("<pre>");
  +        e.printStackTrace(out);
  +        out.println("</pre>");
  +        out.flush();
  +    }
  +}
  
  
  
  1.1.4.4   +101 -101  xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServletRequest.java
  
  Index: CocoonServletRequest.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServletRequest.java,v
  retrieving revision 1.1.4.3
  retrieving revision 1.1.4.4
  diff -u -r1.1.4.3 -r1.1.4.4
  --- CocoonServletRequest.java	2000/02/27 05:45:19	1.1.4.3
  +++ CocoonServletRequest.java	2000/07/22 20:41:55	1.1.4.4
  @@ -1,101 +1,101 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.servlet;
  -
  -import java.util.Enumeration;
  -import javax.servlet.http.HttpServletRequest;
  -import org.apache.cocoon.Request;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.3 $ $Date: 2000/02/27 05:45:19 $
  - */
  -public class CocoonServletRequest implements Request {
  -    
  -    /** This request <code>HttpServletRequest</code> */
  -    private HttpServletRequest request=null;
  -    /** This reques <code>String</code>uri */
  -    private String uri=null;
  -    
  -    /**
  -     * Create a new instance of this <code>CocoonServletRequest</code>
  -     */
  -    protected CocoonServletRequest(HttpServletRequest r, String u) {
  -        super();
  -        if ((r==null)||(u==null))
  -            throw new IllegalArgumentException("Null parameter specified");
  -        this.request=r;
  -        this.uri=u;
  -    }
  -
  -    /**
  -     * Returns the URI as it should be matched by the <code>Sitemap</code>
  -     */
  -    public String getUri() {
  -        return(this.uri);
  -    }
  -
  -    /**
  -     * Returns the value of the specified parameter, or <code>null</code> if
  -     * the parameter does not exist.
  -     */
  -    public String getParameter(String name) {
  -        return(this.request.getParameter(name));
  -    }
  -
  -    /**
  -     * Returns the values of the specified parameter for the request as an
  -     * array of strings, or <code>null</code> if the parameter does not exist.
  -     */
  -    public String[] getParameterValues(String name) {
  -        return(this.request.getParameterValues(name));
  -    }
  -
  -    /**
  -     * Returns the parameter names for this request as an
  -     * <code>Enumeration</code> of <code>String</code> objects , or an empty
  -     * <code>Enumeration</code> if there are no parameters.
  -     */
  -    public Enumeration getParameterNames() {
  -        return(this.request.getParameterNames());
  -    }
  -
  -    /**
  -     * Gets the value of the requested header field of this request.
  -     */
  -    public String getHeader(String name) {
  -        return(this.request.getHeader(name));
  -    }
  -
  -    /**
  -     * Gets the value of the requested header field of this request as an
  -     * integer.
  -     */
  -    public int getIntHeader(String name) {
  -        return(this.request.getIntHeader(name));
  -    }
  -
  -    /**
  -     * Gets the value of the requested header field of this request as a
  -     * date.
  -     */
  -    public long getDateHeader(String name) {
  -        return(this.request.getDateHeader(name));
  -    }
  -
  -    /**
  -     * Returns the header names for this request as an
  -     * <code>Enumeration</code> of <code>String</code> objects , or an empty
  -     * <code>Enumeration</code> if there are no headers.
  -     */
  -    public Enumeration getHeaderNames() {
  -        return(this.request.getHeaderNames());
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.servlet;
  +
  +import java.util.Enumeration;
  +import javax.servlet.http.HttpServletRequest;
  +import org.apache.cocoon.Request;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.4.4 $ $Date: 2000/07/22 20:41:55 $
  + */
  +public class CocoonServletRequest implements Request {
  +    
  +    /** This request <code>HttpServletRequest</code> */
  +    private HttpServletRequest request=null;
  +    /** This reques <code>String</code>uri */
  +    private String uri=null;
  +    
  +    /**
  +     * Create a new instance of this <code>CocoonServletRequest</code>
  +     */
  +    protected CocoonServletRequest(HttpServletRequest r, String u) {
  +        super();
  +        if ((r==null)||(u==null))
  +            throw new IllegalArgumentException("Null parameter specified");
  +        this.request=r;
  +        this.uri=u;
  +    }
  +
  +    /**
  +     * Returns the URI as it should be matched by the <code>Sitemap</code>
  +     */
  +    public String getUri() {
  +        return(this.uri);
  +    }
  +
  +    /**
  +     * Returns the value of the specified parameter, or <code>null</code> if
  +     * the parameter does not exist.
  +     */
  +    public String getParameter(String name) {
  +        return(this.request.getParameter(name));
  +    }
  +
  +    /**
  +     * Returns the values of the specified parameter for the request as an
  +     * array of strings, or <code>null</code> if the parameter does not exist.
  +     */
  +    public String[] getParameterValues(String name) {
  +        return(this.request.getParameterValues(name));
  +    }
  +
  +    /**
  +     * Returns the parameter names for this request as an
  +     * <code>Enumeration</code> of <code>String</code> objects , or an empty
  +     * <code>Enumeration</code> if there are no parameters.
  +     */
  +    public Enumeration getParameterNames() {
  +        return(this.request.getParameterNames());
  +    }
  +
  +    /**
  +     * Gets the value of the requested header field of this request.
  +     */
  +    public String getHeader(String name) {
  +        return(this.request.getHeader(name));
  +    }
  +
  +    /**
  +     * Gets the value of the requested header field of this request as an
  +     * integer.
  +     */
  +    public int getIntHeader(String name) {
  +        return(this.request.getIntHeader(name));
  +    }
  +
  +    /**
  +     * Gets the value of the requested header field of this request as a
  +     * date.
  +     */
  +    public long getDateHeader(String name) {
  +        return(this.request.getDateHeader(name));
  +    }
  +
  +    /**
  +     * Returns the header names for this request as an
  +     * <code>Enumeration</code> of <code>String</code> objects , or an empty
  +     * <code>Enumeration</code> if there are no headers.
  +     */
  +    public Enumeration getHeaderNames() {
  +        return(this.request.getHeaderNames());
  +    }
  +}
  
  
  
  1.1.4.3   +66 -66    xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServletResponse.java
  
  Index: CocoonServletResponse.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServletResponse.java,v
  retrieving revision 1.1.4.2
  retrieving revision 1.1.4.3
  diff -u -r1.1.4.2 -r1.1.4.3
  --- CocoonServletResponse.java	2000/02/27 01:33:08	1.1.4.2
  +++ CocoonServletResponse.java	2000/07/22 20:41:55	1.1.4.3
  @@ -1,66 +1,66 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.servlet;
  -
  -import java.io.IOException;
  -import java.io.PrintWriter;
  -import javax.servlet.ServletOutputStream;
  -import javax.servlet.http.Cookie;
  -import javax.servlet.http.HttpServletResponse;
  -import javax.servlet.http.HttpSession;
  -import org.apache.cocoon.Response;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.2 $ $Date: 2000/02/27 01:33:08 $
  - */
  -public class CocoonServletResponse implements Response {
  -
  -    /** This response <code>HttpServletResponse</code> */
  -    private HttpServletResponse response=null;
  -    
  -    /**
  -     * Create a new instance of this <code>CocoonServletResponse</code>
  -     */
  -    protected CocoonServletResponse(HttpServletResponse res) {
  -        super();
  -        this.response=res;
  -    }
  -
  -    /**
  -     * Adds a field to the response header with the given name and value.
  -     */
  -    public void setHeader(String name, String value) {
  -        this.response.setHeader(name,value);
  -    }
  -
  -    /**
  -     * Adds a field to the response header with the given name and
  -     * integer value.
  -     */
  -    public void setIntHeader(String name, int value) {
  -        this.response.setIntHeader(name,value);
  -    }
  -
  -    /**
  -     * Adds a field to the response header with the given name and
  -     * date-valued field.
  -     */
  -    public void setDateHeader(String name, long date) {
  -        this.response.setDateHeader(name,date);
  -    }
  -
  -    /**
  -     * Sets the content type for this response.
  -     */
  -    public void setContentType(String type) {
  -        this.response.setContentType(type);
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.servlet;
  +
  +import java.io.IOException;
  +import java.io.PrintWriter;
  +import javax.servlet.ServletOutputStream;
  +import javax.servlet.http.Cookie;
  +import javax.servlet.http.HttpServletResponse;
  +import javax.servlet.http.HttpSession;
  +import org.apache.cocoon.Response;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.4.3 $ $Date: 2000/07/22 20:41:55 $
  + */
  +public class CocoonServletResponse implements Response {
  +
  +    /** This response <code>HttpServletResponse</code> */
  +    private HttpServletResponse response=null;
  +    
  +    /**
  +     * Create a new instance of this <code>CocoonServletResponse</code>
  +     */
  +    protected CocoonServletResponse(HttpServletResponse res) {
  +        super();
  +        this.response=res;
  +    }
  +
  +    /**
  +     * Adds a field to the response header with the given name and value.
  +     */
  +    public void setHeader(String name, String value) {
  +        this.response.setHeader(name,value);
  +    }
  +
  +    /**
  +     * Adds a field to the response header with the given name and
  +     * integer value.
  +     */
  +    public void setIntHeader(String name, int value) {
  +        this.response.setIntHeader(name,value);
  +    }
  +
  +    /**
  +     * Adds a field to the response header with the given name and
  +     * date-valued field.
  +     */
  +    public void setDateHeader(String name, long date) {
  +        this.response.setDateHeader(name,date);
  +    }
  +
  +    /**
  +     * Sets the content type for this response.
  +     */
  +    public void setContentType(String type) {
  +        this.response.setContentType(type);
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +41 -41    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/AbstractSitemapComponent.java
  
  Index: AbstractSitemapComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/AbstractSitemapComponent.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AbstractSitemapComponent.java	2000/07/11 03:10:03	1.1.2.2
  +++ AbstractSitemapComponent.java	2000/07/22 20:41:56	1.1.2.3
  @@ -1,41 +1,41 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/11 03:10:03 $
  - */
  -public abstract class AbstractSitemapComponent implements SitemapComponent {
  -
  -    /** The current <code>Request</code>. */
  -    protected Request request=null;
  -    /** The current <code>Response</code>. */
  -    protected Response response=null;
  -    /** The current <code>Parameters</code>. */
  -    protected Parameters parameters=null;
  -    /** The source URI associated with the request or <b>null</b>. */
  -    protected String source=null;
  -
  -    /**
  -     * Set the <code>Request</code>, <code>Response</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Request req, Response res, String src, Parameters par) {
  -        this.request=req;
  -        this.response=res;
  -        this.source=src;
  -        this.parameters=par;
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  +
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.Request;
  +import org.apache.cocoon.Response;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:56 $
  + */
  +public abstract class AbstractSitemapComponent implements SitemapComponent {
  +
  +    /** The current <code>Request</code>. */
  +    protected Request request=null;
  +    /** The current <code>Response</code>. */
  +    protected Response response=null;
  +    /** The current <code>Parameters</code>. */
  +    protected Parameters parameters=null;
  +    /** The source URI associated with the request or <b>null</b>. */
  +    protected String source=null;
  +
  +    /**
  +     * Set the <code>Request</code>, <code>Response</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Request req, Response res, String src, Parameters par) {
  +        this.request=req;
  +        this.response=res;
  +        this.source=src;
  +        this.parameters=par;
  +    }
  +}
  
  
  
  1.1.4.3   +26 -26    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/LinkResolver.java
  
  Index: LinkResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/LinkResolver.java,v
  retrieving revision 1.1.4.2
  retrieving revision 1.1.4.3
  diff -u -r1.1.4.2 -r1.1.4.3
  --- LinkResolver.java	2000/07/11 03:10:03	1.1.4.2
  +++ LinkResolver.java	2000/07/22 20:41:56	1.1.4.3
  @@ -1,26 +1,26 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  -
  -import org.apache.avalon.Configurable;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.2 $ $Date: 2000/07/11 03:10:03 $
  - */
  -public interface LinkResolver {
  -
  -    /**
  -     * Resolve a link against a source into the target URI space.
  -     */
  -    public String resolve(String source, String partition);
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  +
  +import org.apache.avalon.Configurable;
  +import org.apache.cocoon.Request;
  +import org.apache.cocoon.Response;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.4.3 $ $Date: 2000/07/22 20:41:56 $
  + */
  +public interface LinkResolver {
  +
  +    /**
  +     * Resolve a link against a source into the target URI space.
  +     */
  +    public String resolve(String source, String partition);
  +}
  
  
  
  1.1.2.6   +302 -302  xml-cocoon/src/org/apache/cocoon/sitemap/Attic/LinkTranslator.java
  
  Index: LinkTranslator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/LinkTranslator.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- LinkTranslator.java	2000/07/11 03:10:04	1.1.2.5
  +++ LinkTranslator.java	2000/07/22 20:41:56	1.1.2.6
  @@ -1,302 +1,302 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  -
  -import org.apache.avalon.Configurable;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/11 03:10:04 $
  - */
  -public class LinkTranslator extends AbstractXMLProducer implements XMLConsumer {
  -
  -    private LinkResolver local=null;
  -    private LinkResolver global=null;
  -    private String partition=null;
  -    private String source=null;
  -    private String basepath=null;
  -    private String rootpath="";
  -
  -    public LinkTranslator(LinkResolver local, LinkResolver global,
  -                          String partition, String source) {
  -        super();
  -        this.local=local;
  -        this.global=global;
  -        this.partition=partition;
  -        this.source=source;
  -        if (local==null) throw new IllegalArgumentException("loc");
  -        if (global==null) throw new IllegalArgumentException("global");
  -        if (partition==null) throw new IllegalArgumentException("partition");
  -        if (source==null) throw new IllegalArgumentException("loc");
  -        
  -        int pos=-1;
  -        for (int x=0; x<source.length(); x++) {
  -            if (source.charAt(x)=='/') {
  -                pos=x;
  -                this.rootpath=this.rootpath+"../";
  -            }
  -        }
  -        if (pos>0) this.basepath=source.substring(0,pos+1);
  -        else this.basepath="";
  -    }
  -    
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     *
  -     * @param locator An object that can return the location of any SAX
  -     *                document event.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.setDocumentLocator(locator);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startDocument();
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endDocument();
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     *
  -     * @param prefix The Namespace prefix being declared.
  -     * @param uri The Namespace URI the prefix is mapped to.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startPrefixMapping(prefix,uri);
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     *
  -     * @param prefix The prefix that was being mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endPrefixMapping(prefix);
  -    }
  -
  -    /**
  -     * 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.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes a)
  -    throws SAXException {
  -        if (super.contentHandler==null) return;
  -        String tran=null;
  -        String part=null;
  -        AttributesImpl a2=new AttributesImpl();
  -        for (int x=0; x< a.getLength(); x++) {
  -            String auri=a.getURI(x);
  -            if (auri.equals("http://xml.apache.org/cocoon/links")) {
  -                if (a.getLocalName(x).equals("partition")) part=a.getValue(x);
  -                if (a.getLocalName(x).equals("translate")) tran=a.getValue(x);
  -            } else {
  -                a2.addAttribute(a.getURI(x),a.getLocalName(x),a.getQName(x),
  -                               a.getType(x),a.getValue(x));
  -            }
  -        }
  -        if (tran!=null) {
  -            int x=a2.getIndex(tran);
  -            if (x>-1) {
  -                if (part==null) part=this.partition;
  -                String name=this.basepath+a2.getValue(x);
  -
  -                String resolved=this.local.resolve(name,part);
  -                if (resolved==null) resolved=this.global.resolve(name,part);
  -                
  -                if (resolved!=null) a2.setValue(x,rootpath+resolved);
  -            }
  -        }
  -        super.contentHandler.startElement(uri,loc,raw,a2);
  -    }
  -
  -
  -    /**
  -     * 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.
  -     */
  -    public void endElement(String uri, String loc, String raw)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endElement(uri,loc,raw);
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     *
  -     * @param ch 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.
  -     */
  -    public void characters(char ch[], int start, int len)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.characters(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     *
  -     * @param ch 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.
  -     */
  -    public void ignorableWhitespace(char ch[], int start, int len)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.ignorableWhitespace(ch,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.
  -     */
  -    public void processingInstruction(String target, String data)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.processingInstruction(target,data);
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     *
  -     * @param name The name of the skipped entity.  If it is a  parameter
  -     *             entity, the name will begin with '%'.
  -     */
  -    public void skippedEntity(String name)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.skippedEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     *
  -     * @param name The document type name.
  -     * @param publicId The declared public identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     * @param systemId The declared system identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     */
  -    public void startDTD(String name, String publicId, String systemId)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startDTD(name,publicId,systemId);
  -    }
  -
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD()
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endDTD();
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     *
  -     * @param name The name of the entity. If it is a parameter entity, the
  -     *             name will begin with '%'.
  -     */
  -    public void startEntity(String name)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startEntity(name);
  -    }
  -
  -    /**
  -     * Report the end of an entity.
  -     *
  -     * @param name The name of the entity that is ending.
  -     */
  -    public void endEntity(String name)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA()
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startCDATA();
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA()
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endCDATA();
  -    }
  -
  -
  -    /**
  -     * 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.
  -     */
  -    public void comment(char ch[], int start, int len)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.comment(ch,start,len);
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  +
  +import org.apache.avalon.Configurable;
  +import org.apache.cocoon.Request;
  +import org.apache.cocoon.Response;
  +import org.apache.cocoon.xml.AbstractXMLProducer;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/22 20:41:56 $
  + */
  +public class LinkTranslator extends AbstractXMLProducer implements XMLConsumer {
  +
  +    private LinkResolver local=null;
  +    private LinkResolver global=null;
  +    private String partition=null;
  +    private String source=null;
  +    private String basepath=null;
  +    private String rootpath="";
  +
  +    public LinkTranslator(LinkResolver local, LinkResolver global,
  +                          String partition, String source) {
  +        super();
  +        this.local=local;
  +        this.global=global;
  +        this.partition=partition;
  +        this.source=source;
  +        if (local==null) throw new IllegalArgumentException("loc");
  +        if (global==null) throw new IllegalArgumentException("global");
  +        if (partition==null) throw new IllegalArgumentException("partition");
  +        if (source==null) throw new IllegalArgumentException("loc");
  +        
  +        int pos=-1;
  +        for (int x=0; x<source.length(); x++) {
  +            if (source.charAt(x)=='/') {
  +                pos=x;
  +                this.rootpath=this.rootpath+"../";
  +            }
  +        }
  +        if (pos>0) this.basepath=source.substring(0,pos+1);
  +        else this.basepath="";
  +    }
  +    
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     *
  +     * @param locator An object that can return the location of any SAX
  +     *                document event.
  +     */
  +    public void setDocumentLocator(Locator locator) {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.setDocumentLocator(locator);
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startDocument();
  +    }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument()
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.endDocument();
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     *
  +     * @param prefix The Namespace prefix being declared.
  +     * @param uri The Namespace URI the prefix is mapped to.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startPrefixMapping(prefix,uri);
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     *
  +     * @param prefix The prefix that was being mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.endPrefixMapping(prefix);
  +    }
  +
  +    /**
  +     * 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.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes a)
  +    throws SAXException {
  +        if (super.contentHandler==null) return;
  +        String tran=null;
  +        String part=null;
  +        AttributesImpl a2=new AttributesImpl();
  +        for (int x=0; x< a.getLength(); x++) {
  +            String auri=a.getURI(x);
  +            if (auri.equals("http://xml.apache.org/cocoon/links")) {
  +                if (a.getLocalName(x).equals("partition")) part=a.getValue(x);
  +                if (a.getLocalName(x).equals("translate")) tran=a.getValue(x);
  +            } else {
  +                a2.addAttribute(a.getURI(x),a.getLocalName(x),a.getQName(x),
  +                               a.getType(x),a.getValue(x));
  +            }
  +        }
  +        if (tran!=null) {
  +            int x=a2.getIndex(tran);
  +            if (x>-1) {
  +                if (part==null) part=this.partition;
  +                String name=this.basepath+a2.getValue(x);
  +
  +                String resolved=this.local.resolve(name,part);
  +                if (resolved==null) resolved=this.global.resolve(name,part);
  +                
  +                if (resolved!=null) a2.setValue(x,rootpath+resolved);
  +            }
  +        }
  +        super.contentHandler.startElement(uri,loc,raw,a2);
  +    }
  +
  +
  +    /**
  +     * 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.
  +     */
  +    public void endElement(String uri, String loc, String raw)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.endElement(uri,loc,raw);
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     *
  +     * @param ch 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.
  +     */
  +    public void characters(char ch[], int start, int len)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.characters(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     *
  +     * @param ch 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.
  +     */
  +    public void ignorableWhitespace(char ch[], int start, int len)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.ignorableWhitespace(ch,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.
  +     */
  +    public void processingInstruction(String target, String data)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.processingInstruction(target,data);
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     *
  +     * @param name The name of the skipped entity.  If it is a  parameter
  +     *             entity, the name will begin with '%'.
  +     */
  +    public void skippedEntity(String name)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.skippedEntity(name);
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any.
  +     *
  +     * @param name The document type name.
  +     * @param publicId The declared public identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     * @param systemId The declared system identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     */
  +    public void startDTD(String name, String publicId, String systemId)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startDTD(name,publicId,systemId);
  +    }
  +
  +    /**
  +     * Report the end of DTD declarations.
  +     */
  +    public void endDTD()
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endDTD();
  +    }
  +
  +    /**
  +     * Report the beginning of an entity.
  +     *
  +     * @param name The name of the entity. If it is a parameter entity, the
  +     *             name will begin with '%'.
  +     */
  +    public void startEntity(String name)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startEntity(name);
  +    }
  +
  +    /**
  +     * Report the end of an entity.
  +     *
  +     * @param name The name of the entity that is ending.
  +     */
  +    public void endEntity(String name)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endEntity(name);
  +    }
  +
  +    /**
  +     * Report the start of a CDATA section.
  +     */
  +    public void startCDATA()
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startCDATA();
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section.
  +     */
  +    public void endCDATA()
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endCDATA();
  +    }
  +
  +
  +    /**
  +     * 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.
  +     */
  +    public void comment(char ch[], int start, int len)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.comment(ch,start,len);
  +    }
  +}
  
  
  
  1.1.2.4   +26 -26    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Matcher.java
  
  Index: Matcher.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Matcher.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- Matcher.java	2000/07/11 03:10:04	1.1.2.3
  +++ Matcher.java	2000/07/22 20:41:56	1.1.2.4
  @@ -1,26 +1,26 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  -
  -import org.apache.avalon.Configurable;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/11 03:10:04 $
  - */
  -public interface Matcher extends Configurable {
  -
  -    /**
  -     *
  -     */
  -    public boolean match(Request req, Response res);
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  +
  +import org.apache.avalon.Configurable;
  +import org.apache.cocoon.Request;
  +import org.apache.cocoon.Response;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:56 $
  + */
  +public interface Matcher extends Configurable {
  +
  +    /**
  +     *
  +     */
  +    public boolean match(Request req, Response res);
  +}
  
  
  
  1.1.2.6   +109 -92   xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ResourcePipeline.java
  
  Index: ResourcePipeline.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ResourcePipeline.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- ResourcePipeline.java	2000/07/17 21:06:14	1.1.2.5
  +++ ResourcePipeline.java	2000/07/22 20:41:57	1.1.2.6
  @@ -1,92 +1,109 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  -
  -import java.util.Vector;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -
  -//import org.apache.avalon.ConfigurationException;
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -import org.apache.cocoon.generation.Generator;
  -import org.apache.cocoon.transformation.Transformer;
  -import org.apache.cocoon.serialization.Serializer;
  -import org.apache.cocoon.xml.XMLProducer;
  -
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/17 21:06:14 $
  - */
  -public class ResourcePipeline {
  -    private Generator generator = null;
  -    private Parameters generatorParam = null;
  -    private String generatorSource = null;
  -    private Vector transformers = new Vector();
  -    private Vector transformerParams = new Vector();
  -    private Vector transformerSources = new Vector();
  -    private Serializer serializer = null;
  -    private Parameters serializerParam = null;
  -    private String serializerSource = null;
  -
  -    public ResourcePipeline () {
  -    }
  -
  -    public void setGenerator (Generator generator, String source, Parameters param) {
  -        this.generator = generator;
  -        this.generatorSource = source;
  -        this.generatorParam = param;
  -    }
  -
  -    public void setSerializer (Serializer serializer, String source, Parameters param) {
  -        this.serializer = serializer;
  -        this.serializerSource = source;
  -        this.serializerParam = param;
  -    }
  -
  -    public void addTransformer (Transformer transformer, String source, Parameters param) {
  -        this.transformers.add (transformer);
  -        this.transformerSources.add (source);
  -        this.transformerParams.add (param);
  -    }
  -
  -    public boolean process (Request req, Response res, OutputStream out)
  -                            throws ProcessingException, IOException, SAXException {
  -        if (generator == null) {
  -            throw new ProcessingException ("Generator not specified");
  -        }
  -
  -        if (serializer == null) {
  -            throw new ProcessingException ("Serializer not specified");
  -        }
  -
  -        generator.setup (req, res, generatorSource, generatorParam);
  -        Transformer transformer = null;
  -        XMLProducer producer = generator;
  -        int i = transformers.size();
  -
  -        for (int j=0; j < i; j++) {
  -            transformer = (Transformer) transformers.elementAt (j);
  -            transformer.setup (req, res, (String)transformerSources.elementAt (j),
  -                           (Parameters)transformerParams.elementAt (j));
  -            producer.setConsumer (transformer);
  -            producer = transformer;
  -        }
  -
  -        serializer.setup (req, res, serializerSource, generatorParam);
  -        serializer.setOutputStream (out);
  -        producer.setConsumer (serializer);
  -        generator.generate();
  -        return true;
  -    }
  -} 
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  +
  +import java.util.Vector;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +
  +//import org.apache.avalon.ConfigurationException;
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.generation.Generator;
  +import org.apache.cocoon.reading.Reader;
  +import org.apache.cocoon.transformation.Transformer;
  +import org.apache.cocoon.serialization.Serializer;
  +import org.apache.cocoon.xml.XMLProducer;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/22 20:41:57 $
  + */
  +public class ResourcePipeline {
  +    private Generator generator = null;
  +    private Parameters generatorParam = null;
  +    private String generatorSource = null;
  +    private Reader reader = null;
  +    private Parameters readerParam = null;
  +    private String readerSource = null;
  +    private Vector transformers = new Vector();
  +    private Vector transformerParams = new Vector();
  +    private Vector transformerSources = new Vector();
  +    private Serializer serializer = null;
  +    private Parameters serializerParam = null;
  +    private String serializerSource = null;
  +    private boolean isReader = false;
  +
  +    public ResourcePipeline () {
  +    }
  +
  +    public void setGenerator (Generator generator, String source, Parameters param) {
  +        this.generator = generator;
  +        this.generatorSource = source;
  +        this.generatorParam = param;
  +    }
  +
  +    public void setReader (Reader reader, String source, Parameters param) {
  +        this.reader = reader;
  +        this.readerSource = source;
  +        this.readerParam = param;
  +        this.isReader = true;
  +    }
  +
  +    public void setSerializer (Serializer serializer, String source, Parameters param) {
  +        this.serializer = serializer;
  +        this.serializerSource = source;
  +        this.serializerParam = param;
  +    }
  +
  +    public void addTransformer (Transformer transformer, String source, Parameters param) {
  +        this.transformers.add (transformer);
  +        this.transformerSources.add (source);
  +        this.transformerParams.add (param);
  +    }
  +
  +    public boolean process (Environment environment, OutputStream out)
  +                            throws ProcessingException, IOException, SAXException {
  +        if (isReader) {
  +            reader.setup (environment, serializerSource, generatorParam);
  +            reader.setOutputStream (out);
  +            reader.generate();
  +        } else {
  +            if (generator == null) {
  +                throw new ProcessingException ("Generator not specified");
  +            }
  +
  +            if (serializer == null) {
  +                throw new ProcessingException ("Serializer not specified");
  +            }
  +
  +            generator.setup (environment, generatorSource, generatorParam);
  +            Transformer transformer = null;
  +            XMLProducer producer = generator;
  +            int i = transformers.size();
  +
  +            for (int j=0; j < i; j++) {
  +                transformer = (Transformer) transformers.elementAt (j);
  +                transformer.setup (environment, (String)transformerSources.elementAt (j),
  +                               (Parameters)transformerParams.elementAt (j));
  +                producer.setConsumer (transformer);
  +                producer = transformer;
  +            }
  +
  +            serializer.setup (environment, serializerSource, generatorParam);
  +            serializer.setOutputStream (out);
  +            producer.setConsumer (serializer);
  +            generator.generate();
  +        }
  +        return true;
  +    }
  +} 
  
  
  
  1.1.4.8   +27 -120   xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Sitemap.java
  
  Index: Sitemap.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Sitemap.java,v
  retrieving revision 1.1.4.7
  retrieving revision 1.1.4.8
  diff -u -r1.1.4.7 -r1.1.4.8
  --- Sitemap.java	2000/07/20 21:57:14	1.1.4.7
  +++ Sitemap.java	2000/07/22 20:41:57	1.1.4.8
  @@ -1,120 +1,27 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  -
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import org.apache.avalon.Component;
  -import org.apache.avalon.ComponentManager;
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.Configurable;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  -import org.apache.cocoon.Processor;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -import org.apache.cocoon.environment.Environment;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.7 $ $Date: 2000/07/20 21:57:14 $
  - */
  -public class Sitemap
  -implements Composer, Configurable, Processor, LinkResolver {
  -    
  -    /** The default partition */
  -    private SitemapPartition partition=null;
  -    /** The partitions table */
  -    private Hashtable partitions=new Hashtable();
  -
  -    /** The component manager instance */
  -    private ComponentManager manager=null;
  -
  -    /**
  -     * Create a new <code>Sitemap</code> instance.
  -     */
  -    public Sitemap() {
  -        super();
  -    }
  -
  -    /**
  -     * Set the current <code>ComponentManager</code> instance used by this
  -     * <code>Composer</code>.
  -     */
  -    public void setComponentManager(ComponentManager manager) {
  -        this.manager=manager;
  -    }
  -
  -    /**
  -     * Pass a <code>Configuration</code> instance to this
  -     * <code>Configurable</code> class.
  -     */
  -    public void setConfiguration(Configuration conf)
  -    throws ConfigurationException {
  -        if (!conf.getName().equals("sitemap"))
  -            throw new ConfigurationException("Invalid sitemap configuration",
  -                                             conf);
  -        // Set components
  -        Enumeration e=conf.getConfigurations("partition");
  -        while (e.hasMoreElements()) {
  -            Configuration co=(Configuration)e.nextElement();
  -            SitemapPartition p=new SitemapPartition(this);
  -            p.setComponentManager(this.manager);
  -            p.setConfiguration(co);
  -            
  -            String name=co.getAttribute("name","default");
  -            if ("default".equals(name)) {
  -                if (this.partition==null) this.partition=p;
  -                else throw new ConfigurationException("Dupliacate definition "+
  -                                               "of the default partition",co);
  -            } else {
  -                if (this.partitions.put(name,p)!=null)
  -                    throw new ConfigurationException("Duplicate definition "+
  -                                    "of the partition named \""+name+"\"",co);
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Process the given <code>Request</code> producing the output to the
  -     * specified <code>Response</code> and <code>OutputStream</code>.
  -     */
  -    public boolean process(Environment environment, OutputStream out) {return true;}
  -    public boolean process(Request req, Response res, OutputStream out)
  -    throws SAXException, IOException, ProcessingException {
  -        if(this.partition!=null)
  -            if(this.partition.process(req,res,out)) return(true);
  -
  -        Enumeration e=partitions.elements();
  -        while (e.hasMoreElements()) {
  -            SitemapPartition p=(SitemapPartition)e.nextElement();
  -            if (p.process(req,res,out)) return(true);
  -        }
  -        return(false);
  -    }
  -
  -    public String resolve(String source, String part) {
  -        if (part==null) return(null);
  -        if ("default".equals(part)) return(this.partition.resolve(source,part));
  -
  -        SitemapPartition p=(SitemapPartition)this.partitions.get(part);
  -        if (p!=null) return(p.resolve(source,part));
  -
  -        return(null);
  -    }
  -
  -    public boolean hasChanged () {
  -        return false;
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  +
  +import org.apache.avalon.Composer; 
  +import org.apache.avalon.Modifiable; 
  +import org.apache.avalon.Configurable; 
  +import org.apache.avalon.Configuration; 
  +import org.apache.cocoon.Processor;
  +
  +/**
  + * Base interface for generated <code>Sitemap</code> classes
  + *
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.4.8 $ $Date: 2000/07/22 20:41:57 $
  + */
  +public interface Sitemap
  +         extends Composer, Configurable, Processor, Modifiable { 
  +
  +    /** set the base path of a sitemap */
  +    public void setBasePath (String basePath);
  +} 
  
  
  
  1.1.2.5   +31 -32    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapComponent.java
  
  Index: SitemapComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapComponent.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- SitemapComponent.java	2000/07/11 03:10:04	1.1.2.4
  +++ SitemapComponent.java	2000/07/22 20:41:57	1.1.2.5
  @@ -1,32 +1,31 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  -
  -import java.io.IOException;
  -import org.apache.avalon.Component;
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -import org.apache.cocoon.ProcessingException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/11 03:10:04 $
  - */
  -public interface SitemapComponent extends Component {
  -
  -    /**
  -     * Set the <code>Request</code>, <code>Response</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Request req, Response res, String src, Parameters par)
  -    throws ProcessingException, SAXException, IOException;
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  +
  +import java.io.IOException;
  +import org.apache.avalon.Component;
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.ProcessingException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:57 $
  + */
  +public interface SitemapComponent extends Component {
  +
  +    /**
  +     * Set the <code>Request</code>, <code>Response</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par)
  +    throws ProcessingException, SAXException, IOException;
  +}
  
  
  
  1.1.2.2   +185 -108  xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapHandler.java
  
  Index: SitemapHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapHandler.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SitemapHandler.java	2000/07/20 21:57:16	1.1.2.1
  +++ SitemapHandler.java	2000/07/22 20:41:57	1.1.2.2
  @@ -1,111 +1,188 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  -
  -import java.io.File;
  -import java.io.FileNotFoundException;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -
  -import org.xml.sax.SAXException;
  -
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.environment.Environment;
  -
  -/**
  - * Handles the manageing and stating of one <code>Sitemap</code>
  - *
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/20 21:57:16 $
  - */
  -public class SitemapHandler implements Runnable {
  -
  -    /** the source of this sitemap */
  -    private File source = null;
  -    private long changeDate = -1L;
  -
  -    /** the last error */
  -    private Exception exception = null;
  -
  -    /** the managed sitemap */
  -    private SitemapProcessor sitemap = null;
  -
  -    /** the regenerating thread */
  -    private Thread regeneration = null;
  -
  -    protected SitemapHandler (String source) throws FileNotFoundException {
  -        File f = null;
  -        String s = null;
  -        if (source.charAt(source.length()-1) == '/') {
  -            s = source+"sitemap.xmap";
  -            f = new File (s);
  -        } else {
  -            f = new File (source);
  -            if (!f.isFile()) {
  -                s = source+File.separatorChar+"sitemap.xmap";
  -                f = new File (s);
  -            }
  -            if (!f.canRead()) {
  -                throw new FileNotFoundException ("file "+s+" not found or cannot be opened for reading");
  -            }
  -        }
  -        this.source = f;
  -        changeDate = f.lastModified();
  -    }
  -
  -    protected void throwError () throws Exception {
  -        if (exception != null) {
  -            throw exception;
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  +
  +import java.io.File;
  +import java.io.FileNotFoundException;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.components.language.generator.ProgramGenerator;
  +import org.apache.cocoon.environment.Environment;
  +
  +import org.apache.avalon.Configurable;
  +import org.apache.avalon.Configuration;
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.ComponentManager;
  +
  +/**
  + * Handles the manageing and stating of one <code>Sitemap</code>
  + *
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:57 $
  + */
  +public class SitemapHandler implements Runnable, Configurable, Composer {
  +
  +    /** the configuration */
  +    private Configuration conf = null;
  +
  +    /** the component manager */
  +    private ComponentManager manager = null;
  +
  +    /** the source of this sitemap */
  +    private File source = null;
  +    private long changeDate = -1L;
  +
  +    /** the last error */
  +    private Exception exception = null;
  +
  +    /** the managed sitemap */
  +    private Sitemap sitemap = null;
  + 
  +    /** the regenerating thread */ 
  +    private Thread regeneration = null; 
  + 
  +    /** the sitemaps base path */ 
  +    private String basePath = null; 
  +
  +    public void setComponentManager (ComponentManager manager) {
  +        this.manager = manager;
  +    }
  +
  +    public void setConfiguration (Configuration conf) {
  +        this.conf = conf;
  +    }
  +
  +    protected SitemapHandler (String source) throws FileNotFoundException {
  +        System.out.println("SitemapHandler: Instantiating sitemap \""+source+"\"");
  +        File f = null;
  +        String s = null;
  +        if (source.charAt(source.length()-1) == '/') {
  +            s = source+"sitemap.xmap";
  +            f = new File (s);
  +        } else {
  +            f = new File (source);
  +            if (!f.isFile()) {
  +                s = source+File.separatorChar+"sitemap.xmap";
  +                f = new File (s);
  +            }
  +            if (!f.canRead()) {
  +                throw new FileNotFoundException ("file "+s+" not found or cannot be opened for reading");
  +            }
  +        }
  +        this.source = f;
  +        changeDate = f.lastModified();
  +        System.out.println("SitemapHandler: Instantiatet sitemap \""+f.getPath()+"\"");
  +    }
  +
  +    protected void throwError () 
  +    throws ProcessingException, SAXException, IOException, InterruptedException {
  +        Exception e = exception;
  +        exception = null;
  +        if (e instanceof ProcessingException) {
  +            throw (ProcessingException) exception;
  +        } else if (e instanceof SAXException) {
  +            throw (SAXException) exception;
  +        } else if (e instanceof IOException) {
  +            throw (IOException) exception;
  +        } else if (e instanceof InterruptedException) {
  +            throw (InterruptedException) exception;
  +        } else if (e != null) {
  +            throw new ProcessingException ("Unknown Exception raised: "
  +                                         + exception.toString());
  +        }
  +    }
  +
  +    protected boolean available () {
  +        return (sitemap != null);
  +    }
  +
  +    protected boolean hasChanged () {
  +        if (sitemap != null) {
  +            return sitemap.modifiedSince(this.changeDate);
  +        }
  +        return true;
  +    }
  +
  +    protected boolean isRegenerating () {
  +        if (regeneration == null)
  +            return false;
  +        return regeneration.isAlive();
  +    }
  +
  +    protected void regenerateAsynchroniously () {
  +        if (!isRegenerating()) {
  +            regeneration = new Thread (this);
  +            regeneration.start();
  +        }
  +    }
  +
  +    protected void regenerate () 
  +    throws ProcessingException, SAXException, IOException, InterruptedException { 
  +        if (!isRegenerating()) {
  +            regeneration = new Thread (this);
  +            regeneration.start();
  +            regeneration.join();
  +            throwError();
  +        }
  +    }
  +
  +    public boolean process (Environment environment, OutputStream out) 
  +    throws ProcessingException, SAXException, IOException, InterruptedException {
  +        this.throwError();
  +        return sitemap.process (environment, out);
  +    }
  +
  +    /** Generate the Sitemap class */
  +    public void run() {
  +/*
  +    private void generateSitemap (String sitemapName) 
  +            throws java.net.MalformedURLException, IOException, 
  +                   org.apache.cocoon.ProcessingException {
  +*/
  +
  +        InputSource inputSource = new InputSource (source.getPath());
  +        String systemId = inputSource.getSystemId();
  +        System.out.println ("C2 generateSitemap: "+systemId);
  +
  +        File file = new File(systemId);
  +
  +        String markupLanguage = "sitemap";
  +        String programmingLanguage = "java";
  +
  +        ProgramGenerator programGenerator = null;
  +
  +        System.out.println ("C2 generateSitemap: obtaining programGenerator");
  +        programGenerator = (ProgramGenerator) this.manager.getComponent("program-generator");
  +        System.out.println ("C2 generateSitemap: programGenerator obtained");
  +
  +        System.out.println ("C2 generateSitemap: obtaining generator");
  +        try {
  +            sitemap = (Sitemap) programGenerator.load(file, markupLanguage, programmingLanguage);
  +            System.out.println ("C2 generateSitemap: generator obtained");
  +            if (sitemap instanceof Composer) sitemap.setComponentManager(this.manager);
  +            if (sitemap instanceof Configurable) sitemap.setConfiguration(this.conf);
  +            sitemap.setBasePath (basePath);
  +            System.out.println ("C2 generateSitemap: generator called");
  +        } catch (Exception e) {
  +            synchronized (this.exception) {
  +                this.exception = e;
  +            }
  +        } finally {
  +            regeneration = null;
           }
  -    }
  -
  -    protected boolean available () {
  -        return (sitemap != null);
  -    }
  -
  -    protected boolean hasChanged () {
  -        if (sitemap != null) {
  -            return sitemap.modifiedSince(this.changeDate);
  -        }
  -        return true;
  -    }
  -/*
  -    protected boolean modifiedSince () {
  -        if (sitemap != null) {
  -            return sitemap.modifiedSince(this.changeDate);
  -        }
  -        return true;
  -    }
  -*/
  -    protected boolean isRegenerating () {
  -        return regeneration.isAlive();
  -    }
  -
  -    protected void regenerateAsynchroniously () {
  -        if (!isRegenerating()) {
  -            regeneration = new Thread (this);
  -            regeneration.start();
  -        }
  -    }
  -
  -    protected void regenerate () throws InterruptedException {
  -        if (!isRegenerating()) {
  -            regeneration = new Thread (this);
  -            regeneration.start();
  -            regeneration.join();
  -        }
  -    }
  -
  -    public boolean process (Environment environment, OutputStream out) 
  -    throws ProcessingException, SAXException, IOException {
  -        return sitemap.process (environment, out);
  -    }
  +    }
   
  -    public void run() {
  +    public void setBasePath (String basePath) {
  +        this.basePath = basePath;
       }
  -} 
  +} 
  
  
  
  1.1.2.2   +89 -58    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapManager.java
  
  Index: SitemapManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapManager.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SitemapManager.java	2000/07/20 21:57:17	1.1.2.1
  +++ SitemapManager.java	2000/07/22 20:41:57	1.1.2.2
  @@ -1,58 +1,89 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  -
  -import java.io.OutputStream;
  -import java.util.Hashtable;
  -
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.sitemap.SitemapHandler;
  -
  -/**
  - * This class manages all sub <code>Sitemap</code>s of a <code>Sitemap</code>
  - * Invokation of sub sitemaps will be done by this instance as well 
  - * checking regeneration of the sub <code>Sitemap</code>
  - *
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/20 21:57:17 $
  - */
  -public class SitemapManager {
  -
  -    /** The vectors of sub sitemaps */
  -    private Hashtable sitemaps = new Hashtable();
  -
  -    protected SitemapManager () {
  -    }
  -
  -    public boolean invoke (Environment environment, String uri_prefix, 
  -                           String source, boolean check_reload, OutputStream out) 
  -    throws Exception{
  -        SitemapHandler sm = (SitemapHandler) sitemaps.get (source);
  -        if (sm != null) {
  -            sm.throwError();
  -            if (sm.available()) {
  -                if (check_reload 
  -                 && sm.hasChanged()
  -                 && !sm.isRegenerating()) {
  -                    sm.regenerateAsynchroniously();
  -                }
  -                environment.addUriPrefix (uri_prefix);
  -                return sm.process (environment, out);
  -            } else {
  -                sm.regenerate();
  -            }
  -            environment.addUriPrefix (uri_prefix);
  -            return sm.process (environment, out);
  -        } else {
  -            sm = new SitemapHandler(source);
  -            sitemaps.put(source, sm);
  -            environment.addUriPrefix (uri_prefix);
  -            return sm.process (environment, out);
  -        }
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap;
  +
  +import java.io.FileNotFoundException;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.util.Hashtable;
  +
  +import org.apache.avalon.ComponentManager;
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.Configurable;
  +import org.apache.avalon.Configuration;
  +
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.sitemap.SitemapHandler;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + * This class manages all sub <code>Sitemap</code>s of a <code>Sitemap</code>
  + * Invokation of sub sitemaps will be done by this instance as well 
  + * checking regeneration of the sub <code>Sitemap</code>
  + *
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:57 $
  + */
  +public class SitemapManager implements Configurable, Composer {
  +
  +    /** The vectors of sub sitemaps */
  +    private Hashtable sitemaps = new Hashtable();
  +
  +    /** The configuration */
  +    private Configuration conf = null;
  +
  +    /** The component manager */
  +    private ComponentManager manager = null;
  +
  +    public SitemapManager () {
  +    }
  +
  +    public void setConfiguration (Configuration conf) {
  +        this.conf = conf;
  +    }
  +
  +    public void setComponentManager (ComponentManager manager) {
  +        this.manager = manager;
  +    }
  +
  +    public boolean invoke (Environment environment, String uri_prefix, 
  +                           String source, boolean check_reload, OutputStream out) 
  +    throws SAXException, ProcessingException, IOException, InterruptedException,
  +           FileNotFoundException {
  +        SitemapHandler sitemapHandler = (SitemapHandler) sitemaps.get (source);
  +        if (sitemapHandler != null) {
  +            sitemapHandler.throwError();
  +            if (sitemapHandler.available()) {
  +                if (check_reload 
  +                 && sitemapHandler.hasChanged()
  +                 && !sitemapHandler.isRegenerating()) {
  +                    sitemapHandler.regenerateAsynchroniously();
  +                }
  +                environment.addUriPrefix (uri_prefix);
  +                return sitemapHandler.process (environment, out);
  +            } else {
  +                sitemapHandler.regenerate();
  +            }
  +            environment.addUriPrefix (uri_prefix);
  +            return sitemapHandler.process (environment, out);
  +        } else {
  +            String basePath = source.substring(0,source.lastIndexOf('/')+1);
  +            System.out.println ("BasePath is \""+basePath+"\"");
  +            sitemapHandler = new SitemapHandler(source);
  +            if (sitemapHandler instanceof Composer) sitemapHandler.setComponentManager (this.manager);
  +            if (sitemapHandler instanceof Configurable) sitemapHandler.setConfiguration (this.conf); 
  +            sitemapHandler.setBasePath (basePath); 
  +            sitemaps.put(source, sitemapHandler);
  +            sitemapHandler.regenerate(); 
  +            environment.addUriPrefix (uri_prefix);
  +            return sitemapHandler.process (environment, out);
  +        }
  +    }
  +}
  
  
  
  1.1.2.6   +44 -44    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTMatcherFactoryLoader.java
  
  Index: XSLTMatcherFactoryLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTMatcherFactoryLoader.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- XSLTMatcherFactoryLoader.java	2000/07/20 21:57:19	1.1.2.5
  +++ XSLTMatcherFactoryLoader.java	2000/07/22 20:41:58	1.1.2.6
  @@ -1,44 +1,44 @@
  -/***************************************************************************** 
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap; 
  -
  -import java.util.Hashtable;
  -
  -import org.apache.cocoon.matching.MatcherFactory;
  -
  -import org.w3c.dom.DocumentFragment;
  -  
  -/** 
  - * This class is used as a XSLT extension class. It is used by the sitemap 
  - * generation stylesheet to load a <code>MatcherFactory</code> to get the 
  - * generated source code.
  - * 
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/20 21:57:19 $ 
  - */ 
  -
  -public class XSLTMatcherFactoryLoader {
  -
  -    Hashtable obj = new Hashtable ();
  -
  -    public String getSource (String level, String matcherFactoryClassname, String pattern, 
  -        String prefix, DocumentFragment conf) 
  -    throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
  -        MatcherFactory factory = (MatcherFactory) obj.get(matcherFactoryClassname);
  -        if (factory == null) {
  -            Class cl = this.getClass().getClassLoader().loadClass(matcherFactoryClassname);
  -            factory = (MatcherFactory) cl.newInstance();
  -            obj.put (matcherFactoryClassname, factory);
  -        }
  -        if ("class".equals(level)) {
  -            return factory.generateClassLevel (pattern, prefix, conf);
  -        } else {
  -            return factory.generateMethodLevel (pattern, prefix, conf);
  -        } 
  -    }
  -}
  +/***************************************************************************** 
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap; 
  +
  +import java.util.Hashtable;
  +
  +import org.apache.cocoon.matching.MatcherFactory;
  +
  +import org.w3c.dom.DocumentFragment;
  +  
  +/** 
  + * This class is used as a XSLT extension class. It is used by the sitemap 
  + * generation stylesheet to load a <code>MatcherFactory</code> to get the 
  + * generated source code.
  + * 
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/22 20:41:58 $ 
  + */ 
  +
  +public class XSLTMatcherFactoryLoader {
  +
  +    Hashtable obj = new Hashtable ();
  +
  +    public String getSource (String level, String matcherFactoryClassname, String pattern, 
  +        String prefix, DocumentFragment conf) 
  +    throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
  +        MatcherFactory factory = (MatcherFactory) obj.get(matcherFactoryClassname);
  +        if (factory == null) {
  +            Class cl = this.getClass().getClassLoader().loadClass(matcherFactoryClassname);
  +            factory = (MatcherFactory) cl.newInstance();
  +            obj.put (matcherFactoryClassname, factory);
  +        }
  +        if ("class".equals(level)) {
  +            return factory.generateClassLevel (pattern, prefix, conf);
  +        } else {
  +            return factory.generateMethodLevel (pattern, prefix, conf);
  +        } 
  +    }
  +}
  
  
  
  1.1.2.5   +44 -44    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTSelectorFactoryLoader.java
  
  Index: XSLTSelectorFactoryLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTSelectorFactoryLoader.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- XSLTSelectorFactoryLoader.java	2000/07/20 21:57:19	1.1.2.4
  +++ XSLTSelectorFactoryLoader.java	2000/07/22 20:41:58	1.1.2.5
  @@ -1,44 +1,44 @@
  -/***************************************************************************** 
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap; 
  -
  -import java.util.Hashtable;
  -
  -import org.apache.cocoon.selection.SelectorFactory;
  -
  -import org.w3c.dom.DocumentFragment;
  -  
  -/** 
  - * This class is used as a XSLT extension class. It is used by the sitemap 
  - * generation stylesheet to load a <code>SelectorFactory</code> to get the 
  - * generated source code.
  - * 
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/20 21:57:19 $ 
  - */ 
  -
  -public class XSLTSelectorFactoryLoader {
  -
  -    Hashtable obj = new Hashtable ();
  -
  -    public String getSource (String level, String selectorFactoryClassname, String test, 
  -            String prefix, DocumentFragment conf) 
  -    throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
  -        SelectorFactory factory = (SelectorFactory ) obj.get(selectorFactoryClassname);
  -        if (factory == null) {
  -            Class cl = this.getClass().getClassLoader().loadClass(selectorFactoryClassname);
  -            factory = (SelectorFactory) cl.newInstance();
  -            obj.put (selectorFactoryClassname, factory);
  -        }
  -        if ("class".equals(level)) {
  -            return factory.generateClassLevel (test, prefix, conf);
  -        } else {
  -            return factory.generateMethodLevel (test, prefix, conf);
  -        } 
  -    }
  -}
  +/***************************************************************************** 
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap; 
  +
  +import java.util.Hashtable;
  +
  +import org.apache.cocoon.selection.SelectorFactory;
  +
  +import org.w3c.dom.DocumentFragment;
  +  
  +/** 
  + * This class is used as a XSLT extension class. It is used by the sitemap 
  + * generation stylesheet to load a <code>SelectorFactory</code> to get the 
  + * generated source code.
  + * 
  + * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a> 
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:58 $ 
  + */ 
  +
  +public class XSLTSelectorFactoryLoader {
  +
  +    Hashtable obj = new Hashtable ();
  +
  +    public String getSource (String level, String selectorFactoryClassname, String test, 
  +            String prefix, DocumentFragment conf) 
  +    throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
  +        SelectorFactory factory = (SelectorFactory ) obj.get(selectorFactoryClassname);
  +        if (factory == null) {
  +            Class cl = this.getClass().getClassLoader().loadClass(selectorFactoryClassname);
  +            factory = (SelectorFactory) cl.newInstance();
  +            obj.put (selectorFactoryClassname, factory);
  +        }
  +        if ("class".equals(level)) {
  +            return factory.generateClassLevel (test, prefix, conf);
  +        } else {
  +            return factory.generateMethodLevel (test, prefix, conf);
  +        } 
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +27 -27    xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternException.java
  
  Index: PatternException.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternException.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- PatternException.java	2000/02/27 01:33:10	1.1.2.2
  +++ PatternException.java	2000/07/22 20:41:59	1.1.2.3
  @@ -1,27 +1,27 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap.patterns;
  -
  -/**
  - * This exception is thrown by a <code>URIMatcher</code> or by a
  - * <code>URITranslator</code> when there's something wrong with the matching or
  - * translation patterns.
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 01:33:10 $
  - */
  -public class PatternException extends Exception {
  -
  -    /**
  -     * Construct a new <code>PatternException</code> instance.
  -     */
  -    public PatternException(String message) {
  -        super(message);
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap.patterns;
  +
  +/**
  + * This exception is thrown by a <code>URIMatcher</code> or by a
  + * <code>URITranslator</code> when there's something wrong with the matching or
  + * translation patterns.
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:59 $
  + */
  +public class PatternException extends Exception {
  +
  +    /**
  +     * Construct a new <code>PatternException</code> instance.
  +     */
  +    public PatternException(String message) {
  +        super(message);
  +    }
  +}
  
  
  
  1.1.2.6   +255 -255  xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternMatcher.java
  
  Index: PatternMatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternMatcher.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- PatternMatcher.java	2000/02/27 12:56:20	1.1.2.5
  +++ PatternMatcher.java	2000/07/22 20:41:59	1.1.2.6
  @@ -1,255 +1,255 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap.patterns;
  -
  -/**
  - * This class is an utility class that perform wilcard-patterns matching.
  - * <br>
  - * The pattern is made up with the following wildcards:
  - * <ul>
  - *   <li>The '*' character means that zero or more characters (excluding the
  - *       path separator '/') are to be matched.</li>
  - *   <li>The '**' sequence means that zero or more characters (including the
  - *       path separator '/') are to be matched.</li>
  - *   <li>The '\' character is used as an escape sequence ('\*' is translated in
  - *       '*', it does not represent a matching pattern). If an exact '\'
  - *       character needs to be matched the source string must contain a '\\'
  - *       sequence.</li>
  - * </ul>
  - * 
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/02/27 12:56:20 $
  - */
  -public class PatternMatcher {
  -
  -    /** The int representing '*' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_FILE=-1;
  -    /** The int representing '**' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_PATH=-2;
  -    /** The int value that terminates the pattern <code>int []</code>. */
  -    protected static final int MATCH_END=-3;
  -
  -    /** The <code>int []</code> identifying the pattern to match. */
  -    protected int[] sourcePattern=null;
  -
  -    /**
  -     * Construct a new <code>PatternMatcher</code> instance.
  -     */
  -    public PatternMatcher() {
  -        super();
  -    }
  -
  -    /**
  -     * Construct a new <code>PatternMatcher</code> instance.
  -     */
  -    public PatternMatcher(String pattern)
  -    throws PatternException {
  -        this();
  -        this.setPattern(pattern);
  -    }
  -
  -    /**
  -     * Match the specified <code>String</code> against the configured pattern.
  -     */
  -    public boolean match(String data) {
  -        if (data==null) throw new NullPointerException("Null data");
  -        if (this.sourcePattern==null)
  -            throw new IllegalStateException("Null internals");
  -        return(this.matchPattern(data.toCharArray(),this.sourcePattern));
  -    }
  -
  -    /**
  -     * Set the pattern for matching.
  -     */
  -    public void setPattern(String pattern)
  -    throws PatternException {
  -        if (pattern==null) throw new PatternException("Null pattern");
  -        this.sourcePattern=this.convertPattern(pattern);
  -    }
  -
  -    /**
  -     * Translate the given <code>String</code> into a <code>int []</code>
  -     * representing the pattern matchable by this class.
  -     * <br>
  -     * This function translates a <code>String</code> into an int array
  -     * converting the special '*' and '\' characters.
  -     * <br>
  -     * Here is how the conversion algorithm works:
  -     * <ul>
  -     *   <li>The '*' character is converted to MATCH_FILE, meaning that zero
  -     *        or more characters (excluding the path separator '/') are to
  -     *        be matched.</li>
  -     *   <li>The '**' sequence is converted to MATCH_PATH, meaning that zero
  -     *       or more characters (including the path separator '/') are to
  -     *        be matched.</li>
  -     *   <li>The '\' character is used as an escape sequence ('\*' is
  -     *       translated in '*', not in MATCH_FILE). If an exact '\' character
  -     *       is to be matched the source string must contain a '\\'.
  -     *       sequence.</li>
  -     * </ul>
  -     * When more than two '*' characters, not separated by another character,
  -     * are found their value is considered as '**' (MATCH_PATH).
  -     * <br>
  -     * The array is always terminated by a special value (MATCH_END).
  -     * <br>
  -     * All MATCH* values are less than zero, while normal characters are equal
  -     * or greater.
  -     *
  -     * @parameter data The string to translate.
  -     * @return The encoded string as an int array, terminated by the MATCH_END
  -     *         value (don't consider the array length).
  -     * @exception NullPointerException If data is null.
  -     */
  -    protected int[] convertPattern(String data)
  -    throws NullPointerException {
  -        // Prepare the arrays
  -        int expr[]=new int[data.length()+1];
  -        char buff[]=data.toCharArray();
  -        // Prepare variables for the translation loop
  -        int y=0;
  -        boolean slash=false;
  -        if(buff[0]=='\\') slash=true;
  -        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  -        else expr[y++]=buff[0];
  -        // Main translation loop
  -        for (int x=1; x<buff.length; x++) {
  -            // If the previous char was '\' simply copy this char.
  -            if (slash) {
  -                expr[y++]=buff[x];
  -                slash=false;
  -            // If the previous char was not '\' we have to do a bunch of checks
  -            } else {
  -                int prev=(y-1);
  -                // If this char is '\' declare that and continue
  -                if(buff[x]=='\\') {
  -                    slash=true;
  -                // If this char is '*' check the previous one
  -                } else if(buff[x]=='*') {
  -                    // If the previous character als was '*' match a path
  -                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  -                    else expr[y++]=MATCH_FILE;
  -                } else expr[y++]=buff[x];
  -            }
  -        }
  -        // Declare the end of the array and return it
  -        expr[y]=MATCH_END;
  -        return(expr);
  -    }        
  -
  -    /**
  -     * Matches the specified <code>char []</code> against the given pattern
  -     * formatted as an <code>int []</code>.
  -     * <br>
  -     * This method returns <b>true</b> if the specified <code>char []</code>
  -     * can be matched by the pattern created by <code>convertPattern(...)</code>
  -     * be represented as an <code>int []</code>, <b>false</b> otherwise.
  -     * <br>
  -     * <b>FIXME: This routine doesn't match when the pattern ends with a
  -     *    wildcard. Need to fix together with <code>translatePattern()</code>,
  -     *    in <code>PatternTranslator</code> otherwise it won't work.</b>
  -     * <br>
  -     * <i>Seems ok now</i>
  -     *
  -     * @param buff The <code>char []</code> of the path to be matched.
  -     * @param expr The <code>int []</code> representing the pattern, as
  -     *             returned by <code>convertPattern(...)</code>.
  -     * @exception NullPointerException If a parameter is <b>null</b>.
  -     */
  -    protected boolean matchPattern(char buff[], int expr[])
  -    throws NullPointerException {
  -                
  -        // The previous and current position of the expression character
  -        // (MATCH_*)
  -        int charpos=0;
  -        // Search the fist expression character
  -        while (expr[charpos]>=0) charpos++;
  -        // The expression charater (MATCH_*)
  -        int exprchr=expr[charpos];
  -
  -        // The position in the expression, input, translation and result arrays
  -        int exprpos=0;
  -        int buffpos=0;
  -        int offset=-1;
  -        
  -        while (true) {
  -            // Check if the data in the expression array before the current
  -            // expression character matches the data in the input buffer
  -            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  -            if (offset<0) return(false);
  -
  -            if (exprchr==MATCH_END) return(true);
  -            
  -            // Search the next expression character
  -            buffpos+=(charpos-exprpos);
  -            exprpos=++charpos;
  -            while (expr[charpos]>=0) charpos++;
  -            int prevchr=exprchr;
  -            exprchr=expr[charpos];
  -   
  -            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  -            if (offset<0) return(false);
  -    
  -            // Copy the data from the source buffer into the result buffer
  -            // to substitute the expression character
  -            if (prevchr==MATCH_PATH) {
  -                while (buffpos<offset) buffpos++;
  -            } else {
  -                // Matching file, don't copy '/'
  -                while (buffpos<offset) {
  -                    if (buff[buffpos++]=='/') return(false);
  -                }
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Get the offset of a part of an int array within a char array.
  -     * <br>
  -     * This method return the index in d of the first occurrence after dpos of
  -     * that part of array specified by r, starting at rpos and terminating at
  -     * rend.
  -     *
  -     * @param r The array containing the data that need to be matched in d.
  -     * @param rpos The index of the first character in r to look for.
  -     * @param rend The index of the last character in r to look for plus 1.
  -     * @param d The array of char that should contain a part of r.
  -     * @param dpos The starting offset in d for the matching.
  -     * @return The offset in d of the part of r matched in d or -1 if that was
  -     *         not found.
  -     */
  -    protected int matchArray(int r[], int rpos, int rend, char d[], int dpos) {
  -        // Check if pos and len are legal
  -        if(rend<rpos) throw new IllegalArgumentException("rend<rpos");
  -        // If we need to match a zero length string return current dpos
  -        if(rend==rpos) return(d.length);
  -        // If we need to match a 1 char length string do it simply
  -        if(rend-rpos==1) {
  -            // Search for the specified character
  -            for(int x=dpos; x<d.length; x++) if (r[rpos]==d[x]) return(x);
  -        }
  -        // Main string matching loop. It gets executed if the characters to
  -        // match are less then the characters left in the d buffer
  -        while(dpos+rend-rpos<=d.length) {
  -            // Set current startpoint in d
  -            int y=dpos;
  -            // Check every character in d for equity. If the string is matched
  -            // return dpos
  -            for(int x=rpos; x<=rend; x++) {
  -                if(x==rend) return(dpos);
  -                if(r[x]==d[y]) y++;
  -                else break;
  -            }
  -            // Increase dpos to search for the same string at next offset
  -            dpos++;
  -        }
  -        // The remaining chars in d buffer were not enough or the string 
  -        // wasn't matched
  -        return(-1);
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap.patterns;
  +
  +/**
  + * This class is an utility class that perform wilcard-patterns matching.
  + * <br>
  + * The pattern is made up with the following wildcards:
  + * <ul>
  + *   <li>The '*' character means that zero or more characters (excluding the
  + *       path separator '/') are to be matched.</li>
  + *   <li>The '**' sequence means that zero or more characters (including the
  + *       path separator '/') are to be matched.</li>
  + *   <li>The '\' character is used as an escape sequence ('\*' is translated in
  + *       '*', it does not represent a matching pattern). If an exact '\'
  + *       character needs to be matched the source string must contain a '\\'
  + *       sequence.</li>
  + * </ul>
  + * 
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/22 20:41:59 $
  + */
  +public class PatternMatcher {
  +
  +    /** The int representing '*' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_FILE=-1;
  +    /** The int representing '**' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_PATH=-2;
  +    /** The int value that terminates the pattern <code>int []</code>. */
  +    protected static final int MATCH_END=-3;
  +
  +    /** The <code>int []</code> identifying the pattern to match. */
  +    protected int[] sourcePattern=null;
  +
  +    /**
  +     * Construct a new <code>PatternMatcher</code> instance.
  +     */
  +    public PatternMatcher() {
  +        super();
  +    }
  +
  +    /**
  +     * Construct a new <code>PatternMatcher</code> instance.
  +     */
  +    public PatternMatcher(String pattern)
  +    throws PatternException {
  +        this();
  +        this.setPattern(pattern);
  +    }
  +
  +    /**
  +     * Match the specified <code>String</code> against the configured pattern.
  +     */
  +    public boolean match(String data) {
  +        if (data==null) throw new NullPointerException("Null data");
  +        if (this.sourcePattern==null)
  +            throw new IllegalStateException("Null internals");
  +        return(this.matchPattern(data.toCharArray(),this.sourcePattern));
  +    }
  +
  +    /**
  +     * Set the pattern for matching.
  +     */
  +    public void setPattern(String pattern)
  +    throws PatternException {
  +        if (pattern==null) throw new PatternException("Null pattern");
  +        this.sourcePattern=this.convertPattern(pattern);
  +    }
  +
  +    /**
  +     * Translate the given <code>String</code> into a <code>int []</code>
  +     * representing the pattern matchable by this class.
  +     * <br>
  +     * This function translates a <code>String</code> into an int array
  +     * converting the special '*' and '\' characters.
  +     * <br>
  +     * Here is how the conversion algorithm works:
  +     * <ul>
  +     *   <li>The '*' character is converted to MATCH_FILE, meaning that zero
  +     *        or more characters (excluding the path separator '/') are to
  +     *        be matched.</li>
  +     *   <li>The '**' sequence is converted to MATCH_PATH, meaning that zero
  +     *       or more characters (including the path separator '/') are to
  +     *        be matched.</li>
  +     *   <li>The '\' character is used as an escape sequence ('\*' is
  +     *       translated in '*', not in MATCH_FILE). If an exact '\' character
  +     *       is to be matched the source string must contain a '\\'.
  +     *       sequence.</li>
  +     * </ul>
  +     * When more than two '*' characters, not separated by another character,
  +     * are found their value is considered as '**' (MATCH_PATH).
  +     * <br>
  +     * The array is always terminated by a special value (MATCH_END).
  +     * <br>
  +     * All MATCH* values are less than zero, while normal characters are equal
  +     * or greater.
  +     *
  +     * @parameter data The string to translate.
  +     * @return The encoded string as an int array, terminated by the MATCH_END
  +     *         value (don't consider the array length).
  +     * @exception NullPointerException If data is null.
  +     */
  +    protected int[] convertPattern(String data)
  +    throws NullPointerException {
  +        // Prepare the arrays
  +        int expr[]=new int[data.length()+1];
  +        char buff[]=data.toCharArray();
  +        // Prepare variables for the translation loop
  +        int y=0;
  +        boolean slash=false;
  +        if(buff[0]=='\\') slash=true;
  +        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  +        else expr[y++]=buff[0];
  +        // Main translation loop
  +        for (int x=1; x<buff.length; x++) {
  +            // If the previous char was '\' simply copy this char.
  +            if (slash) {
  +                expr[y++]=buff[x];
  +                slash=false;
  +            // If the previous char was not '\' we have to do a bunch of checks
  +            } else {
  +                int prev=(y-1);
  +                // If this char is '\' declare that and continue
  +                if(buff[x]=='\\') {
  +                    slash=true;
  +                // If this char is '*' check the previous one
  +                } else if(buff[x]=='*') {
  +                    // If the previous character als was '*' match a path
  +                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  +                    else expr[y++]=MATCH_FILE;
  +                } else expr[y++]=buff[x];
  +            }
  +        }
  +        // Declare the end of the array and return it
  +        expr[y]=MATCH_END;
  +        return(expr);
  +    }        
  +
  +    /**
  +     * Matches the specified <code>char []</code> against the given pattern
  +     * formatted as an <code>int []</code>.
  +     * <br>
  +     * This method returns <b>true</b> if the specified <code>char []</code>
  +     * can be matched by the pattern created by <code>convertPattern(...)</code>
  +     * be represented as an <code>int []</code>, <b>false</b> otherwise.
  +     * <br>
  +     * <b>FIXME: This routine doesn't match when the pattern ends with a
  +     *    wildcard. Need to fix together with <code>translatePattern()</code>,
  +     *    in <code>PatternTranslator</code> otherwise it won't work.</b>
  +     * <br>
  +     * <i>Seems ok now</i>
  +     *
  +     * @param buff The <code>char []</code> of the path to be matched.
  +     * @param expr The <code>int []</code> representing the pattern, as
  +     *             returned by <code>convertPattern(...)</code>.
  +     * @exception NullPointerException If a parameter is <b>null</b>.
  +     */
  +    protected boolean matchPattern(char buff[], int expr[])
  +    throws NullPointerException {
  +                
  +        // The previous and current position of the expression character
  +        // (MATCH_*)
  +        int charpos=0;
  +        // Search the fist expression character
  +        while (expr[charpos]>=0) charpos++;
  +        // The expression charater (MATCH_*)
  +        int exprchr=expr[charpos];
  +
  +        // The position in the expression, input, translation and result arrays
  +        int exprpos=0;
  +        int buffpos=0;
  +        int offset=-1;
  +        
  +        while (true) {
  +            // Check if the data in the expression array before the current
  +            // expression character matches the data in the input buffer
  +            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(false);
  +
  +            if (exprchr==MATCH_END) return(true);
  +            
  +            // Search the next expression character
  +            buffpos+=(charpos-exprpos);
  +            exprpos=++charpos;
  +            while (expr[charpos]>=0) charpos++;
  +            int prevchr=exprchr;
  +            exprchr=expr[charpos];
  +   
  +            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(false);
  +    
  +            // Copy the data from the source buffer into the result buffer
  +            // to substitute the expression character
  +            if (prevchr==MATCH_PATH) {
  +                while (buffpos<offset) buffpos++;
  +            } else {
  +                // Matching file, don't copy '/'
  +                while (buffpos<offset) {
  +                    if (buff[buffpos++]=='/') return(false);
  +                }
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Get the offset of a part of an int array within a char array.
  +     * <br>
  +     * This method return the index in d of the first occurrence after dpos of
  +     * that part of array specified by r, starting at rpos and terminating at
  +     * rend.
  +     *
  +     * @param r The array containing the data that need to be matched in d.
  +     * @param rpos The index of the first character in r to look for.
  +     * @param rend The index of the last character in r to look for plus 1.
  +     * @param d The array of char that should contain a part of r.
  +     * @param dpos The starting offset in d for the matching.
  +     * @return The offset in d of the part of r matched in d or -1 if that was
  +     *         not found.
  +     */
  +    protected int matchArray(int r[], int rpos, int rend, char d[], int dpos) {
  +        // Check if pos and len are legal
  +        if(rend<rpos) throw new IllegalArgumentException("rend<rpos");
  +        // If we need to match a zero length string return current dpos
  +        if(rend==rpos) return(d.length);
  +        // If we need to match a 1 char length string do it simply
  +        if(rend-rpos==1) {
  +            // Search for the specified character
  +            for(int x=dpos; x<d.length; x++) if (r[rpos]==d[x]) return(x);
  +        }
  +        // Main string matching loop. It gets executed if the characters to
  +        // match are less then the characters left in the d buffer
  +        while(dpos+rend-rpos<=d.length) {
  +            // Set current startpoint in d
  +            int y=dpos;
  +            // Check every character in d for equity. If the string is matched
  +            // return dpos
  +            for(int x=rpos; x<=rend; x++) {
  +                if(x==rend) return(dpos);
  +                if(r[x]==d[y]) y++;
  +                else break;
  +            }
  +            // Increase dpos to search for the same string at next offset
  +            dpos++;
  +        }
  +        // The remaining chars in d buffer were not enough or the string 
  +        // wasn't matched
  +        return(-1);
  +    }
  +}
  
  
  
  1.1.2.7   +201 -201  xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternTranslator.java
  
  Index: PatternTranslator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternTranslator.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- PatternTranslator.java	2000/02/27 14:57:59	1.1.2.6
  +++ PatternTranslator.java	2000/07/22 20:42:00	1.1.2.7
  @@ -1,201 +1,201 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap.patterns;
  -
  -/**
  - * This class is an utility class that perform wilcard-patterns matching and
  - * translation.
  - * <br>
  - * The pattern rules follow the one defined by <code>PatternMatcher</code> and
  - * the translation is done in the following way (in example):
  - * if the source pattern is &quot;test/*.xml&quot; and the target pattern is
  - * &quot;sources/data/*&quot;, the <code>String</code> &quot;test/my.xml&quot;
  - * will be translated into &quot;sources/data/my&quot;
  - * 
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/02/27 14:57:59 $
  - */
  -public class PatternTranslator extends PatternMatcher {
  -
  -    /** Wether the source and the target patterns are equal. */
  -    private boolean identityTranslation=false;
  -    /** The int array identifying the pattern to match. */
  -    protected int[] targetPattern=null;
  -
  -
  -    /**
  -     * Construct a new <code>PatternTranslator</code> instance.
  -     */
  -    public PatternTranslator() {
  -        super();
  -    }
  -
  -    /**
  -     * Construct a new <code>PatternTranslator</code> instance.
  -     */
  -    public PatternTranslator(String pattern)
  -    throws PatternException {
  -        this();
  -        this.setPattern(pattern);
  -    }
  -
  -    /**
  -     * Construct a new <code>PatternTranslator</code> instance.
  -     */
  -    public PatternTranslator(String source, String target)
  -    throws PatternException {
  -        this();
  -        this.setPattern(source,target);
  -    }
  -
  -    /**
  -     * Translate the specified <code>String</code> according to the rules
  -     * specified by the source and target patterns.
  -     * <br>
  -     * If the specified <code>String</code> is not matched by the source
  -     * pattern <b>null</b> is returned.
  -     * <br>
  -     * If the source and the target patterns are qual the same
  -     * <code>String</code> is returned.
  -     */
  -    public String translate(String data) {
  -        if (data==null) throw new NullPointerException("Null data");
  -        if (this.identityTranslation) return(data);
  -        if ((this.targetPattern==null) || (super.sourcePattern==null))
  -            throw new IllegalStateException("Null internals");
  -        if (!super.match(data)) return(null);
  -        
  -        char x[]=data.toCharArray();
  -        return(this.translatePattern(x,super.sourcePattern,this.targetPattern));
  -    }
  -
  -    /**
  -     * Set the source and target patterns as two identical patterns.
  -     * <br>
  -     * No translation will be performed, as this specifies the identity
  -     * transformation.
  -     */
  -    public void setPattern(String pattern)
  -    throws PatternException {
  -        if (pattern==null) throw new PatternException("Null pattern");
  -        this.setPattern(pattern,pattern);
  -    }
  -
  -    /**
  -     * Set the source and target patterns.
  -     * <br>
  -     * If the source pattern is equal to the target one, no translation will
  -     * be performed as same patterns specify an identity transformation.
  -     */
  -    public void setPattern(String source, String target)
  -    throws PatternException {
  -        if (source==null) throw new PatternException("Null source pattern");
  -        if (target==null) throw new PatternException("Null target pattern");
  -        if (source.equals(target)) {
  -            this.targetPattern=super.convertPattern(target);
  -            super.sourcePattern=this.targetPattern;
  -            this.identityTranslation=true;
  -            return;
  -        }
  -        int t[]=super.convertPattern(target);
  -        int s[]=super.convertPattern(source);
  -        int y=0;
  -        for(int x=0; x<t.length; x++) if(t[x]<0) {
  -            while(s[y]>=0) y++;
  -            if(t[x]!=s[y]) throw new PatternException("Unbalanced expression");
  -            else y++;
  -            if(t[x]==MATCH_END) break;
  -        }
  -        this.targetPattern=t;
  -        super.sourcePattern=s;
  -    }
  -
  -    /** 
  -     * Internal routines for translation
  -     * <br>
  -     * <b>FIXME: This routine doesn't match when the pattern ends with a
  -     *    wildcard. Need to fix together with <code>matchPattern()</code>,
  -     *    in <code>PatternMatcher</code> otherwise it won't work.</b>
  -     * <br>
  -     * <i>Seems ok now</i>
  -     */
  -    protected String translatePattern(char buff[], int expr[], int trns[])
  -    throws NullPointerException {
  -        // Allocate the result buffer
  -        char rslt[]=new char[expr.length+trns.length+buff.length];
  -        
  -        // The previous and current position of the expression character
  -        // (MATCH_*)
  -        int charpos=0;
  -        // Search the fist expression character
  -        while (expr[charpos]>=0) charpos++;
  -        // The expression charater (MATCH_*)
  -        int exprchr=expr[charpos];
  -
  -        // The position in the expression, input, translation and result arrays
  -        int exprpos=0;
  -        int buffpos=0;
  -        int trnspos=0;
  -        int rsltpos=0;
  -        int offset=-1;
  -        
  -        while (true) {
  -            // Check if the data in the expression array before the current
  -            // expression character matches the data in the input buffer
  -            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  -            if (offset<0) return(null);
  -
  -            // Copy the data from the translation buffer into the result buffer
  -            // up to the next expression character (arriving to the current in the
  -            // expression buffer)        
  -            while (trns[trnspos]>=0) rslt[rsltpos++]=(char)trns[trnspos++];
  -            trnspos++;
  -                
  -            if (exprchr==MATCH_END) return(new String(rslt,0,rsltpos));
  -            
  -            // Search the next expression character
  -            buffpos+=(charpos-exprpos);
  -            exprpos=++charpos;
  -            while (expr[charpos]>=0) charpos++;
  -            int prevchr=exprchr;
  -            exprchr=expr[charpos];
  -   
  -            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  -            if (offset<0) return(null);
  -    
  -            // Copy the data from the source buffer into the result buffer
  -            // to substitute the expression character
  -            if (prevchr==MATCH_PATH) {
  -                while (buffpos<offset) rslt[rsltpos++]=buff[buffpos++];
  -            } else {
  -                // Matching file, don't copy '/'
  -                while (buffpos<offset) {
  -                    if (buff[buffpos]=='/') return(null);
  -                    rslt[rsltpos++]=buff[buffpos++];
  -                }
  -            }
  -        }
  -    }
  -    
  -    /** Testing */
  -    public static void main(String argv[]) {
  -        try {
  -            if (argv.length<3) return;
  -            PatternTranslator t=new PatternTranslator(argv[0],argv[1]);
  -            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  -            System.out.println("Translation Expr. \""+argv[1]+"\"");
  -            System.out.println("Source Data       \""+argv[2]+"\"");
  -            System.out.println(" - Math returned \""+t.match(argv[2])+"\"");
  -            System.out.println(" - Translation   \""+t.translate(argv[2])+"\"");
  -        } catch (Exception e) {
  -            System.out.println(e.getClass().getName());
  -            System.out.println(e.getMessage());
  -        }
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.sitemap.patterns;
  +
  +/**
  + * This class is an utility class that perform wilcard-patterns matching and
  + * translation.
  + * <br>
  + * The pattern rules follow the one defined by <code>PatternMatcher</code> and
  + * the translation is done in the following way (in example):
  + * if the source pattern is &quot;test/*.xml&quot; and the target pattern is
  + * &quot;sources/data/*&quot;, the <code>String</code> &quot;test/my.xml&quot;
  + * will be translated into &quot;sources/data/my&quot;
  + * 
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.7 $ $Date: 2000/07/22 20:42:00 $
  + */
  +public class PatternTranslator extends PatternMatcher {
  +
  +    /** Wether the source and the target patterns are equal. */
  +    private boolean identityTranslation=false;
  +    /** The int array identifying the pattern to match. */
  +    protected int[] targetPattern=null;
  +
  +
  +    /**
  +     * Construct a new <code>PatternTranslator</code> instance.
  +     */
  +    public PatternTranslator() {
  +        super();
  +    }
  +
  +    /**
  +     * Construct a new <code>PatternTranslator</code> instance.
  +     */
  +    public PatternTranslator(String pattern)
  +    throws PatternException {
  +        this();
  +        this.setPattern(pattern);
  +    }
  +
  +    /**
  +     * Construct a new <code>PatternTranslator</code> instance.
  +     */
  +    public PatternTranslator(String source, String target)
  +    throws PatternException {
  +        this();
  +        this.setPattern(source,target);
  +    }
  +
  +    /**
  +     * Translate the specified <code>String</code> according to the rules
  +     * specified by the source and target patterns.
  +     * <br>
  +     * If the specified <code>String</code> is not matched by the source
  +     * pattern <b>null</b> is returned.
  +     * <br>
  +     * If the source and the target patterns are qual the same
  +     * <code>String</code> is returned.
  +     */
  +    public String translate(String data) {
  +        if (data==null) throw new NullPointerException("Null data");
  +        if (this.identityTranslation) return(data);
  +        if ((this.targetPattern==null) || (super.sourcePattern==null))
  +            throw new IllegalStateException("Null internals");
  +        if (!super.match(data)) return(null);
  +        
  +        char x[]=data.toCharArray();
  +        return(this.translatePattern(x,super.sourcePattern,this.targetPattern));
  +    }
  +
  +    /**
  +     * Set the source and target patterns as two identical patterns.
  +     * <br>
  +     * No translation will be performed, as this specifies the identity
  +     * transformation.
  +     */
  +    public void setPattern(String pattern)
  +    throws PatternException {
  +        if (pattern==null) throw new PatternException("Null pattern");
  +        this.setPattern(pattern,pattern);
  +    }
  +
  +    /**
  +     * Set the source and target patterns.
  +     * <br>
  +     * If the source pattern is equal to the target one, no translation will
  +     * be performed as same patterns specify an identity transformation.
  +     */
  +    public void setPattern(String source, String target)
  +    throws PatternException {
  +        if (source==null) throw new PatternException("Null source pattern");
  +        if (target==null) throw new PatternException("Null target pattern");
  +        if (source.equals(target)) {
  +            this.targetPattern=super.convertPattern(target);
  +            super.sourcePattern=this.targetPattern;
  +            this.identityTranslation=true;
  +            return;
  +        }
  +        int t[]=super.convertPattern(target);
  +        int s[]=super.convertPattern(source);
  +        int y=0;
  +        for(int x=0; x<t.length; x++) if(t[x]<0) {
  +            while(s[y]>=0) y++;
  +            if(t[x]!=s[y]) throw new PatternException("Unbalanced expression");
  +            else y++;
  +            if(t[x]==MATCH_END) break;
  +        }
  +        this.targetPattern=t;
  +        super.sourcePattern=s;
  +    }
  +
  +    /** 
  +     * Internal routines for translation
  +     * <br>
  +     * <b>FIXME: This routine doesn't match when the pattern ends with a
  +     *    wildcard. Need to fix together with <code>matchPattern()</code>,
  +     *    in <code>PatternMatcher</code> otherwise it won't work.</b>
  +     * <br>
  +     * <i>Seems ok now</i>
  +     */
  +    protected String translatePattern(char buff[], int expr[], int trns[])
  +    throws NullPointerException {
  +        // Allocate the result buffer
  +        char rslt[]=new char[expr.length+trns.length+buff.length];
  +        
  +        // The previous and current position of the expression character
  +        // (MATCH_*)
  +        int charpos=0;
  +        // Search the fist expression character
  +        while (expr[charpos]>=0) charpos++;
  +        // The expression charater (MATCH_*)
  +        int exprchr=expr[charpos];
  +
  +        // The position in the expression, input, translation and result arrays
  +        int exprpos=0;
  +        int buffpos=0;
  +        int trnspos=0;
  +        int rsltpos=0;
  +        int offset=-1;
  +        
  +        while (true) {
  +            // Check if the data in the expression array before the current
  +            // expression character matches the data in the input buffer
  +            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(null);
  +
  +            // Copy the data from the translation buffer into the result buffer
  +            // up to the next expression character (arriving to the current in the
  +            // expression buffer)        
  +            while (trns[trnspos]>=0) rslt[rsltpos++]=(char)trns[trnspos++];
  +            trnspos++;
  +                
  +            if (exprchr==MATCH_END) return(new String(rslt,0,rsltpos));
  +            
  +            // Search the next expression character
  +            buffpos+=(charpos-exprpos);
  +            exprpos=++charpos;
  +            while (expr[charpos]>=0) charpos++;
  +            int prevchr=exprchr;
  +            exprchr=expr[charpos];
  +   
  +            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(null);
  +    
  +            // Copy the data from the source buffer into the result buffer
  +            // to substitute the expression character
  +            if (prevchr==MATCH_PATH) {
  +                while (buffpos<offset) rslt[rsltpos++]=buff[buffpos++];
  +            } else {
  +                // Matching file, don't copy '/'
  +                while (buffpos<offset) {
  +                    if (buff[buffpos]=='/') return(null);
  +                    rslt[rsltpos++]=buff[buffpos++];
  +                }
  +            }
  +        }
  +    }
  +    
  +    /** Testing */
  +    public static void main(String argv[]) {
  +        try {
  +            if (argv.length<3) return;
  +            PatternTranslator t=new PatternTranslator(argv[0],argv[1]);
  +            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  +            System.out.println("Translation Expr. \""+argv[1]+"\"");
  +            System.out.println("Source Data       \""+argv[2]+"\"");
  +            System.out.println(" - Math returned \""+t.match(argv[2])+"\"");
  +            System.out.println(" - Translation   \""+t.translate(argv[2])+"\"");
  +        } catch (Exception e) {
  +            System.out.println(e.getClass().getName());
  +            System.out.println(e.getMessage());
  +        }
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +189 -189  xml-cocoon/src/org/apache/cocoon/transformation/Attic/AbstractTransformer.java
  
  Index: AbstractTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/AbstractTransformer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- AbstractTransformer.java	2000/07/11 23:46:56	1.1.2.1
  +++ AbstractTransformer.java	2000/07/22 20:42:00	1.1.2.2
  @@ -1,189 +1,189 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.transformation;
  -
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:56 $
  - */
  -public abstract class AbstractTransformer extends AbstractXMLProducer
  -implements Transformer {
  -
  -    /** Wether we are forwarding XML data or not. */
  -    private boolean canReset=true;
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.setDocumentLocator(locator);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startDocument();
  -        this.canReset=false;
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endDocument();
  -        this.canReset=true;
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startPrefixMapping(prefix,uri);
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes a)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startElement(uri,loc,raw,a);
  -    }
  -
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     */
  -    public void endElement(String uri, String loc, String raw)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endElement(uri,loc,raw);
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     */
  -    public void characters(char ch[], int start, int len)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.characters(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     */
  -    public void ignorableWhitespace(char ch[], int start, int len)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.ignorableWhitespace(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     */
  -    public void processingInstruction(String target, String data)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.processingInstruction(target,data);
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     */
  -    public void skippedEntity(String name)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.skippedEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     */
  -    public void startDTD(String name, String publicId, String systemId)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startDTD(name,publicId,systemId);
  -    }
  -
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD()
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endDTD();
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     */
  -    public void startEntity(String name)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startEntity(name);
  -    }
  -
  -    /**
  -     * Report the end of an entity.
  -     */
  -    public void endEntity(String name)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA()
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startCDATA();
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA()
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endCDATA();
  -    }
  -
  -
  -    /**
  -     * Report an XML comment anywhere in the document.
  -     */
  -    public void comment(char ch[], int start, int len)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.comment(ch,start,len);
  -    }
  -}
  +/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.transformation;
  +
  +import org.apache.cocoon.xml.AbstractXMLProducer;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:00 $
  + */
  +public abstract class AbstractTransformer extends AbstractXMLProducer
  +implements Transformer {
  +
  +    /** Wether we are forwarding XML data or not. */
  +    private boolean canReset=true;
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     */
  +    public void setDocumentLocator(Locator locator) {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.setDocumentLocator(locator);
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startDocument();
  +        this.canReset=false;
  +    }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument()
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.endDocument();
  +        this.canReset=true;
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startPrefixMapping(prefix,uri);
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes a)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startElement(uri,loc,raw,a);
  +    }
  +
  +
  +    /**
  +     * Receive notification of the end of an element.
  +     */
  +    public void endElement(String uri, String loc, String raw)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.endElement(uri,loc,raw);
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     */
  +    public void characters(char ch[], int start, int len)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.characters(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     */
  +    public void ignorableWhitespace(char ch[], int start, int len)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.ignorableWhitespace(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of a processing instruction.
  +     */
  +    public void processingInstruction(String target, String data)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.processingInstruction(target,data);
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     */
  +    public void skippedEntity(String name)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.skippedEntity(name);
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any.
  +     */
  +    public void startDTD(String name, String publicId, String systemId)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startDTD(name,publicId,systemId);
  +    }
  +
  +    /**
  +     * Report the end of DTD declarations.
  +     */
  +    public void endDTD()
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endDTD();
  +    }
  +
  +    /**
  +     * Report the beginning of an entity.
  +     */
  +    public void startEntity(String name)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startEntity(name);
  +    }
  +
  +    /**
  +     * Report the end of an entity.
  +     */
  +    public void endEntity(String name)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endEntity(name);
  +    }
  +
  +    /**
  +     * Report the start of a CDATA section.
  +     */
  +    public void startCDATA()
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startCDATA();
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section.
  +     */
  +    public void endCDATA()
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endCDATA();
  +    }
  +
  +
  +    /**
  +     * Report an XML comment anywhere in the document.
  +     */
  +    public void comment(char ch[], int start, int len)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.comment(ch,start,len);
  +    }
  +}
  
  
  
  1.1.2.2   +312 -313  xml-cocoon/src/org/apache/cocoon/transformation/Attic/LogTransformer.java
  
  Index: LogTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/LogTransformer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- LogTransformer.java	2000/07/11 23:46:57	1.1.2.1
  +++ LogTransformer.java	2000/07/22 20:42:01	1.1.2.2
  @@ -1,313 +1,312 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. 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 org.apache.cocoon.transformation;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.Request;
  -import org.apache.cocoon.Response;
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -
  -import org.xml.sax.Attributes;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -import java.io.FileWriter;
  -import java.io.IOException;
  -import java.util.Date;
  -
  -/**
  - *
  - * The <code>LogTransformer</code> is a class that can be plugged into a pipeline
  - * to print the SAX events which passes thru this transformer in a readable form 
  - * to a file. 
  - * <br>
  - * The file will be specified in a parameter tag to the transformer as follows:
  - * <p>
  - * <code>
  - * &lt;transformer name="log"&gt;<br>
  - * &nbsp;&nbsp;&lt;parameter name="logfile" value="logfile.log"/&gt;<br>
  - * &nbsp;&nbsp;&lt;parameter name="append" value="no"/&gt;<br>
  - * &lt;/transformer&gt;<br>
  - * </code>
  - * </p>
  - *
  - * Because the log file will be hardcoded into the sitemap this LOGTransformer will 
  - * not be thread save!!
  - * <br>
  - * This transformations main purpose is debugging.
  - * 
  - * @author <a href="mailto:giacomo.pati@pwr.ch">Giacomo Pati</a>
  - *         (PWR Organisation &amp; Entwicklung)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:57 $
  - *
  - */
  -public class LogTransformer extends AbstractTransformer {
  -
  -    /** Wether we are forwarding XML data or not. */
  -    private boolean canReset=true;
  -
  -    private String lf = System.getProperty("line.separator", "\n");
  -    
  -    /** true if filename is valid and writeable */
  -    private boolean isValid = true;
  -    /** filename for log file	*/
  -    private String logfilename = null;
  -    /** log file	*/
  -    private FileWriter logfile = null;
  -    /** should we append content to the log file */
  -    private boolean append = false;
  -
  -    /** BEGIN SitemapComponent methods **/
  -
  -    public void setup(Request request, Response response, 
  -                      String source, Parameters parameters) 
  -            throws ProcessingException, SAXException, IOException {
  -        if (logfile == null) {
  -            String appends = parameters.getParameter("append", null);
  -            logfilename = parameters.getParameter("logfile", null);
  -            if (appends != null && appends.equals ("yes")) {
  -                append = true;
  -            } else {
  -                append = false;
  -            }
  -            try {
  -                logfile = new FileWriter(logfilename, append );
  -            } catch (IOException e) {
  -                isValid = false;
  -                throw e;
  -            }
  -        }
  -        Date date = new Date();
  -        StringBuffer logEntry = new StringBuffer();
  -        logEntry.append ( "---------------------------- [" );
  -        logEntry.append ( date.toString() ); 
  -        logEntry.append ( "] ----------------------------" );
  -        log("setup", logEntry.toString());
  -    }
  -
  -    /** END SitemapComponent methods **/
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -        log("setDocumentLocator","");
  -        if (super.contentHandler!=null)
  -            super.contentHandler.setDocumentLocator(locator);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        log("startDocument", "");
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startDocument();
  -        this.canReset=false;
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -        log ("endDocument", "");
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endDocument();
  -        this.canReset=true;
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        log ("startPrefixMapping", "prefix="+prefix+",uri="+uri);
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startPrefixMapping(prefix,uri);
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -        log ("endPrefixMapping", "prefix="+prefix);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes a)
  -    throws SAXException {
  -        log ("startElement", "uri="+uri+",local="+loc+",raw="+raw);
  -        for (int i = 0; i < a.getLength(); i++) {
  -            log ("            ", new Integer(i+1).toString()
  -                 +". uri="+a.getURI(i)
  -                 +",local="+a.getLocalName(i)
  -                 +",qname="+a.getQName(i)
  -                 +",type="+a.getType(i)
  -                 +",value="+a.getValue(i));
  -        }
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startElement(uri,loc,raw,a);
  -    }
  -
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     */
  -    public void endElement(String uri, String loc, String qname)
  -    throws SAXException {
  -        log ("endElement", "uri="+uri+",local="+loc+",qname="+qname);
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endElement(uri,loc,qname);
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     */
  -    public void characters(char ch[], int start, int len)
  -    throws SAXException {
  -        log ("characters", new String(ch).substring(start, len));
  -        if (super.contentHandler!=null)
  -            super.contentHandler.characters(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     */
  -    public void ignorableWhitespace(char ch[], int start, int len)
  -    throws SAXException {
  -        log ("ignorableWhitespace", new String(ch).substring(start, len));
  -        if (super.contentHandler!=null)
  -            super.contentHandler.ignorableWhitespace(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     */
  -    public void processingInstruction(String target, String data)
  -    throws SAXException {
  -        log ("processingInstruction", "target="+target+",data="+data);
  -        if (super.contentHandler!=null)
  -            super.contentHandler.processingInstruction(target,data);
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     */
  -    public void skippedEntity(String name)
  -    throws SAXException {
  -        log ("skippedEntity", "name="+name);
  -        if (super.contentHandler!=null)
  -            super.contentHandler.skippedEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     */
  -    public void startDTD(String name, String publicId, String systemId)
  -    throws SAXException {
  -        log ("startDTD", "name="+name+",publicId="+publicId+",systemId="+systemId);
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startDTD(name,publicId,systemId);
  -    }
  -
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD()
  -    throws SAXException {
  -        log ("endDTD", "");
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endDTD();
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     */
  -    public void startEntity(String name)
  -    throws SAXException {
  -        log ("startEntity", "name="+name);
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startEntity(name);
  -    }
  -
  -    /**
  -     * Report the end of an entity.
  -     */
  -    public void endEntity(String name)
  -    throws SAXException {
  -        log ("endEntity", "name="+name);
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA()
  -    throws SAXException {
  -        log ("startCDATA", "");
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startCDATA();
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA()
  -    throws SAXException {
  -        log ("endCDATA", "");
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endCDATA();
  -    }
  -
  -    /**
  -     * Report an XML comment anywhere in the document.
  -     */
  -    public void comment(char ch[], int start, int len)
  -    throws SAXException {
  -        log ("comment", new String(ch).substring(start, len));
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.comment(ch,start,len);
  -    }
  -
  -    /**
  -     * Report to logfile.
  -