You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2003/12/10 15:33:16 UTC

cvs commit: cocoon-2.1/src/blocks/xmldb/samples populate.xml samples.xml sitemap.xmap

vgritsenko    2003/12/10 06:33:16

  Modified:    .        status.xml
               src/blocks/xmldb/java/org/apache/cocoon/transformation
                        XMLDBTransformer.java
               src/blocks/xmldb/samples sitemap.xmap
  Added:       src/blocks/xmldb/conf xmldb.transformer.xmap
               src/blocks/xmldb/samples populate.xml samples.xml
  Log:
  Enhancements to the XMLDBTransformer: 'collection' attribute on query element,
  create collection functionality.
  Provide some basic xmldb samples.
  
  Revision  Changes    Path
  1.207     +11 -0     cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.206
  retrieving revision 1.207
  diff -u -r1.206 -r1.207
  --- status.xml	10 Dec 2003 14:22:32 -0000	1.206
  +++ status.xml	10 Dec 2003 14:33:16 -0000	1.207
  @@ -183,6 +183,17 @@
     <changes>
   
    <release version="@version@" date="@date@">
  +   <action dev="VG" type="add">
  +     In XMLDBTransformer, create operation now is able to create collections.
  +     It will create collection if oid attribute value ends with '/', otherwise
  +     it will work as before (creates XML resource)
  +   </action>
  +   <action dev="VG" type="add">
  +     Added optional collection attribute on &lt;xmldb:query/&gt; element of XMLDBTransformer.
  +     This attribute specifies collection name, relative to the transformer's base
  +     collection, which is used as base collection for current create/delete/update
  +     operation
  +   </action>
      <action dev="VG" type="remove">
        Remove deprecated XMLDB generators from the sitemap
      </action>
  
  
  
  1.1                  cocoon-2.1/src/blocks/xmldb/conf/xmldb.transformer.xmap
  
  Index: xmldb.transformer.xmap
  ===================================================================
  <?xml version="1.0"?>
  
  <xmap xpath="/sitemap/components/transformers" unless="transformer[@name='xmldb']">
  
      <map:transformer logger="sitemap.transformer.xmldb" name="xmldb" src="org.apache.cocoon.transformation.XMLDBTransformer">
        <driver>org.apache.xindice.client.xmldb.embed.DatabaseImpl</driver>
        <base>xmldb:xindice-embed:///db</base>
      </map:transformer>
  </xmap>
  
  
  
  1.8       +167 -102  cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/transformation/XMLDBTransformer.java
  
  Index: XMLDBTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/transformation/XMLDBTransformer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLDBTransformer.java	6 Oct 2003 16:07:33 -0000	1.7
  +++ XMLDBTransformer.java	10 Dec 2003 14:33:16 -0000	1.8
  @@ -73,6 +73,7 @@
   import org.xmldb.api.base.Database;
   import org.xmldb.api.base.Resource;
   import org.xmldb.api.base.XMLDBException;
  +import org.xmldb.api.modules.CollectionManagementService;
   import org.xmldb.api.modules.XUpdateQueryService;
   
   import java.io.IOException;
  @@ -93,7 +94,10 @@
   
   /**
    * This transformer allows to perform resource creation, deletion, and
  - * XUpdate command execution in XML:DB.
  + * XUpdate command execution in XML:DB. All operations are performed either
  + * in <code>base</code> collection, or context collection, which
  + * is specified as <code>collection</code> attribute on the <code>query</code>
  + * element. Context collection must be specified relative to the base collection.
    *
    * <p>Definition:</p>
    * <pre>
  @@ -103,7 +107,7 @@
    * &lt;/map:transformer&gt;
    * </pre>
    *
  - * <p>Invokation:</p>
  + * <p>Invocation:</p>
    * <pre>
    * &lt;map:transform type="xmldb"&gt;
    *   &lt;map:parameter name="base" value="xmldb:xindice:///db/collection"/&gt;
  @@ -112,39 +116,52 @@
    *
    * <p>Input XML document example:</p>
    * <pre>
  - * &lt;page xmlns:xindice="http://apache.org/cocoon/xmldb/1.0"&gt;
  + * &lt;page xmlns:xmldb="http://apache.org/cocoon/xmldb/1.0"&gt;
    *   ...
  - *   &lt;xindice:query type="create" oid="xmldb-object-id"&gt;
  + *   &lt;p&gt;Create XML resource in base collection with specified object ID&lt;/p&gt;
  + *   &lt;xmldb:query type="create" oid="xmldb-object-id"&gt;
    *     &lt;page&gt;
    *       XML Object body
    *     &lt;/page&gt;
  - *   &lt;/xindice:query&gt;
  + *   &lt;/xmldb:query&gt;
    *
  - *   &lt;xindice:query type="delete" oid="xmldb-object-id"/&gt;
  + *   &lt;p&gt;Delete XML resource from the base collection with specified object ID&lt;/p&gt;
  + *   &lt;xmldb:query type="delete" oid="xmldb-object-id"/&gt;
    *
  - *   &lt;xindice:query type="update" oid="xmldb-object-id"&gt;
  + *   &lt;p&gt;Update XML resource with specified object ID&lt;/p&gt;
  + *   &lt;xmldb:query type="update" oid="xmldb-object-id"&gt;
    *     &lt;xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate"&gt;
    *       &lt;xu:remove select="/person/phone[@type = 'home']"/&gt;
    *       &lt;xu:update select="/person/phone[@type = 'work']"&gt;
    *         480-300-3003
    *       &lt;/xu:update&gt;
    *       &lt;/xu:modifications&gt;
  - *   &lt;/xindice:query&gt;
  + *   &lt;/xmldb:query&gt;
  + *
  + *   &lt;p&gt;Create collection nested into the base collection&lt;/p&gt;
  + *   &lt;xmldb:query type="create" oid="inner/"/&gt;
  + *
  + *   &lt;p&gt;Create XML resource in context collection with specified object ID&lt;/p&gt;
  + *   &lt;xmldb:query type="create" collection="inner" oid="xmldb-object-id"&gt;
  + *     &lt;page&gt;
  + *       XML Object body
  + *     &lt;/page&gt;
  + *   &lt;/xmldb:query&gt;
    *   ...
    * &lt;/page&gt;
    * </pre>
    *
    * <p>Output XML document example:</p>
    * <pre>
  - * &lt;page xmlns:xindice="http://apache.org/cocoon/xmldb/1.0"&gt;
  + * &lt;page xmlns:xmldb="http://apache.org/cocoon/xmldb/1.0"&gt;
    *   ...
  - *   &lt;xindice:query type="create" oid="xmldb-object-id" result="success"/&gt;
  + *   &lt;xmldb:query type="create" oid="xmldb-object-id" result="success"/&gt;
    *
  - *   &lt;xindice:query type="delete" oid="xmldb-object-id" result="success"/&gt;
  + *   &lt;xmldb:query type="delete" oid="xmldb-object-id" result="success"/&gt;
    *
  - *   &lt;xindice:query type="update" oid="xmldb-object-id" result="failure"&gt;
  + *   &lt;xmldb:query type="update" oid="xmldb-object-id" result="failure"&gt;
    *     Resource xmldb-object-id is not found
  - *   &lt;/xindice:query&gt;
  + *   &lt;/xmldb:query&gt;
    *   ...
    * &lt;/page&gt;
    * </pre>
  @@ -158,11 +175,12 @@
    * @version CVS $Id$
    */
   public class XMLDBTransformer extends AbstractTransformer
  -    implements CacheableProcessingComponent, Configurable, Initializable {
  +        implements CacheableProcessingComponent, Configurable, Initializable {
   
       private static String XMLDB_URI = "http://apache.org/cocoon/xmldb/1.0";
       private static String XMLDB_QUERY_ELEMENT = "query";
       private static String XMLDB_QUERY_TYPE_ATTRIBUTE = "type";
  +    private static String XMLDB_QUERY_CONTEXT_ATTRIBUTE = "collection";
       private static String XMLDB_QUERY_OID_ATTRIBUTE = "oid";
       private static String XMLDB_QUERY_RESULT_ATTRIBUTE = "result";
   
  @@ -177,10 +195,13 @@
       private String driver = null;
   
       /** Default collection name. */
  -    private String default_base = null;
  +    private String default_base;
   
       /** Current collection name. */
  -    private String base = null;
  +    private String local_base;
  +
  +    /** Current collection name. */
  +    private String xbase;
   
       /** Current collection. */
       private Collection collection;
  @@ -191,12 +212,19 @@
       /** Document ID. Can be null if update or insert is performed on collection. */
       private String key;
   
  +    /** Result of current operation. Success or failure. */
  +    private String result;
  +
  +    /** Message in case current operation failed. */
  +    private String message;
  +
       private StringWriter queryWriter;
       private TransformerHandler queryHandler;
   
       /** True when inside &lt;query&gt; element. */
       private boolean processing;
   
  +
       public XMLDBTransformer() {
           format.put(OutputKeys.ENCODING, "utf-8");
           format.put(OutputKeys.INDENT, "no");
  @@ -204,14 +232,12 @@
       }
   
       public void configure(Configuration configuration) throws ConfigurationException {
  -        Configuration driver = configuration.getChild("driver");
  -        if (driver == null || driver.getValue() == null)
  +        this.driver = configuration.getChild("driver").getValue(null);
  +        if (driver == null) {
               throw new ConfigurationException("Required driver parameter is missing.");
  -        this.driver = driver.getValue();
  +        }
   
  -        Configuration default_base = configuration.getChild("base");
  -        if (default_base != null)
  -            this.default_base = default_base.getValue();
  +        this.default_base = configuration.getChild("base").getValue(null);
       }
   
       /**
  @@ -227,26 +253,27 @@
       public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
       throws ProcessingException, SAXException, IOException {
   
  -        this.base = par.getParameter("base", this.default_base);
  -        if (this.base == null)
  +        this.local_base = par.getParameter("base", this.default_base);
  +        if (this.local_base == null) {
               throw new ProcessingException("Required base parameter is missing. Syntax is: xmldb:xindice:///db/collection");
  +        }
   
           try {
  -            this.collection = DatabaseManager.getCollection(base);
  +            this.collection = DatabaseManager.getCollection(this.local_base);
           } catch (XMLDBException e) {
  -            throw new ProcessingException("Could not get collection " + base + ": " + e.errorCode, e);
  +            throw new ProcessingException("Could not get collection " + this.local_base + ": " + e.errorCode, e);
           }
   
  -        if(this.collection == null)
  -            throw new ResourceNotFoundException("Collection " + base + " does not exist");
  +        if (this.collection == null) {
  +            throw new ResourceNotFoundException("Collection " + this.local_base + " does not exist");
  +        }
       }
   
       /**
        * Helper for TransformerFactory.
        */
  -    protected SAXTransformerFactory getTransformerFactory()
  -    {
  -        if(tfactory == null)  {
  +    protected SAXTransformerFactory getTransformerFactory() {
  +        if (tfactory == null)  {
               tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
               tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
           }
  @@ -301,7 +328,7 @@
           if (!processing) {
               super.startPrefixMapping(prefix,uri);
               prefixMap.put(prefix,uri);
  -        } else if (this.queryHandler != null){
  +        } else if (this.queryHandler != null) {
               this.queryHandler.startPrefixMapping(prefix, uri);
           }
       }
  @@ -339,17 +366,24 @@
               if (XMLDB_URI.equals(uri) && XMLDB_QUERY_ELEMENT.equals(loc)){
   
                   this.operation = a.getValue(XMLDB_QUERY_TYPE_ATTRIBUTE);
  -                if(!"create".equals(operation) && !"delete".equals(operation) && !"update".equals(operation)) {
  -                    throw new SAXException("Supported operation types are: create, delete");
  +                if (!"create".equals(operation) && !"delete".equals(operation) && !"update".equals(operation)) {
  +                    throw new SAXException("Supported operation types are: create, delete, update");
                   }
   
                   this.key = a.getValue(XMLDB_QUERY_OID_ATTRIBUTE);
  -                if("delete".equals(operation) && this.key == null) {
  -                    throw new SAXException("Object ID is missing in xmldb element");
  +                if ("delete".equals(operation) && this.key == null) {
  +                    throw new SAXException("Object ID attribute is missing on query element");
                   }
  +
  +                this.xbase = a.getValue(XMLDB_QUERY_CONTEXT_ATTRIBUTE);
  +
  +                // Start processing
  +                result = "failure";
  +                message = null;
                   processing = true;
   
  -                if (!"delete".equals(operation)) {
  +                if ("create".equals(operation) && this.key != null && this.key.endsWith("/")) {
  +                } else if (!"delete".equals(operation)) {
                       // Prepare SAX query writer
                       queryWriter = new StringWriter(256);
                       try {
  @@ -362,21 +396,20 @@
   
                       // Start query document
                       this.queryHandler.startDocument();
  -                    Iterator itt = prefixMap.entrySet().iterator();
  -                    while ( itt.hasNext() ) {
  -                        Map.Entry entry = (Map.Entry)itt.next();
  +                    Iterator i = prefixMap.entrySet().iterator();
  +                    while (i.hasNext()) {
  +                        Map.Entry entry = (Map.Entry)i.next();
                           this.queryHandler.startPrefixMapping((String)entry.getKey(), (String)entry.getValue());
                       }
                   }
               } else {
  -                super.startElement(uri,loc,raw,a);
  +                super.startElement(uri, loc, raw, a);
               }
  -        } else if (this.queryHandler != null){
  -            this.queryHandler.startElement(uri,loc,raw,a);
  +        } else if (this.queryHandler != null) {
  +            this.queryHandler.startElement(uri, loc, raw, a);
           }
       }
   
  -
       /**
        * Receive notification of the end of an element.
        *
  @@ -393,65 +426,96 @@
           if (!processing) {
               super.endElement(uri,loc,raw);
           } else {
  -            if (XMLDB_URI.equals(uri) && XMLDB_QUERY_ELEMENT.equals(loc)){
  +            if (XMLDB_URI.equals(uri) && XMLDB_QUERY_ELEMENT.equals(loc)) {
                   processing = false;
   
                   String document = null;
  -                if (this.queryHandler != null){
  +                if (this.queryHandler != null) {
                       // Finish building query. Remove existing prefix mappings.
  -                    Iterator itt = prefixMap.entrySet().iterator();
  -                    while ( itt.hasNext() ) {
  -                        Map.Entry entry = (Map.Entry) itt.next();
  +                    Iterator i = prefixMap.entrySet().iterator();
  +                    while (i.hasNext()) {
  +                        Map.Entry entry = (Map.Entry) i.next();
                           this.queryHandler.endPrefixMapping((String)entry.getKey());
                       }
                       this.queryHandler.endDocument();
  -
                       document = this.queryWriter.toString();
                   }
   
                   // Perform operation
  -                String result = "failure";
  -                String message = null;
  -                if("create".equals(operation)) {
  -                    try {
  -                        if (key == null) key = collection.createId();
  -                        Resource resource = collection.createResource(key, "XMLResource");
  -                        resource.setContent(document);
  -                        collection.storeResource(resource);
  -                        result = "success";
  -                        key = resource.getId();
  -                    } catch (XMLDBException e) {
  -                        message = "Failed to create resource " + key + ": " + e.errorCode;
  -                        getLogger().debug(message, e);
  -                    }
  -                } else if("delete".equals(operation)) {
  -                    try {
  -                        Resource resource = collection.getResource(this.key);
  -                        if (resource == null) {
  -                            message = "Resource " + this.key + " does not exist";
  -                            getLogger().debug(message);
  +                Collection collection = null;
  +                try {
  +                    // Obtain collection for the current operation
  +                    collection = (xbase != null)? DatabaseManager.getCollection(local_base + "/" + xbase) : this.collection;
  +
  +                    if ("create".equals(operation)) {
  +                        if (key != null && key.endsWith("/")) {
  +                            try {
  +                                // Cut trailing '/'
  +                                String k = this.key.substring(0, this.key.length() - 1);
  +                                CollectionManagementService service =
  +                                        (CollectionManagementService) collection.getService("CollectionManagementService", "1.0");
  +                                service.createCollection(k);
  +                                result = "success";
  +                            } catch (XMLDBException e) {
  +                                message = "Failed to create collection " + this.key + ": " + e.errorCode;
  +                                getLogger().error(message, e);
  +                            }
                           } else {
  -                            collection.removeResource(resource);
  +                            try {
  +                                if (key == null) {
  +                                    key = collection.createId();
  +                                }
  +                                // Support of binary objects can be added. Content can be obtained using Source.
  +                                Resource resource = collection.createResource(key, "XMLResource");
  +                                resource.setContent(document);
  +                                collection.storeResource(resource);
  +                                result = "success";
  +                                key = resource.getId();
  +                            } catch (XMLDBException e) {
  +                                message = "Failed to create resource " + key + ": " + e.errorCode;
  +                                getLogger().debug(message, e);
  +                            }
  +                        }
  +                    } else if ("delete".equals(operation)) {
  +                        try {
  +                            Resource resource = collection.getResource(this.key);
  +                            if (resource == null) {
  +                                message = "Resource " + this.key + " does not exist";
  +                                getLogger().debug(message);
  +                            } else {
  +                                collection.removeResource(resource);
  +                                result = "success";
  +                            }
  +                        } catch (XMLDBException e) {
  +                            message = "Failed to delete resource " + key + ": " + e.errorCode;
  +                            getLogger().debug(message, e);
  +                        }
  +                    } else if ("update".equals(operation)) {
  +                        try {
  +                            XUpdateQueryService service =
  +                                    (XUpdateQueryService) collection.getService("XUpdateQueryService", "1.0");
  +                            long count = (this.key == null)?
  +                                    service.update(document) : service.updateResource(this.key, document);
  +                            message = count + " entries updated.";
                               result = "success";
  +                        } catch (XMLDBException e) {
  +                            message = "Failed to update resource " + key + ": " + e.errorCode;
  +                            getLogger().debug(message, e);
                           }
  -                    } catch (XMLDBException e) {
  -                        message = "Failed to delete resource " + key + ": " + e.errorCode;
  -                        getLogger().debug(message, e);
                       }
  -                } else if("update".equals(operation)) {
  -                    try {
  -                        XUpdateQueryService service =
  -                                (XUpdateQueryService) collection.getService("XUpdateQueryService", "1.0");
  -                        long count = (this.key == null)?
  -                                service.update(document) : service.updateResource(this.key, document);
  -                        message = count + " entries updated.";
  -                        result = "success";
  -                    } catch (XMLDBException e) {
  -                        message = "Failed to update resource " + key + ": " + e.errorCode;
  -                        getLogger().debug(message, e);
  +                } catch (XMLDBException e) {
  +                    message = "Failed to get context collection for the query (base: " + local_base + ", context: " + xbase + "): " + e.errorCode;
  +                    getLogger().debug(message, e);
  +                } finally {
  +                    if (xbase != null) {
  +                        try {
  +                            collection.close();
  +                        } catch (XMLDBException ignored) {
  +                        }
                       }
                   }
   
  +
                   // Report result
                   AttributesImpl attrs = new AttributesImpl();
                   attrs.addAttribute(null, XMLDB_QUERY_OID_ATTRIBUTE,
  @@ -465,7 +529,7 @@
                       super.characters(message.toCharArray(), 0, message.length());
                   }
                   super.endElement(uri, loc, raw);
  -            } else if (this.queryHandler != null){
  +            } else if (this.queryHandler != null) {
                   this.queryHandler.endElement(uri, loc, raw);
               }
           }
  @@ -481,7 +545,7 @@
       public void characters(char c[], int start, int len) throws SAXException {
           if (!processing) {
               super.characters(c,start,len);
  -        } else if (this.queryHandler != null){
  +        } else if (this.queryHandler != null) {
               this.queryHandler.characters(c,start,len);
           }
       }
  @@ -496,7 +560,7 @@
       public void ignorableWhitespace(char c[], int start, int len) throws SAXException {
           if (!processing) {
               super.ignorableWhitespace(c,start,len);
  -        } else if (this.queryHandler != null){
  +        } else if (this.queryHandler != null) {
               this.queryHandler.ignorableWhitespace(c,start,len);
           }
       }
  @@ -511,7 +575,7 @@
       public void processingInstruction(String target, String data) throws SAXException {
           if (!processing) {
               super.processingInstruction(target,data);
  -        } else if (this.queryHandler != null){
  +        } else if (this.queryHandler != null) {
               this.queryHandler.processingInstruction(target,data);
           }
       }
  @@ -525,7 +589,7 @@
       public void skippedEntity(String name) throws SAXException {
           if (!processing) {
               super.skippedEntity(name);
  -        } else if (this.queryHandler != null){
  +        } else if (this.queryHandler != null) {
               this.queryHandler.skippedEntity(name);
           }
       }
  @@ -541,7 +605,7 @@
        */
       public void startDTD(String name, String publicId, String systemId) throws SAXException {
           if (!processing) {
  -            super.startDTD(name,publicId,systemId);
  +            super.startDTD(name, publicId, systemId);
           } else {
               throw new SAXException(
                   "Recieved startDTD after beginning SVG extraction process."
  @@ -569,7 +633,7 @@
       public void startEntity(String name) throws SAXException {
           if (!processing) {
               super.startEntity(name);
  -        } else if (this.queryHandler != null){
  +        } else if (this.queryHandler != null) {
               this.queryHandler.startEntity(name);
           }
       }
  @@ -582,7 +646,7 @@
       public void endEntity(String name) throws SAXException {
           if (!processing) {
               super.endEntity(name);
  -        } else if (this.queryHandler != null){
  +        } else if (this.queryHandler != null) {
               this.queryHandler.endEntity(name);
           }
       }
  @@ -593,7 +657,7 @@
       public void startCDATA() throws SAXException {
           if (!processing) {
               super.startCDATA();
  -        } else if (this.queryHandler != null){
  +        } else if (this.queryHandler != null) {
               this.queryHandler.startCDATA();
           }
       }
  @@ -604,7 +668,7 @@
       public void endCDATA() throws SAXException {
           if (!processing) {
               super.endCDATA();
  -        } else if (this.queryHandler != null){
  +        } else if (this.queryHandler != null) {
               this.queryHandler.endCDATA();
           }
       }
  @@ -618,9 +682,9 @@
        */
       public void comment(char ch[], int start, int len) throws SAXException {
           if (!processing) {
  -            super.comment(ch,start,len);
  -        } else if (this.queryHandler != null){
  -            this.queryHandler.comment(ch,start,len);
  +            super.comment(ch, start, len);
  +        } else if (this.queryHandler != null) {
  +            this.queryHandler.comment(ch, start, len);
           }
       }
   
  @@ -630,12 +694,13 @@
           this.queryWriter = null;
   
           try {
  -            if (collection != null) collection.close();
  +            if (collection != null) {
  +                collection.close();
  +            }
           } catch (XMLDBException e) {
  -            getLogger().error("Failed to close collection " + base + ". Error " + e.errorCode, e);
  +            getLogger().error("Failed to close collection " + this.local_base + ". Error " + e.errorCode, e);
           }
           collection = null;
           super.recycle();
       }
  -
   }
  
  
  
  1.4       +25 -33    cocoon-2.1/src/blocks/xmldb/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/xmldb/samples/sitemap.xmap,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- sitemap.xmap	8 Dec 2003 14:53:29 -0000	1.3
  +++ sitemap.xmap	10 Dec 2003 14:33:16 -0000	1.4
  @@ -2,25 +2,6 @@
   
   <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
   
  -<!-- ========================= Components ================================ -->
  -
  -  <map:components>
  -    <map:generators default="file">
  -      <!-- =================== XML:DB Generators ========================= -->
  -      <!-- BEWARE: these are unmaintained XML:DB generators, going to be   -->
  -      <!-- removed soon.                                                   -->
  -      <!-- You might want  to use the XML:DB pseudo protocol instead.      -->
  -      <map:generator name="xmldb" src="org.apache.cocoon.generation.XMLDBGenerator" label="content">
  -        <driver>org.apache.xindice.client.xmldb.DatabaseImpl</driver>
  -        <base>xmldb:xindice-embed:///db/</base>
  -      </map:generator>
  -      <map:generator name="xmldbcollection" src="org.apache.cocoon.generation.XMLDBCollectionGenerator" label="content">
  -        <driver>org.apache.xindice.client.xmldb.DatabaseImpl</driver>
  -        <base>xmldb:xindice-embed:///db/</base>
  -      </map:generator>
  -    </map:generators>
  -  </map:components>
  -
   <!-- =========================== Views =================================== -->
   
     <map:views>
  @@ -42,23 +23,34 @@
   
     <map:pipelines>
       <map:pipeline>
  -      <!-- =================== XML:DB Generators ========================= -->
  -      <!-- BEWARE: the following examples use the unmaintained XML:DB      -->
  -      <!-- generators, going to be deprecated soon.                        -->
  -      <!-- You might want  to use the XML:DB pseudo protocol instead.      -->
  -      <map:match pattern="xmldb-generator/db/**/">
  -        <map:generate type="xmldbcollection" src="/{1}"/>
  -        <map:serialize type="xml"/>
  +      <map:match pattern="">
  +        <map:redirect-to uri="welcome"/>
  +      </map:match>
  +   
  +      <map:match pattern="welcome">
  +        <map:generate src="samples.xml"/>
  +        <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
  +          <map:parameter name="contextPath" value="{request:contextPath}"/>
  +        </map:transform>
  +        <map:serialize/>
         </map:match>
  -      <map:match pattern="xmldb-generator/db/**">
  -        <map:generate type="xmldb" src="/{1}"/>
  -        <map:serialize type="xml"/>
  +   
  +      <map:match pattern="xwelcome">
  +        <map:generate src="xmldb:xindice-embed:///db/cocoon/welcome"/>
  +        <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
  +          <map:parameter name="contextPath" value="{request:contextPath}"/>
  +        </map:transform>
  +        <map:serialize/>
         </map:match>
  -    </map:pipeline>
   
  -    <map:pipeline>
  -      <!-- ======================= XML:DB ============================== -->
  -      <map:match pattern="**">
  +      <map:match pattern="populate">
  +        <map:generate src="populate.xml"/>
  +        <map:transform type="cinclude"/>
  +        <map:transform type="xmldb"/>
  +        <map:serialize/>
  +      </map:match>
  +
  +      <map:match pattern="db/**">
           <map:match type="request-parameter" pattern="xpath">
             <map:generate src="xmldb:xindice-embed:///db/{../1}#{1}"/>
             <map:serialize type="xml"/>
  
  
  
  1.1                  cocoon-2.1/src/blocks/xmldb/samples/populate.xml
  
  Index: populate.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <html>
    <h2>Populating DB with samples data</h2>
    <h3>Create Collection</h3>
    <p>Create collection should succeed on the first run, but will fail on subsequent runs</p>
    <textarea cols="75" rows="3">
      <x:query type="create" oid="cocoon/" xmlns:x="http://apache.org/cocoon/xmldb/1.0"/>
    </textarea>
  
    <h3>Create Samples Document</h3>
    <textarea cols="75" rows="3">
      <x:query type="create" collection="cocoon" oid="welcome" xmlns:x="http://apache.org/cocoon/xmldb/1.0">
        <!-- i:include src="samples.xml" xmlns:i="http://apache.org/cocoon/include/1.0"/ -->
        <samples name="XMLDB Samples" xmlns:xlink="http://www.w3.org/1999/xlink">
          <group name="Main examples page.">
            <sample name="Back" href="..">to Cocoon examples main page</sample>
          </group>
          <group name="Init Database">
            <sample name="Init" href="populate">
              Populate sample XMLDB Database
            </sample>
          </group>
          <group name="XMLDB Samples">
            <note>
              This page is served from the XMLDB. Click below to go back to file system
              version of the file.
            </note>
            <sample name="From File System" href="welcome">
              This samples page, but served from the file system.
            </sample>
          </group>
        </samples>
      </x:query>
    </textarea>
  
    <h3>Done</h3>
    <a href="./">Go Back</a>
  </html>
  
  
  
  1.1                  cocoon-2.1/src/blocks/xmldb/samples/samples.xml
  
  Index: samples.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  
  <!--+
      | XMLDB Samples
      |
      | CVS $Id: samples.xml,v 1.1 2003/12/10 14:33:16 vgritsenko Exp $
      +-->
  
  <samples name="XMLDB Samples" xmlns:xlink="http://www.w3.org/1999/xlink">
  
    <group name="Main examples page.">
      <sample name="Back" href="..">to Cocoon examples main page</sample>
    </group>
  
    <group name="Init Database">
      <sample name="Init" href="populate">
        Populate sample XMLDB Database
      </sample>
    </group>
  
    <group name="XMLDB Samples">
      <sample name="From DB" href="xwelcome">
        This samples page, but obtained from the XMLDB database
        (don't forget to Init database first)
      </sample>
    </group>
  </samples>