cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/webapp/mount/charts sitemap.xmap
Date Mon, 08 Apr 2002 08:09:17 GMT
nicolaken    02/04/08 01:09:17

  Added:       src/scratchpad/src/org/apache/cocoon/transformation/constrained
                        AbstractConstrainedTransformer.java
                        ContainerElementEndEvent.java
                        ElementEventAdapter.java ElementEventListener.java
                        ElementValueEvent.java XmlTreeConstraint.java
               src/scratchpad/webapp/mount/charts/content/static
                        bar3Dchart.xml barchart.xml linechart.xml
                        testapplet.xml
               src/scratchpad/src/org/apache/cocoon/transformation
                        Chart2SvgTransformer.java
               src/scratchpad/lib krysalis-wings-0.1.0-dev-2.jar
                        LICENSE.krysalis-wings
               src/scratchpad/webapp/mount/charts/content samples.xml
               src/scratchpad/webapp/mount/charts/stylesheets
                        simple-samples2html.xsl
               src/scratchpad/webapp/mount/charts sitemap.xmap
  Log:
  Adding my charting stuff to scratchpad.
  It builds; it doesn't work.
  It used to work in an early version of C2, and adaption to latest C2 isn't finished.
  Patches welcome.
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/constrained/AbstractConstrainedTransformer.java
  
  Index: AbstractConstrainedTransformer.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.transformation.constrained;
  
  import java.io.IOException;
  
  import java.util.Map;
  import java.util.Properties;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.ListIterator;
  import java.util.TooManyListenersException;
  import java.util.EventListener;
  
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.xml.XMLConsumer;
  import org.apache.cocoon.xml.XMLProducer;
  import org.apache.cocoon.transformation.*;
  
  
  import org.xml.sax.ContentHandler;
  import org.xml.sax.EntityResolver;
  import org.xml.sax.Attributes;
  import org.xml.sax.helpers.AttributesImpl;
  import org.xml.sax.SAXException;
  import org.xml.sax.Locator;
  import org.xml.sax.ext.LexicalHandler;
  
  
  /**
   * This class is an abstract class from which you can extend your Transformer
   * and write it in a way similar to AWT & Swing Event Handling.
   * Part of this code is from the SQLTransformer of Donald Ball.
   * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a> 
   */
  public abstract class AbstractConstrainedTransformer
          extends AbstractTransformer {
  
      private String           my_uri;
      private String           my_prefix = "unknown";
      private String           my_name;
      private ArrayList        myUriOpenElements             = new ArrayList();
      private ArrayList        globalOpenElements            = new ArrayList();
      private ArrayList        globalOpenElementsAttributes  = new ArrayList();
      private String           lastOpenElementRaw            = "";
      private ArrayList        registeredListeners           = new ArrayList();
      private ArrayList        registeredListenerConstraints = new ArrayList();
      private StringBuffer     current_value                 =
          new StringBuffer();
      protected XMLConsumer    xml_consumer;
      protected LexicalHandler lexical_handler;
  
  
      public abstract void init(Parameters parameters);
  
      public abstract String getUri();
  
      public abstract String getName();
  
      public final void setup(
              EntityResolver resolver, Map objectModel, String source, Parameters parameters)
                  throws ProcessingException, SAXException, IOException {
  
          my_uri  = getUri();
          getLogger().debug(my_uri);
          my_name = getName();
          getLogger().debug(my_name);
          init(parameters);
  
      }
  
  
      public void addEventListener(
              ElementEventListener l, XmlTreeConstraint constraint){
  
          registeredListeners.add(l);
          registeredListenerConstraints.add(constraint);
      }
  
  
      public void setDocumentLocator(Locator locator) {
          if (super.contentHandler != null) {
              super.contentHandler.setDocumentLocator(locator);
          }
      }
  
      public void startElement(
              String uri, String name, String raw, Attributes attributes)
                  throws SAXException {
          System.out.println("Start"+uri+name+raw+attributes);
  
          lastOpenElementRaw = raw;
  
          boolean isMyUri = false;
  
          if (uri.equals(my_uri)) {
              isMyUri = true;
              if (getLogger().isDebugEnabled())
                getLogger().debug(raw+" isMyUri!!!");
              myUriOpenElements.add(name);
  
          current_value.delete(0, current_value.length());
          globalOpenElements.add(name);
          globalOpenElementsAttributes.add(attributes);
  
          ListIterator constraintsIter =
              this.registeredListenerConstraints.listIterator();
  
          while (constraintsIter.hasNext()) {
              if (((XmlTreeConstraint) constraintsIter.next())
                      .isAllowed(new Boolean(isMyUri), this.myUriOpenElements,
                                 this.globalOpenElements)) {
                  return;
              }
          }
          }
  else{
          super.startElement(uri, name, raw, attributes);
  }
      }
  
      public void endElement(String uri, String name, String raw)
              throws SAXException {
  
          try {
  
              boolean isMyUri = false;
  
              if (uri.equals(my_uri)) {
                  isMyUri = true;
  
              ListIterator      constraintsIter =
                  this.registeredListenerConstraints.listIterator();
              XmlTreeConstraint currentConstraint;
              boolean           isAllowed;
              boolean           isElementTag = lastOpenElementRaw.equals(raw);
  
              while (constraintsIter.hasNext()) {
                  currentConstraint =
                      (XmlTreeConstraint) constraintsIter.next();
                  isAllowed         =
                      currentConstraint.isAllowed(new Boolean(isMyUri),
                                                  this.myUriOpenElements,
                                                  this.globalOpenElements);
  
                  if (isAllowed) {
  
                      EventListener el =
                          (EventListener) (registeredListeners
                              .get(constraintsIter.previousIndex()));
  
  
                      if(isElementTag)//it's an element
                      {
                          ((ElementEventListener)el).elementValueRecieved(
                              new ElementValueEvent(
                                  this, name, current_value.toString(),
                                  (Attributes) this.globalOpenElementsAttributes
                                      .get(globalOpenElementsAttributes.size()
                                           - 1)));
                      }
                      else {//it's a container
                          ((ElementEventListener)el).containerElementEnded(
                              new ContainerElementEndEvent(
                                  this, name));
                      }
  
  
                      if (uri.equals(my_uri)) {
                          myUriOpenElements.remove(myUriOpenElements.size()
                                                   - 1);
                      }
  
                      globalOpenElements.remove(globalOpenElements.size() - 1);
                      globalOpenElementsAttributes
                          .remove(globalOpenElementsAttributes.size() - 1);
                      current_value.delete(0, current_value.length());
  
                      return;
                  }
              }
  
              if (globalOpenElements.size() > 0) {
                  globalOpenElements.remove(globalOpenElements.size() - 1);
                  globalOpenElementsAttributes
                      .remove(globalOpenElementsAttributes.size() - 1);
  
              }
  
              if (uri.equals(my_uri) && (myUriOpenElements.size() > 0)) {
                  myUriOpenElements.remove(myUriOpenElements.size() - 1);
  
              }
              }
  else{
              super.endElement(uri, name, raw);
              }
  
  
              current_value.delete(0, current_value.length());
  
          } catch (Exception t) {
              throw new SAXException("Exception in transformer "
                                     + this.getName() + " with uri "
                                     + this.getUri()
                                     + " while ending element.", t);
          }
      }
  
      /***************************************/
      /* Utility methods also for subclasses */
      /***************************************/
  
  
      public class RipperListener extends ElementEventAdapter {
  
          public void elementValueRecieved(ElementValueEvent e) {
            //do nothing so that element doesn't pass through
          }
      }
  
  
      public void characters(char ary[], int start, int length)
              throws SAXException {
  
          if (this.globalOpenElements.isEmpty()) {
              super.characters(ary, start, length);
          } else {
              current_value.append(ary, start, length);
          }
      }
  
      protected void start(String name, AttributesImpl attr)
              throws SAXException {
          super.contentHandler.startElement(getUri(), name, name, attr);
          attr.clear();
      }
  
      protected void start(String name) throws SAXException {
          super.contentHandler.startElement(getUri(), name, name,
                                            new AttributesImpl());
      }
  
      protected void end(String name) throws SAXException {
          super.contentHandler.endElement(getUri(), name, name);
      }
  
      protected void data(String data) throws SAXException {
  
          if (data != null) {
              super.contentHandler.characters(data.toCharArray(), 0,
                                              data.length());
          }
      }
  
      protected static String getStringValue(Object object) {
  
          if (object instanceof byte[]) {
              return new String((byte[]) object);
          } else if (object instanceof char[]) {
              return new String((char[]) object);
          } else if (object != null) {
              return object.toString();
          } else {
              return "";
          }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/constrained/ContainerElementEndEvent.java
  
  Index: ContainerElementEndEvent.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.transformation.constrained;
  
  
  import java.util.EventObject;
  import org.xml.sax.Attributes;
  import org.apache.cocoon.xml.XMLProducer;
  
  
  /**
   *
   * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a> 
   */
  public class ContainerElementEndEvent extends EventObject  {
  
      private String     elementName;
  
      public ContainerElementEndEvent(
              Object source, String elementName) {
  
          super(source);
  
  
          this.elementName       = elementName;
  
      }
  
      public Object getSource() {
          return source;
      }
  
      public String getElementName() {
          return elementName;
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/constrained/ElementEventAdapter.java
  
  Index: ElementEventAdapter.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.transformation.constrained;
  
  import java.util.EventListener;
  import org.xml.sax.SAXException;
  
  /**
   *
   * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a> 
   */
  public abstract class ElementEventAdapter implements ElementEventListener {
  
    public void containerElementEnded(ContainerElementEndEvent e) throws Exception{}
  
    public void elementValueRecieved(ElementValueEvent e) throws Exception{}
  
  }
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/constrained/ElementEventListener.java
  
  Index: ElementEventListener.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.transformation.constrained;
  
  import java.util.EventListener;
  import org.xml.sax.SAXException;
  
  /**
   *
   * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a> 
   */
  public interface ElementEventListener extends EventListener {
  
    public void containerElementEnded(ContainerElementEndEvent e) throws Exception;
  
    public void elementValueRecieved(ElementValueEvent e) throws Exception;
  
  }
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/constrained/ElementValueEvent.java
  
  Index: ElementValueEvent.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.transformation.constrained;
  
  
  import java.util.EventObject;
  import org.xml.sax.Attributes;
  
  
  /**
   *
   * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a> 
   */
  public class ElementValueEvent extends ContainerElementEndEvent {
  
      private String     elementValue;
      private Attributes elementAttributes;
  
      public ElementValueEvent(
              Object source, String elementName, String elementValue,
              Attributes elementAttributes) {
  
          super(source, elementName);
  
          this.elementValue      = elementValue;
          this.elementAttributes = elementAttributes;
      }
  
  
  
      public String getElementValue() {
          return elementValue;
      }
  
      public Attributes getAttributes() {
          return elementAttributes;
      }
  
      public String getAttribute(String attributeName) {
          return elementAttributes.getValue(attributeName).toString();
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/constrained/XmlTreeConstraint.java
  
  Index: XmlTreeConstraint.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.transformation.constrained;
  
  
  
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.ListIterator;
  
  
  /**
   *
   * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a> 
   */
  public class XmlTreeConstraint {
  
      private boolean debug=true;
  
      private Boolean   isMyUriRequired;
      private ArrayList allowedMyUriStackEnd  = null;
      private ArrayList allowedGlobalStackEnd = null;
  
      public XmlTreeConstraint(ArrayList allowedMyUriStackEnd,
                               ArrayList allowedGlobalStackEnd,
                               Boolean isMyUriRequired) {
  
          this.allowedMyUriStackEnd  = allowedMyUriStackEnd;
          this.allowedGlobalStackEnd = allowedGlobalStackEnd;
          this.isMyUriRequired       = isMyUriRequired;
      }
  
      public XmlTreeConstraint(ArrayList allowedMyUriStackEnd,
                               Boolean isMyUriRequired) {
          this.allowedMyUriStackEnd = allowedMyUriStackEnd;
          this.isMyUriRequired      = isMyUriRequired;
      }
  
      public XmlTreeConstraint(ArrayList allowedMyUriStackEnd) {
          this.allowedMyUriStackEnd = allowedMyUriStackEnd;
      }
  
      public XmlTreeConstraint(String[] allowedMyUriStackEnd,
                               String[] allowedGlobalStackEnd,
                               boolean isMyUriRequired) {
  
          this.allowedMyUriStackEnd  = new ArrayList(Arrays.asList(allowedMyUriStackEnd));
          this.allowedGlobalStackEnd = new ArrayList(Arrays.asList(allowedGlobalStackEnd));
          this.isMyUriRequired       = new Boolean(isMyUriRequired);
      }
  
      public XmlTreeConstraint(String[] allowedMyUriStackEnd,
                               boolean isMyUriRequired) {
          this.allowedMyUriStackEnd = new ArrayList(Arrays.asList(allowedMyUriStackEnd));
          this.isMyUriRequired      = new Boolean(isMyUriRequired);
      }
  
      public XmlTreeConstraint(String[] allowedMyUriStackEnd) {
          this.allowedMyUriStackEnd = new ArrayList(Arrays.asList(allowedMyUriStackEnd));
      }
  
  
      public boolean isAllowed(Boolean isMyUri, ArrayList myUriStack,
                               ArrayList globalStack) {
     if(debug){
          System.out.println("isMyUri :"+isMyUri+"\nrequired uri "+isMyUriRequired);
          System.out.println("myUristack: \n"+myUriStack);
          System.out.println("allowedMyUriStackEnd: \n"+allowedMyUriStackEnd);
          System.out.println("globalstack: \n"+globalStack);
          System.out.println("allowedGlobalStackEnd: \n"+allowedGlobalStackEnd);
          }
          if (isMyUriRequired != null) {
              if (isMyUri == null) {
                  return false;
              }
  
              if (!isMyUriRequired.equals(isMyUri)) {
                  return false;
              }
          }
  
          if (allowedMyUriStackEnd != null) {
              if (myUriStack == null) {
                  return false;
              }
  
              if (!areEndsEqual(allowedMyUriStackEnd, myUriStack)) {
                  return false;
              }
          }
  
          if (allowedGlobalStackEnd != null) {
              if (globalStack == null) {
                  return false;
              }
  
              if (!areEndsEqual(allowedGlobalStackEnd, globalStack)) {
                  return false;
              }
          }
  
          return true;
      }
  
      private boolean areEndsEqual(ArrayList l1, ArrayList l2) {
  
          if (l1.size() > l2.size()) {
              if ((!(l1.size() == l2.size()))
                      && ((l1.size() < 1) || (l2.size() < 1))) {
                  return false;
              }
  
              //make l1 smaller
              ArrayList l3 = l1;
  
              l1 = l2;
              l2 = l3;
          }
  
          ListIterator iter1 = l1.listIterator(l1.size());
          ListIterator iter2 = l2.listIterator(l2.size());
  
          while (iter1.hasPrevious()) {
              if (!(((String) iter1.previous().toString())
                      .equals(iter2.previous().toString()))) {
  
                  //System.out.println("ends are NOT equal.");
                  return false;
              }
          }
  
          //System.out.println("ends are equal.");
          return true;
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/webapp/mount/charts/content/static/bar3Dchart.xml
  
  Index: bar3Dchart.xml
  ===================================================================
  <?xml version="1.0"?>
  <chart:chartdef xmlns:chart="http://apache.org/cocoon/Chart2Svg">
  <chart:appearance>
        <chart:type>bar</chart:type>
        <chart:title>Cocoon 1 vs Cocoon 2 :)</chart:title>
   <chart:LF3d/>  
        <chart:colors>
           <chart:color>#ffffff</chart:color>
           <chart:color>#666666</chart:color>
        </chart:colors>
        <chart:width>400</chart:width>
        <chart:height>280</chart:height>
     </chart:appearance>
    <chart:properties>
     <chart:min>0</chart:min>
      <chart:max>7</chart:max>
     </chart:properties>
     <chart:data>
        <result>
           <row>
              <cocoon1>1</cocoon1>
              <cocoon2>3</cocoon2>
              <cocoon3>5</cocoon3>
           </row>
           <row>
              <cocoon1>2</cocoon1>
              <cocoon2>6</cocoon2>
              <cocoon3>3</cocoon3>
           </row>
           <row>
              <cocoon1>2</cocoon1>
              <cocoon2>6</cocoon2>
              <cocoon3>5</cocoon3>
           </row>
           <row>
              <cocoon1>2</cocoon1>
              <cocoon2>6</cocoon2>
              <cocoon3>3</cocoon3>
           </row>
        </result>
    </chart:data>
  </chart:chartdef>
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/webapp/mount/charts/content/static/barchart.xml
  
  Index: barchart.xml
  ===================================================================
  <?xml version="1.0"?>
  <chart:chartdef xmlns:chart="http://apache.org/cocoon/Chart2Svg">
  <chart:appearance>
        <chart:type>bar</chart:type>
        <chart:title>Cocoon 1 vs Cocoon 2 :)</chart:title>
  
        <chart:colors>
           <chart:color>#ffffff</chart:color>
           <chart:color>#666666</chart:color>
        </chart:colors>
        <chart:width>400</chart:width>
        <chart:height>280</chart:height>
     </chart:appearance>
    <chart:properties>
     <chart:min>0</chart:min>
      <chart:max>7</chart:max>
     </chart:properties>
     <chart:data>
        <result>
           <row>
              <cocoon1>1</cocoon1>
              <cocoon2>3</cocoon2>
              <cocoon3>5</cocoon3>
           </row>
           <row>
              <cocoon1>2</cocoon1>
              <cocoon2>6</cocoon2>
              <cocoon3>3</cocoon3>
           </row>
           <row>
              <cocoon1>2</cocoon1>
              <cocoon2>6</cocoon2>
              <cocoon3>5</cocoon3>
           </row>
           <row>
              <cocoon1>2</cocoon1>
              <cocoon2>6</cocoon2>
              <cocoon3>3</cocoon3>
           </row>
        </result>
    </chart:data>
  </chart:chartdef>
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/webapp/mount/charts/content/static/linechart.xml
  
  Index: linechart.xml
  ===================================================================
  <?xml version="1.0"?>
  <chart:chartdef xmlns:chart="http://apache.org/cocoon/Chart2Svg">
  <chart:appearance>
        <chart:type>line</chart:type>
        <chart:title>Cocoon 1 vs Cocoon 2 :)</chart:title>
        <chart:colors>
           <chart:color>#ffffff</chart:color>
           <chart:color>#666666</chart:color>
        </chart:colors>
        <chart:width>400</chart:width>
        <chart:height>280</chart:height>
     </chart:appearance>
    <chart:properties>
     <chart:min>0</chart:min>
      <chart:max>7</chart:max>
     </chart:properties>
     <chart:data>
        <result>
           <row>
              <cocoon1>1</cocoon1>
              <cocoon2>3</cocoon2>
              <cocoon3>5</cocoon3>
           </row>
           <row>
              <cocoon1>2</cocoon1>
              <cocoon2>6</cocoon2>
              <cocoon3>3</cocoon3>
           </row>
           <row>
              <cocoon1>2</cocoon1>
              <cocoon2>6</cocoon2>
              <cocoon3>5</cocoon3>
           </row>
           <row>
              <cocoon1>2</cocoon1>
              <cocoon2>6</cocoon2>
              <cocoon3>3</cocoon3>
           </row>
        </result>
    </chart:data>
  </chart:chartdef>
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/webapp/mount/charts/content/static/testapplet.xml
  
  Index: testapplet.xml
  ===================================================================
  <?xml version="1.0"?>
  <xapplet:applet2svg xmlns:xapplet="http://apache.org/cocoon/Applet2Svg">
   <applet width="400" height="400" code="org.apache.cocoon.transformation.chart.TestAppklet.class"/>
  </xapplet:applet2svg>
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/Chart2SvgTransformer.java
  
  Index: Chart2SvgTransformer.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.transformation;
  
  import java.io.IOException;
  
  import org.apache.avalon.framework.parameters.Parameters;
  
  import org.apache.cocoon.environment.SourceResolver;
  
  import org.apache.cocoon.transformation.constrained.*;
  
  import java.util.TooManyListenersException;
  import java.util.ArrayList;
  import java.util.Arrays;
  
  import java.util.Map;
  
  import java.awt.Color;
  
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  
  import org.krysalis.wings.*;
  
  
  /**
   * This Transformer transforms XML that describes a chart into an SVG
   * representation.
   * See Cocoon examples for implicit DTD.
   *
   * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a>
   */
  public class Chart2SvgTransformer extends AbstractConstrainedTransformer {
  
      private String        originalPrefix = "unknown";
      private boolean       minSet         = false;
      private boolean       maxSet         = false;
      private ChartModel2D  cm             = new ChartModel2D();
      private String        type           = "";
      private String        title          = "";
      private AbstractChart c;
      private ColorList     cl = new ColorList();
      private double        min;
      private double        max;
      private boolean       LF3D   = false;
      private int           width  = 320;
      private int           height = 200;
  
      public String getUri() {
          return "http://apache.org/cocoon/chart2svg";
      }
  
      public String getName() {
          return "chart2svg";
      }
  
      public void setup(SourceResolver resolver, Map map, String string, Parameters parameters)
      {
  
      }
  
      public void init(Parameters parameters) {
  
              String[] chartdefStack = { "chartdef" };
  
              addEventListener(new ElementEventAdapter() {
  
                  public void containerElementEnded(ContainerElementEndEvent e)
                          throws SAXException {
  
                      if (minSet) {
                          cm.setMin(min);
                      }
  
                      if (maxSet) {
                          cm.setMax(max);
                      }
  
                      if (type.trim().equals("bar")) {
                          c = new BarChart(cm);
  
                          ((BarChart) c).set3DLF(LF3D);
                      }
                       else if (type.trim().equals("pie")) {
                          c = new PieChart(cm);
                      }
                       else {
                          c = new LineChart(cm);
                      }
  
                      c.setTitle(title);
                      c.setColorList(cl);
                      c.setSize(width, height);
  
                      SVGGraphics svg = new SVGGraphics(Chart2SvgTransformer.super.contentHandler, width,
                                                        height);
                      svg.startEvents();
                      c.paint(svg);
                      svg.stopEvents();
  
  
                  }
              }, new XmlTreeConstraint(chartdefStack, true));
  
              String[] typeStack = { "type" };
  
              addEventListener(new ElementEventAdapter() {
  
                  public void elementValueRecieved(ElementValueEvent e) {
                      type = e.getElementValue();
                  }
              }, new XmlTreeConstraint(typeStack, true));
  
              String[] titleStack = { "title" };
  
              addEventListener(new ElementEventAdapter() {
  
                  public void elementValueRecieved(ElementValueEvent e) {
                      title = e.getElementValue();
                  }
              }, new XmlTreeConstraint(titleStack, true));
  
              String[] LF3dStack = { "LF3d" };
  
              addEventListener(new ElementEventAdapter() {
  
                  public void elementValueRecieved(ElementValueEvent e) {
                      LF3D = true;
                  }
              }, new XmlTreeConstraint(LF3dStack, true));
  
              String[] colorStack = { "color" };
  
              addEventListener(new ElementEventAdapter() {
  
                  public void elementValueRecieved(ElementValueEvent e) {
                      cl.add(Color.decode(e.getElementValue()));
                  }
              }, new XmlTreeConstraint(colorStack, true));
  
              String[] widthStack = { "width" };
  
              addEventListener(new ElementEventAdapter() {
  
                  public void elementValueRecieved(ElementValueEvent e) {
                      width = Integer.parseInt(e.getElementValue());
                      try
                      {
                      Chart2SvgTransformer.this.start("prova");
                      Chart2SvgTransformer.this.end("prova");
                      Chart2SvgTransformer.this.data("prova data");
                      }
                      catch(Exception exx)
                      {
                        System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAA");
                      }
                  }
              }, new XmlTreeConstraint(widthStack, true));
  
              String[] heightStack = { "height" };
  
              addEventListener(new ElementEventAdapter() {
  
                  public void elementValueRecieved(ElementValueEvent e) {
                      height = Integer.parseInt(e.getElementValue());
                  }
              }, new XmlTreeConstraint(heightStack, true));
  
              String[] minStack = { "min" };
  
              addEventListener(new ElementEventAdapter() {
  
                  public void elementValueRecieved(ElementValueEvent e) {
                      min    = Double.parseDouble(e.getElementValue().trim());
                      minSet = true;
                  }
              }, new XmlTreeConstraint(minStack, true));
  
              String[] maxStack = { "max" };
  
              addEventListener(new ElementEventAdapter() {
  
                  public void elementValueRecieved(ElementValueEvent e) {
                      max    = Double.parseDouble(e.getElementValue().trim());
                      maxSet = true;
                  }
              }, new XmlTreeConstraint(maxStack, true));
  
              String[] dataStack = { "data" };
  
              addEventListener(new DataListener(),
                                           new XmlTreeConstraint(dataStack,
                                               false));
              addEventListener(new RipperListener(),
                                           new XmlTreeConstraint(dataStack,
                                               true));
  
              String[] appearanceStack = { "appearance" };
  
              addEventListener(
                  new RipperListener(),
                  new XmlTreeConstraint(appearanceStack, true));
  
              String[] propertiesStack = { "properties" };
  
              addEventListener(
                  new RipperListener(),
                  new XmlTreeConstraint(propertiesStack, true));
  
              String[] colorsStack = { "colors" };
  
              addEventListener(new RipperListener(),
                                           new XmlTreeConstraint(colorsStack,
                                               true));
  
      }
  
  
      class DataListener extends ElementEventAdapter {
  
          public void elementValueRecieved(ElementValueEvent e)
                  throws SAXException {
              cm.addToRow(e.getElementName(),
                          Double.parseDouble(e.getElementValue()));
          }
      }
  
  }
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/lib/krysalis-wings-0.1.0-dev-2.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/src/scratchpad/lib/LICENSE.krysalis-wings
  
  Index: LICENSE.krysalis-wings
  ===================================================================
  /*
  The Krysalis Patchy Software License, Version 1.1_01
  Copyright (c) 2002 Nicola Ken Barozzi.  All rights reserved.
  
  This Licence is compatible with the BSD licence as described and 
  approved by http://www.opensource.org/, and is based on the
  Apache Software Licence Version 1.1.
  
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:
  
   1. Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
  
  2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
     distribution.
  
  3. The end-user documentation included with the redistribution,
     if any, must include the following acknowledgment:
        "This product includes software developed for project 
         Krysalis (http://www.krysalis.org/)."
     Alternately, this acknowledgment may appear in the software itself,
     if and wherever such third-party acknowledgments normally appear.
  
  4. The names "Krysalis" and "Nicola Ken Barozzi" and
     "Krysalis Centipede" must not be used to endorse or promote products
     derived from this software without prior written permission. For
     written permission, please contact krysalis@nicolaken.org.
     
  5. Products derived from this software may not be called "Krysalis",
     "Krysalis Centipede", nor may "Krysalis" appear in their name,
     without prior written permission of Nicola Ken Barozzi.
  
  6. This software may contain voluntary contributions made by many 
     individuals, who decided to donate the code to this project in
     respect of this licence.
  
  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  DISCLAIMED.  IN NO EVENT SHALL THE KRYSALIS PROJECT OR
  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  SUCH DAMAGE.
  ====================================================================*/
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/webapp/mount/charts/content/samples.xml
  
  Index: samples.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  
  <samples xmlns:xlink="http://www.w3.org/1999/xlink">
  
    <group name="This page is served by sub-sitemap!">
     <sample name="Back" href="../..">
      to Cocoon examples main page
     </sample>
    </group>
  
    
    <group name="SVG Chart samples">
     <sample name="Bar Chart" href="barchart.svg">
      This sample doesn't yet work. Still needs debugging and fixing. It used to work with an early version of Cocoon2 and currently it hasen't been completely adapted. Patches are welcome :-)
     </sample>
     <sample name="Bar Chart 3d style" href="bar3Dchart.svg">
      This sample doesn't yet work. Still needs debugging and fixing. It used to work with an early version of Cocoon2 and currently it hasen't been completely adapted. Patches are welcome :-)
     </sample>
     <sample name="Line Chart" href="line.svg">
      This sample doesn't yet work. Still needs debugging and fixing. It used to work with an early version of Cocoon2 and currently it hasen't been completely adapted. Patches are welcome :-)
     </sample>
    </group>
    
    <group name="Chart samples viewed in xml">
     <sample name="Bar Chart" href="barchart.xml">
      This sample doesn't yet work. Still needs debugging and fixing. It used to work with an early version of Cocoon2 and currently it hasen't been completely adapted. Patches are welcome :-)
     </sample>
     <sample name="Bar Chart 3d style" href="bar3Dchart.xml">
      This sample doesn't yet work. Still needs debugging and fixing. It used to work with an early version of Cocoon2 and currently it hasen't been completely adapted. Patches are welcome :-)
     </sample>
     <sample name="Line Chart" href="line.xml">
      This sample doesn't yet work. Still needs debugging and fixing. It used to work with an early version of Cocoon2 and currently it hasen't been completely adapted. Patches are welcome :-)
     </sample>
    </group>
  
  
  </samples>
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/webapp/mount/charts/stylesheets/simple-samples2html.xsl
  
  Index: simple-samples2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  <!-- Author: Nicola Ken Barozzi "barozzi@nicolaken.com" -->
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink">
  
   <xsl:template match="/">
    <html>
     <head>
      <title>Poi Cocoon Samples</title>
     </head>
     <body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
      <p align="center"><font size="+0" face="arial,helvetica,sanserif" color="#000000">Poi Cocoon samples</font></p>
  
      <xsl:apply-templates/>
  
      <p align="center">
       <font size="-1">
        Copyright &#169; 1999-2001 <a href="http://www.apache.org">poi project founders</a>.<br/>
        All rights reserved.
       </font>
      </p>
     </body>
    </html>
   </xsl:template>
  
   <xsl:template match="samples">
    <xsl:variable name="all-samples" select="count(group/sample)"/>
    <xsl:variable name="half-samples" select="round($all-samples div 2)"/>
      
    <table width="100%">
     <tr>
      <td width="50%" valign="top">
       <xsl:for-each select="group">  
        <xsl:variable name="group-position" select="position()"/>
        <xsl:variable name="current-sample" select="1 + count(../group[position() &lt;= $group-position]/sample)"/>
        <xsl:choose>
         <xsl:when test="$current-sample &lt;= $half-samples">
         <table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0" width="97%">
          <tbody>
           <tr>
            <td>
        
          <table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2" align="center" width="100%">
           <tr>
            <td bgcolor="#0086b2" width="100%" align="left">
             <font size="+1" face="arial,helvetica,sanserif" color="#ffffff"><xsl:value-of select="@name"/></font>
            </td>
           </tr>
           <tr>
            <td width="100%" bgcolor="#ffffff" align="left">
             <table bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="2"  width="100%" align="center">
              <xsl:apply-templates/>
             </table>
            </td>
           </tr>
          </table>
          
            </td>
           </tr>        
           </tbody>
          </table>
          
          <br/>
         </xsl:when>
         <xsl:otherwise></xsl:otherwise>
        </xsl:choose>
       </xsl:for-each>
      </td>
      <td valign="top">
       <xsl:for-each select="group">  <!-- [position()<=$half] -->
        <xsl:variable name="group-position" select="position()"/>
        <xsl:variable name="current-sample" select="1 + count(../group[position() &lt;= $group-position]/sample)"/>
        <xsl:choose>
         <xsl:when test="not($current-sample &lt;= $half-samples)">
         <table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0" width="97%">
          <tbody>
           <tr>
            <td>       
          <table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2" align="center" width="100%">
           <tr>
            <td bgcolor="#0086b2" width="100%" align="left">
             <font size="+1" face="arial,helvetica,sanserif" color="#ffffff"><xsl:value-of select="@name"/></font>
            </td>
           </tr>
           <tr>
            <td width="100%" bgcolor="#ffffff" align="left">
             <table bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="2"  width="100%" align="center">
              <xsl:apply-templates/>
             </table>
            </td>
           </tr>
          </table>
           </td>
           </tr>        
           </tbody>
          </table>
          <br/>
         </xsl:when>
         <xsl:otherwise></xsl:otherwise>
        </xsl:choose>
       </xsl:for-each>
      </td>
     </tr>
    </table>
   </xsl:template>
   
   <xsl:template match="sample">
    <tr>
     <td width="100%" bgcolor="#ffffff" align="left">
      <font size="+0" face="arial,helvetica,sanserif" color="#000000">    
        <a href="{@href}"><xsl:value-of select="@name"/></a><xsl:text> - </xsl:text>
        <xsl:value-of select="."/>
      </font>
     </td>
    </tr>
   </xsl:template>
   
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/webapp/mount/charts/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  <?xml version="1.0"?>
  <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  
   <map:components>
   
    <map:generators default="file"/>
    
    <map:transformers default="xslt">
     <map:transformer name="chart2svg" src="org.apache.cocoon.transformation.Chart2SvgTransformer"/>
    </map:transformers>
    
    <map:readers default="resource"/>
    
    <map:serializers default="html">
       <map:serializer name="svgxml" mime-type="image/svg-xml"    logger="sitemap.serializer.svgxml"
                     src="org.apache.cocoon.serialization.XMLSerializer">
      <doctype-public>-//W3C//DTD SVG 20000303 Stylable//EN</doctype-public>
      <doctype-system>http://www.w3.org/TR/2000/03/WD-SVG-20000303/</doctype-system>
     </map:serializer>
    </map:serializers>
    
    <map:matchers default="wildcard"/>
    
    <map:selectors default="browser"/>
    
   </map:components>
  
   <map:pipelines>
    <map:pipeline>
    
     <map:match pattern="">
      <map:redirect-to uri="welcome"/>
     </map:match>
  
     <map:match pattern="welcome">
      <map:generate src="content/samples.xml"/>
      <map:transform src="stylesheets/simple-samples2html.xsl"/>
      <map:serialize/>
     </map:match>
     
     <map:match pattern="*chart.xml">
      <map:generate src="content/static/{1}chart.xml"/>
      <map:transform type="chart2svg"/>
      <map:serialize type="xml"/>
     </map:match>
     
     <map:match pattern="*chart.svg">
      <map:generate src="content/static/{1}chart.xml"/>
      <map:transform type="chart2svg"/>
      <map:serialize type="svgxml"/>
     </map:match>
  
     <map:match pattern="*chart.source.xml">
      <map:generate src="content/static/{1}chart.xml"/>
      <map:serialize type="xml"/>
     </map:match>   
     
     <!-- ========================= Server ================================ -->
  
     <map:match pattern="sites/styles/**.css">
      <map:read src="resources/styles/{1}.css" mime-type="text/css"/>
     </map:match>
  
     <map:match pattern="images/**.gif">
      <map:read src="resources/images/{1}.gif" mime-type="image/gif"/>
     </map:match>
  
     <map:match pattern="images/**.jpg">
      <map:read src="resources/images/{1}.jpg" mime-type="image/jpg"/>
     </map:match>
  
     <map:match pattern="images/**.png">
      <map:read src="resources/images/{1}.png" mime-type="image/png"/>
     </map:match>
  
  <!-- delegate to parent
     <map:handle-errors>
      <map:serialize status-code="500"/>
     </map:handle-errors>
  -->
    </map:pipeline>
   </map:pipelines>
  
  </map:sitemap>
  
  <!-- end of file -->
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message