You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2001/08/24 12:03:46 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon/xml XMLizable.java XMLFragment.java

sylvain     01/08/24 03:03:46

  Modified:    src/org/apache/cocoon/acting ServerPagesAction.java
               src/org/apache/cocoon/components/language/markup/xsp
                        XSPObjectHelper.java
               src/org/apache/cocoon/components/sax
                        XMLByteStreamFragment.java
               src/org/apache/cocoon/xml XMLFragment.java
  Added:       src/org/apache/cocoon/xml XMLizable.java
  Log:
  Added XMLizable, a SAX-only version of XMLFragment
  
  Revision  Changes    Path
  1.5       +3 -3      xml-cocoon2/src/org/apache/cocoon/acting/ServerPagesAction.java
  
  Index: ServerPagesAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/acting/ServerPagesAction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServerPagesAction.java	2001/08/22 12:03:32	1.4
  +++ ServerPagesAction.java	2001/08/24 10:03:45	1.5
  @@ -32,14 +32,14 @@
    * This action works in concert with the "action" logicheet, that offers
    * actions-related services such as redirect or result map access, and the
    * "capture" logicsheet that allows to capture parts of XSP-generated XML
  - * either as an <code>XMLFragment</code> containing serialized SAX events,
  + * either as an <code>XMLizable</code> containing serialized SAX events,
    * or as a DOM <code>Node</code>.<br/>
    *
    * As for generators, the XSP file name is set using the "src" attribute.<br/>
    *
    * This action accepts a single parameter, "output-attribute", which names
    * the request attribute where the XSP-generated document will be stored
  - * (as an <code>XMLFragment</code>). If this parameter is omitted, the
  + * (as an <code>XMLizable</code>). If this parameter is omitted, the
    * XSP result is discarded (often the case when inner fragments are captured
    * with the "capture" logicsheet").<br/>
    *
  @@ -59,7 +59,7 @@
    * </pre>
    *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  - * @version CVS $Revision: 1.4 $ $Date: 2001/08/22 12:03:32 $
  + * @version CVS $Revision: 1.5 $ $Date: 2001/08/24 10:03:45 $
    */
   public class ServerPagesAction extends ConfigurableComposerAction implements Disposable, ThreadSafe {
       
  
  
  
  1.4       +32 -8     xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPObjectHelper.java
  
  Index: XSPObjectHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPObjectHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSPObjectHelper.java	2001/08/20 13:55:11	1.3
  +++ XSPObjectHelper.java	2001/08/24 10:03:45	1.4
  @@ -8,6 +8,7 @@
   package org.apache.cocoon.components.language.markup.xsp;
   
   import org.apache.cocoon.xml.XMLFragment;
  +import org.apache.cocoon.xml.XMLizable;
   import org.apache.cocoon.xml.dom.DOMStreamer;
   import org.w3c.dom.Node;
   import org.xml.sax.ContentHandler;
  @@ -23,7 +24,7 @@
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="sylvain.wallez@anyware-tech.com">Sylvain Wallez</a>
    *         (Cocoon1 <code>xspExpr()</code> methods port)
  - * @version CVS $Revision: 1.3 $ $Date: 2001/08/20 13:55:11 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/08/24 10:03:45 $
    */
   public class XSPObjectHelper {
     /**
  @@ -253,14 +254,30 @@
       }
     }
   
  +// Now handled by XMLizable
  +//  /**
  +//   * Implementation of &lt;xsp:expr&gt; for <code>XMLFragment</code> :
  +//   * outputs the value by calling <code>v.toSax(contentHandler)</code>.
  +//   *
  +//   * @param contentHandler the SAX content handler
  +//   * @param v the XML fragment
  +//   */
  +//  public static void xspExpr(ContentHandler contentHandler, XMLFragment v) throws SAXException
  +//  {
  +//    if (v != null)
  +//    {
  +//      v.toSAX(contentHandler);
  +//    }
  +//  }
  +
     /**
  -   * Implementation of &lt;xsp:expr&gt; for <code>XMLFragment</code> :
  +   * Implementation of &lt;xsp:expr&gt; for <code>XMLizable</code> :
      * outputs the value by calling <code>v.toSax(contentHandler)</code>.
      *
      * @param contentHandler the SAX content handler
      * @param v the XML fragment
      */
  -  public static void xspExpr(ContentHandler contentHandler, XMLFragment v) throws SAXException
  +  public static void xspExpr(ContentHandler contentHandler, XMLizable v) throws SAXException
     {
       if (v != null)
       {
  @@ -335,13 +352,20 @@
       }
   
       // Check handled object types in case they were not typed in the XSP
  -
  -    // XMLFragment
  -    if (v instanceof XMLFragment)
  +    
  +    // XMLizable
  +    if (v instanceof XMLizable)
       {
  -      xspExpr(contentHandler, (XMLFragment)v);
  -      return;
  +        xspExpr(contentHandler, (XMLizable)v);
       }
  +
  +// Now handled by XMLizable
  +//    // XMLFragment
  +//    if (v instanceof XMLFragment)
  +//    {
  +//      xspExpr(contentHandler, (XMLFragment)v);
  +//      return;
  +//    }
   
       // Node
       if (v instanceof Node)
  
  
  
  1.3       +4 -4      xml-cocoon2/src/org/apache/cocoon/components/sax/XMLByteStreamFragment.java
  
  Index: XMLByteStreamFragment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/sax/XMLByteStreamFragment.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLByteStreamFragment.java	2001/08/20 13:55:12	1.2
  +++ XMLByteStreamFragment.java	2001/08/24 10:03:45	1.3
  @@ -7,21 +7,21 @@
    *****************************************************************************/
   package org.apache.cocoon.components.sax;
   
  -import org.apache.cocoon.xml.AbstractSAXFragment;
  +import org.apache.cocoon.xml.XMLizable;
   import org.apache.cocoon.xml.EmbeddedXMLPipe;
   import org.apache.cocoon.xml.XMLConsumer;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
   
   /**
  - * An XMLByteStream wrapped by an XMLFragment implementation. This allows to
  + * An XMLByteStream wrapped by an XMLizable implementation. This allows to
    * store SAX events and insert them in an XSP result using &lt;xsp:expr&gt;.
    *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/08/20 13:55:12 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/08/24 10:03:45 $
    */
   
  -public class XMLByteStreamFragment extends AbstractSAXFragment {
  +public class XMLByteStreamFragment implements XMLizable {
       
       /** The XML byte stream */
       private Object xmlBytes;
  
  
  
  1.3       +13 -10    xml-cocoon2/src/org/apache/cocoon/xml/XMLFragment.java
  
  Index: XMLFragment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/xml/XMLFragment.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLFragment.java	2001/05/31 16:12:47	1.2
  +++ XMLFragment.java	2001/08/24 10:03:45	1.3
  @@ -15,21 +15,24 @@
    * This interface must be implemented by classes willing
    * to provide an XML representation of their current state.
    * <br/>
  - * This class replaces the Cocoon1 <code>XObject</code> class
  - * by using the SAX2 <code>ContentHandler</code> and exists in both
  - * Cocoon1 and Cocoon2 to ensure compatibility.
  + * This interface exists in both Cocoon 1 and Cocoon 2 and to ensure
  + * a minimal compatibility between the two versions.
  + * <br/>
  + * Cocoon 2 only objects can implement the SAX-only <code>XMLizable</code>
  + * interface.
    *
    * @author <a href="mailto:sylvain.wallez@anyware-tech.com">Sylvain Wallez</a>
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a> for the original XObject class
  - * @version CVS $Revision: 1.2 $ $Date: 2001/05/31 16:12:47 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/08/24 10:03:45 $
    */
   
  -public interface XMLFragment {
  -    /**
  -     * Generates SAX events representing the object's state
  -     * for the given content handler.
  -     */
  -    void toSAX(ContentHandler handler) throws SAXException;
  +public interface XMLFragment extends XMLizable {
  +// Now inherited from XMLizable
  +//    /**
  +//     * Generates SAX events representing the object's state
  +//     * for the given content handler.
  +//     */
  +//    void toSAX(ContentHandler handler) throws SAXException;
   
       /**
        * Appends children representing the object's state to the given node.
  
  
  
  1.1                  xml-cocoon2/src/org/apache/cocoon/xml/XMLizable.java
  
  Index: XMLizable.java
  ===================================================================
  /*****************************************************************************
   * 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.xml;
  
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  
  /**
   * This interface can be implemented by classes willing to provide an XML representation
   * of their current state as SAX events.
   *
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version CVS $Revision: 1.1 $ $Date: 2001/08/24 10:03:45 $
   */
  
  public interface XMLizable {
      /**
       * Generates SAX events representing the object's state.<br/>
       * <b>NOTE</b> : if the implementation can produce lexical events, care should be taken
       * that <code>handler</code> can actually be a {@link XMLConsumer} that accepts such
       * events.
       */
      void toSAX(ContentHandler handler) throws SAXException;
      
  }
  
  
  

----------------------------------------------------------------------
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