cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From step...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation SourceDescriptionGenerator.java
Date Mon, 24 Jun 2002 16:26:15 GMT
stephan     2002/06/24 09:26:15

  Modified:    src/scratchpad/src/org/apache/cocoon/components/source
                        LockableSource.java RestrictableSource.java
                        VersionableSource.java
               src/scratchpad/src/org/apache/cocoon/components/source/helpers
                        SourceProperty.java
               src/scratchpad/src/org/apache/cocoon/components/source/impl
                        SlideSource.java
               src/scratchpad/src/org/apache/cocoon/generation
                        SourceDescriptionGenerator.java
  Added:       src/scratchpad/src/org/apache/cocoon/components/source
                        SourceInspector.java TraversableSource.java
               src/scratchpad/src/org/apache/cocoon/components/source/impl
                        XPathSourceInspector.java
  Removed:     src/scratchpad/src/org/apache/cocoon/components/source
                        BrowseableSource.java
  Log:
  Implementation of a replacement for the several DirectoryGenerators through
  SourceInspectors.
  Clean up the SourceProperty.
  Renamed the BrowseableSource to TraversableSource, also added the method getParent
  to this Interface.
  
  Revision  Changes    Path
  1.2       +2 -2      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/LockableSource.java
  
  Index: LockableSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/LockableSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LockableSource.java	21 Jun 2002 13:39:42 -0000	1.1
  +++ LockableSource.java	24 Jun 2002 16:26:14 -0000	1.2
  @@ -65,7 +65,7 @@
   /**
    * A source, which could be locked
    *
  - * @author <a href="mailto:stephan@vern.chem.tu-berlin.de">Stephan Michels</a>
  + * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
    * @version $Id$
    */
   public interface LockableSource extends Source {
  
  
  
  1.2       +2 -2      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/RestrictableSource.java
  
  Index: RestrictableSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/RestrictableSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RestrictableSource.java	21 Jun 2002 13:39:42 -0000	1.1
  +++ RestrictableSource.java	24 Jun 2002 16:26:14 -0000	1.2
  @@ -63,7 +63,7 @@
   /**
    * A source, which is restrictable, which means you need a username and password.
    *
  - * @author <a href="mailto:stephan@vern.chem.tu-berlin.de">Stephan Michels</a>
  + * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
    * @version $Id$
    */
   public interface RestrictableSource extends Source {
  
  
  
  1.2       +2 -2      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/VersionableSource.java
  
  Index: VersionableSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/VersionableSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- VersionableSource.java	21 Jun 2002 13:39:43 -0000	1.1
  +++ VersionableSource.java	24 Jun 2002 16:26:15 -0000	1.2
  @@ -61,7 +61,7 @@
   /**
    * A source, which could exist in different versions
    *
  - * @author <a href="mailto:stephan@vern.chem.tu-berlin.de">Stephan Michels</a>
  + * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
    * @version $Id$
    */
   public interface VersionableSource extends Source {
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/SourceInspector.java
  
  Index: SourceInspector.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * 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 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 (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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cocoon.components.source;
  
  import org.apache.avalon.framework.component.Component;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  
  import org.apache.cocoon.components.source.helpers.SourceProperty;
  
  /**
   * A source inspector helps to get properties from sources
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
   * @version $Id: SourceInspector.java,v 1.1 2002/06/24 16:26:14 stephan Exp $
   */
  public interface SourceInspector extends Component {
  
      public final static String ROLE = "org.apache.cocoon.components.source.SourceInspector";
  
      public SourceProperty getSourceProperty(Source source, String namespace, String name)

          throws SourceException;
  
      public SourceProperty[] getSourceProperties(Source source) throws SourceException;
  
  }
  
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/TraversableSource.java
  
  Index: TraversableSource.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * 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 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 (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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cocoon.components.source;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  
  import java.util.Enumeration;
  
  /**
   * A source, which can a directory or collection of sources.
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
   * @version $Id: TraversableSource.java,v 1.1 2002/06/24 16:26:15 stephan Exp $
   */
  public interface TraversableSource extends Source {
  
      /** 
       * If the source a directory or a collection
       */
      public boolean isSourceCollection() throws SourceException;
  
      /**
       * Returns the count of child sources.
       */
      public int getChildSourceCount()  throws SourceException;
  
      /**
       * Return the system id of a child source.
       *
       * @param index Index of the child
       */
      public String getChildSource(int index)  throws SourceException;
  
      /**
       * Return the system if of the parent source. The method should return
       * null if the source hasn't a parent. 
       */
      public String getParent();
  }
  
  
  
  
  1.2       +65 -15    xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/helpers/SourceProperty.java
  
  Index: SourceProperty.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/helpers/SourceProperty.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceProperty.java	21 Jun 2002 13:39:43 -0000	1.1
  +++ SourceProperty.java	24 Jun 2002 16:26:15 -0000	1.2
  @@ -55,10 +55,17 @@
   
   package org.apache.cocoon.components.source.helpers;
   
  +import org.apache.avalon.excalibur.xml.XMLizable;
  +
   import org.apache.cocoon.xml.dom.DOMBuilder;
  +import org.apache.cocoon.xml.dom.DOMStreamer;
  +
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
   
  +import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
   
  @@ -66,10 +73,10 @@
   /**
    * This interface for a property of a source
    *
  - * @author <a href="mailto:stephan@vern.chem.tu-berlin.de">Stephan Michels</a>
  + * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
    * @version $Id$
    */
  -public class SourceProperty {
  +public class SourceProperty implements XMLizable {
   
       private String namespace;
       private String name;
  @@ -94,12 +101,17 @@
        * @param name The name of the property
        * @param value The value of the property
        */
  -    /*public SourceProperty(String namespace, String name, String value) {
  +    public SourceProperty(String namespace, String name, String value) {
           this.namespace = namespace;
           this.name      = name;
  -        this.value     = value;
  -    }*/
  +        setValue(value);
  +    }
   
  +    /**
  +     * Creates a new property for a source
  +     *
  +     * @param property The property in DOM representation
  +     */
       public SourceProperty(Element property) {
           this.namespace = property.getNamespaceURI();
           this.name = property.getLocalName();
  @@ -154,6 +166,9 @@
               DOMBuilder builder = new DOMBuilder();
               builder.startDocument();
               builder.startElement(namespace, name, name, new AttributesImpl());
  +
  +            builder.characters(value.toCharArray(), 0, value.length());
  +
               builder.endElement(namespace, name, name);
               builder.endDocument();
   
  @@ -169,9 +184,17 @@
        * 
        * @return Value of the property
        */
  -    /*public String getValueAsString() {
  -        return this.value;
  -    }*/
  +    public String getValueAsString() {
  +
  +        NodeList nodeslist = this.value.getChildNodes();
  +        StringBuffer buffer = new StringBuffer();
  +        for(int i=0; i<nodeslist.getLength(); i++)
  +            if ((nodeslist.item(i).getNodeType()==Node.TEXT_NODE) || 
  +                (nodeslist.item(i).getNodeType()==Node.CDATA_SECTION_NODE))
  +                buffer.append(nodeslist.item(i).getNodeValue());
  +
  +        return buffer.toString();
  +    }
   
       /**
        * Sets the value of the property
  @@ -185,15 +208,42 @@
       }
   
       /**
  -     * Returns the value of the property
  -     * 
  -     * @return Value of the property
  +     * Sets the value of the property
  +     *
  +     * @param value Value of the property
        */
  -    /*public String getValueAsElement() {
  -        return this.value;
  -    }*/
  +    public void setValue(NodeList values) {
  +        try {
  +            DOMBuilder builder = new DOMBuilder();
  +            builder.startDocument();
  +            builder.startElement(namespace, name, name, new AttributesImpl());
  +
  +            DOMStreamer stream = new DOMStreamer(builder);
  +             for (int i = 0; i < values.getLength(); i++)
  +               stream.stream(values.item(i));
  +
  +            builder.endElement(namespace, name, name);
  +            builder.endDocument();
  +
  +            Document doc = builder.getDocument();
  +            this.value = doc.getDocumentElement();
  +        } catch (SAXException se) {
  +            // do nothing
  +        }
  +    }
   
       public Element getValue() {
           return this.value;
  +    }
  +
  +    /**
  +     * 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 org.apache.cocoon.xml.XMLConsumer}
that accepts such
  +     * events.
  +     */
  +    public void toSAX(ContentHandler handler) throws SAXException {
  +        DOMStreamer stream = new DOMStreamer(handler);
  +        stream.stream(this.value);
       }
   }
  
  
  
  1.3       +17 -3     xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/SlideSource.java
  
  Index: SlideSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/SlideSource.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SlideSource.java	22 Jun 2002 18:00:01 -0000	1.2
  +++ SlideSource.java	24 Jun 2002 16:26:15 -0000	1.3
  @@ -67,10 +67,10 @@
   import org.apache.avalon.framework.thread.ThreadSafe;
   
   import org.apache.cocoon.Constants;
  -import org.apache.cocoon.components.source.BrowseableSource;
   import org.apache.cocoon.components.source.InspectableSource;
   import org.apache.cocoon.components.source.LockableSource;
   import org.apache.cocoon.components.source.RestrictableSource;
  +import org.apache.cocoon.components.source.TraversableSource;
   import org.apache.cocoon.components.source.WriteableSource;
   import org.apache.cocoon.components.source.VersionableSource;
   import org.apache.cocoon.components.source.helpers.SourceCredential;
  @@ -131,7 +131,7 @@
    * @version $Id$
    */
   public class SlideSource extends AbstractLoggable implements 
  -      Source, WriteableSource, BrowseableSource, RestrictableSource, 
  +      Source, WriteableSource, TraversableSource, RestrictableSource, 
         LockableSource/*, InspectableSource*/, VersionableSource {
   
       /** Component manager */
  @@ -518,6 +518,20 @@
           } catch (SlideException se) {
               throw new SourceException("Could not get children", se);
           }
  +    }
  +
  +    /**
  +     * Return the system if of the parent source. The method should return
  +     * null if the source hasn't a parent. 
  +     */
  +    public String getParent() {
  +        if ((this.uri==null) || (this.uri.length()<=1))
  +            return null;
  +
  +        if (this.uri.endsWith("/"))
  +           return this.uri.substring(0, this.uri.substring(0,this.uri.length()-1).lastIndexOf("/"));
  +
  +        return this.uri.substring(0, this.uri.lastIndexOf("/"));
       }
   
       /** 
  
  
  
  1.1                  xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/XPathSourceInspector.java
  
  Index: XPathSourceInspector.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * 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 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 (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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cocoon.components.source.impl;
  
  import org.apache.avalon.excalibur.xml.Parser;
  import org.apache.avalon.excalibur.xml.xpath.XPathProcessor;
  
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.logger.AbstractLoggable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  
  import org.apache.cocoon.components.source.SourceInspector;
  import org.apache.cocoon.components.source.helpers.SourceProperty;
  
  import org.w3c.dom.Document;
  import org.w3c.dom.NodeList;
  
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  import java.io.IOException;
  
  /**
   * This source inspector inspects XML files with a xpath expression
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
   * @version $Id: XPathSourceInspector.java,v 1.1 2002/06/24 16:26:15 stephan Exp $
   */
  public class XPathSourceInspector extends AbstractLoggable implements 
      SourceInspector, ThreadSafe, Parameterizable {
  
      private String propertynamespace = "http://xml.apache.org/cocoon/XPathSourceInspector";
      private String propertyname = "result";
      private String extension = null;
      private String xpath = null;
  
      private ComponentManager manager = null;
  
      public void compose(ComponentManager manager) {
          this.manager = manager;
      }
  
      public void parameterize(Parameters params)  {
          this.propertynamespace = params.getParameter("namespace", 
              "http://xml.apache.org/cocoon/XPathSourceInspector");
          this.propertyname = params.getParameter("name", "result");
          this.extension = params.getParameter("extension", ".xml");
          this.xpath = params.getParameter("xpath", "/*");
      }
  
      public SourceProperty getSourceProperty(Source source, String namespace, String name)

          throws SourceException {
  
          if ((namespace.equals(propertynamespace)) && (name.equals(propertyname))
&& 
              (source.getSystemId().endsWith(extension))) {
  
              Parser parser = null;
              Document doc = null;
              try { 
                  parser = (Parser)manager.lookup(Parser.ROLE);
  
                  doc = parser.parseDocument(new InputSource(source.getInputStream()));
              } catch (SAXException se) {
                  this.getLogger().error(source.getSystemId()
                                          + " is not a valid XML file");
              } catch (IOException ioe) {
                  this.getLogger().error("Could not read file", ioe);
              } catch (ComponentException ce) {
                  this.getLogger().error("Could not retrieve component", ce);
              } finally {
                  if (parser!=null)
                      this.manager.release(parser);
              }
  
              if (doc != null) {
  
                  XPathProcessor processor = null;
                  try {
                      processor = (XPathProcessor)manager.lookup(XPathProcessor.ROLE);
  
                      NodeList nodelist = processor.selectNodeList(doc.getDocumentElement(),
this.xpath);
  
                      SourceProperty property = new SourceProperty(this.propertynamespace,
this.propertyname);
                      property.setValue(nodelist);
  
                      return property;
                  } catch (ComponentException ce) {
                      this.getLogger().error("Could not retrieve component", ce);
                  } finally {
                      if (processor!=null)
                          this.manager.release(processor);
                  }
              }
          } 
          return null;  
      }
  
      public SourceProperty[] getSourceProperties(Source source) throws SourceException {
  
          SourceProperty property = getSourceProperty(source, this.propertynamespace, this.propertyname);
          if (property!=null)
              return new SourceProperty[]{property};
          return null;
      }
  
  }
  
  
  
  
  1.2       +5 -5      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java
  
  Index: SourceDescriptionGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceDescriptionGenerator.java	21 Jun 2002 13:39:43 -0000	1.1
  +++ SourceDescriptionGenerator.java	24 Jun 2002 16:26:15 -0000	1.2
  @@ -65,7 +65,7 @@
   import org.apache.avalon.framework.parameters.Parameters;
   
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.components.source.BrowseableSource;
  +import org.apache.cocoon.components.source.TraversableSource;
   import org.apache.cocoon.components.source.InspectableSource;
   import org.apache.cocoon.components.source.LockableSource;
   import org.apache.cocoon.components.source.RestrictableSource;
  @@ -199,8 +199,8 @@
                   pushSourcePermissions((RestrictableSource)source);*/
               if (source instanceof LockableSource)
                   pushSourceLocks((LockableSource)source);
  -            if ((source instanceof BrowseableSource) && (deep>0))
  -                pushSourceChilds((BrowseableSource)source, deep);
  +            if ((source instanceof TraversableSource) && (deep>0))
  +                pushSourceChilds((TraversableSource)source, deep);
               this.contentHandler.endElement(RDF_NS, DESCRIPTION_NODE_NAME, RDF_PREFIX+':'+DESCRIPTION_NODE_NAME);
           } catch (SAXException saxe) {
               throw saxe;
  @@ -209,7 +209,7 @@
           }
       }
   
  -    private void pushSourceChilds(BrowseableSource source, int deep) 
  +    private void pushSourceChilds(TraversableSource source, int deep) 
           throws SAXException, SourceException, ProcessingException, IOException {
   
           if (source.isSourceCollection()) {
  
  
  

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