dims 01/08/20 09:14:02
Modified: . build.xml
xdocs generators.xml site-book.xml
Added: src/org/apache/cocoon/generation XMLDBGenerator.java
xdocs xmldb-generator.xml
Log:
Accept donation of XML:DB generator (Optional) from Gianugo Rabellino
<[EMAIL PROTECTED]>.
Revision Changes Path
1.51 +23 -1 xml-cocoon2/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/build.xml,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- build.xml 2001/08/14 14:44:33 1.50
+++ build.xml 2001/08/20 16:14:01 1.51
@@ -101,6 +101,10 @@
- HTML Generator : Requires the JTidy package (included in the dist)
<map:generator name="html"
src="org.apache.cocoon.generation.HTMLGenerator" label="content"/>
+- XML:DB Generator: Requires the XML:DB API and a valid implementation
+ (notincluded in the dist)
+ <map:generator name="xmldb"
src="org.apache.cocoon.generation.XMLDBGenerator"/>
+
Transformers
- XT transformer : Requires the XT package (included in the dist)
@@ -282,6 +286,9 @@
<available property="maybeupload.present"
classname="uk.co.weft.maybeupload.MaybeUploadRequestWrapper">
<classpath refid="classpath"/>
</available>
+ <available property="xmldb.present" classname="org.xmldb.api.DatabaseManager">
+ <classpath refid="classpath"/>
+ </available>
</target>
<!-- =================================================================== -->
@@ -304,6 +311,7 @@
<exclude name="**/Sendmail*.java" unless="mail.present"/>
<exclude name="**/LDAPTransformer*.java" unless="naming.present"/>
<exclude name="**/JSPEngineImplWLS.java" unless="weblogic.present"/>
+ <exclude name="**/XMLDBGenerator.java" unless="xmldb.present"/>
<exclude name="**/browser/*.x*"/>
</fileset>
</copy>
@@ -615,9 +623,23 @@
</target>
<!-- =================================================================== -->
+ <!-- Prepares the webapp sitemap if XML:DB is available -->
+ <!-- =================================================================== -->
+ <target name="prepare-webapp-xmldb" depends="copy-webapp"
+ if="xmldb.present">
+ <property name="xmldb.conf"
value="<driver>org.dbxml.client.xmldb.DatabaseImpl</driver><base>xmldb:dbxml:///db/</base>"/>
+ <java classname="st">
+ <arg line="-i ${build.war}/sitemap.xmap -o ${build.war}/sitemap.xmap -a
generators xmldb org.apache.cocoon.generation.XMLDBGenerator ${xmldb.conf}"/>
+ <classpath>
+ <pathelement location="${bin.dir}"/>
+ </classpath>
+ </java>
+ </target>
+
+ <!-- =================================================================== -->
<!-- Prepares the webapp directories -->
<!-- =================================================================== -->
- <target name="prepare-webapp" depends="copy-webapp, prepare-webapp-php,
prepare-webapp-xt, prepare-webapp-fop, prepare-webapp-tidy, prepare-webapp-naming">
+ <target name="prepare-webapp" depends="copy-webapp, prepare-webapp-php,
prepare-webapp-xt, prepare-webapp-fop, prepare-webapp-tidy, prepare-webapp-naming,
prepare-webapp-xmldb">
<!-- Simply do nothing, just invoke all dependencies -->
</target>
1.1 xml-cocoon2/src/org/apache/cocoon/generation/XMLDBGenerator.java
Index: XMLDBGenerator.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.generation;
import java.io.IOException;
import java.util.Map;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
import org.xmldb.api.base.ErrorCodes;
import org.xmldb.api.base.Resource;
import org.xmldb.api.base.Service;
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.XMLResource;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.excalibur.pool.Poolable;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.ResourceNotFoundException;
import org.apache.cocoon.caching.CacheValidity;
import org.apache.cocoon.caching.Cacheable;
import org.apache.cocoon.caching.TimeStampCacheValidity;
import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.util.HashUtil;
import org.apache.avalon.excalibur.pool.Recyclable;
import org.xml.sax.SAXException;
/**
* This class implements generation of XML documents from a
* XML:DB compliant database.
* It must to be configured as follows:
* <pre>
* <driver>(a valid DB:XML compliant driver)</driver>
* <base>xmldb:yourdriver://host/an/optional/path/to/be/prepended</base>
* </pre>
* NOTE: the driver can be any DB:XML compliant driver (although this
* component has been tested only with
* <a href="http://www.dbxml.org">dbXML</a>, and the trailing
* slash in the base tag is important!
*
* @author <a href="mailto:[EMAIL PROTECTED]">Gianugo Rabellino</a>
*/
public class XMLDBGenerator extends ComposerGenerator
implements Cacheable, Recyclable,Configurable {
protected String driver;
protected String base;
protected String col;
protected String res;
protected Database database;
protected Collection collection;
protected XMLResource xmlResource;
public void compose(ComponentManager manager) throws ComponentException {
super.compose(manager);
}
/**
* Recycle the component, keep only the configuration variables.
*
*/
public void recycle() {
super.recycle();
this.col = null;
this.res = null;
this.database = null;
this.collection = null;
this.xmlResource = null;
}
/**
* Configure the component. This class is expecting a configuration
* like the following one:
* <pre>
* <driver>org.dbxml.client.xmldb.DatabaseImpl</driver>
* <base>xmldb:dbxml:///db/</base>
* </pre>
* NOTE: the driver can be any DB:XML compliant driver (although this
* component has been tested only with
* <a href="http://www.dbxml.org">dbXML</a>, and the trailing
* slash in the base tag is important!
*
* @exception ConfigurationException (configuration invalid or missing)
*/
public void configure(Configuration conf)
throws ConfigurationException {
if (conf != null) {
this.driver = conf.getChild("driver").getValue();
this.base = conf.getChild("base").getValue();
} else {
throw new ConfigurationException("XMLDB configuration not found");
}
}
public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par)
throws ProcessingException, SAXException,IOException {
super.setup(resolver, objectModel, src, par);
}
/**
* The component isn't cached (yet)
*/
public CacheValidity getValidity() {
return null;
}
/**
* The component isn't cached (yet)
*/
public CacheValidity generateValidity() {
return null;
}
/**
* The component isn't cached (yet)
*/
public long generateKey() {
return 0;
}
/**
* Parse the requested URI, connect to the XML:DB database
* and fetch the requested resource.
*
* @exception ProcessingException something unexpected happened with the DB
*/
public void generate()
throws IOException, SAXException, ProcessingException {
String col = "/";
this.getLogger().debug("Processing resource: " + source);
if (source.indexOf('/') != -1)
col = "/" + source.substring(0, source.lastIndexOf('/'));
res = source.substring(source.lastIndexOf('/') + 1);
try {
Class c = Class.forName(driver);
Database database = (Database)c.newInstance();
DatabaseManager.registerDatabase(database);
collection = DatabaseManager.getCollection(base + col);
xmlResource = (XMLResource) collection.getResource(res);
if (xmlResource == null)
throw new ResourceNotFoundException("Document " + col + "/" +res +
"not found");
xmlResource.getContentAsSAX(this.xmlConsumer);
} catch (XMLDBException xde) {
throw new ProcessingException("Unable to fetch content: " +
xde.getMessage());
} catch (Exception e) {
this.getLogger().debug("Driver: " + driver +"/" + "Base: " + base);
throw new ProcessingException("Unable to set up XMLDB connection (NULL?):
" +
e.getMessage());
}
}
}
1.7 +1 -0 xml-cocoon2/xdocs/generators.xml
Index: generators.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/xdocs/generators.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- generators.xml 2001/07/19 13:47:19 1.6
+++ generators.xml 2001/08/20 16:14:01 1.7
@@ -37,6 +37,7 @@
<li><link href="status-generator.html">Status
Generator</link></li>
<li><link href="stream-generator.html">Stream
Generator</link></li>
<li><link href="php-generator.html">Php
Generator</link> (optional)</li>
+ <li><link href="xmldb-generator.html">XML:DB
Generator</link> (optional)</li>
</ul>
</s1>
</body>
1.26 +1 -0 xml-cocoon2/xdocs/site-book.xml
Index: site-book.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/xdocs/site-book.xml,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- site-book.xml 2001/08/13 10:39:06 1.25
+++ site-book.xml 2001/08/20 16:14:01 1.26
@@ -33,6 +33,7 @@
<hidden id="status-generator" label="Status Generator"
source="status-generator.xml"/>
<hidden id="stream-generator" label="Stream Generator"
source="stream-generator.xml"/>
<hidden id="php-generator" label="Php Generator" source="php-generator.xml"/>
+ <hidden id="xmldb-generator" label="XML:DB Generator"
source="xmldb-generator.xml"/>
<!-- The transformers -->
<page id="transformers" label="Transformers" source="transformers.xml"/>
1.1 xml-cocoon2/xdocs/xmldb-generator.xml
Index: xmldb-generator.xml
===================================================================
<?xml version="1.0"?>
<!DOCTYPE document SYSTEM "dtd/document-v10.dtd">
<document>
<header>
<title>XML:DB Generator</title>
<subtitle>in @doctitle@</subtitle>
<version>0.1</version>
<type>Technical document</type>
<authors>
<person name="Gianugo Rabellino" email="[EMAIL PROTECTED]"/>
</authors>
<abstract>This document describes the XML:DB generator of
@docname@.</abstract>
</header>
<body>
<s1 title="XML:DB Generator">
<p>
Generates XML documents out of an XML:DB compliant database. XML:DB
is a generic API developed by the XML:DB group in order to allow access
via a consistent API to the upcoming XML databases such as dbXML,
Ozone and eXist (as of now only the first one has an almost compliant
API implementation).
For the sake of this document, an XML:DB compliant database can be
seen as a filesystem where directories are called "collections" and
files are called "resources".
</p>
<ul>
<li>Name: xmldb</li>
<li>Class: org.apache.cocoon.generation.XMLDBGenerator</li>
<li>Cacheable: no</li>
</ul>
<p>
The generator needs to be configured in a "JDBCish" way: a driver
(a class name) must be provided, together with a "base" URI. An example
configuration, based on the stock dbXML implementation, will look like
this:
<source>
<![CDATA[
<map:generator name="xmldb" src="org.apache.cocoon.generation.XMLDBGenerator"
label="content">
<driver>org.dbxml.client.xmldb.DatabaseImpl</driver>
<base>xmldb:dbxml:///db/</base>
</map:generator>
]]>
</source>
Note that the content of the "base" tag will be prepended to the
requested resource. It's important to keep a trailing slash at the
end of the <code>base</code> tag.
</p>
</s1>
</body>
</document>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]