giacomo 00/07/05 21:57:52
Modified: src/org/apache/arch/config Tag: xml-cocoon2
SitemapConfigurationBuilder.java
src/org/apache/cocoon/components/language/markup/sitemap/java
Tag: xml-cocoon2 sitemap.xsl
src/org/apache/cocoon/sitemap Tag: xml-cocoon2
AbstractSitemapProcessor.java SitemapProcessor.java
Log:
Further work on the compiles SitemapProcessor
Revision Changes Path
No revision
No revision
1.1.2.2 +17 -9
xml-cocoon/src/org/apache/arch/config/Attic/SitemapConfigurationBuilder.java
Index: SitemapConfigurationBuilder.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/arch/config/Attic/SitemapConfigurationBuilder.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- SitemapConfigurationBuilder.java 2000/07/03 15:19:13 1.1.2.1
+++ SitemapConfigurationBuilder.java 2000/07/06 04:57:42 1.1.2.2
@@ -23,7 +23,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* (Apache Software Foundation, Exoffice Technologies)
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/03 15:19:13 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/06 04:57:42 $
*/
public class SitemapConfigurationBuilder {
@@ -33,12 +33,20 @@
public Configuration newConfiguration(String name) {
return(new ConfigurationImpl (name));
}
-
- /**
- * Add an attribute to this configuration element, returning its old
- * value or <b>null</b>.
- */
- public void addAttribute(String name, String value, Configuration conf) {
- ((ConfigurationImpl)conf).addAttribute(name,value);
- }
+
+ /**
+ * Add an attribute to this configuration element, returning its old
+ * value or <b>null</b>.
+ */
+ public void addAttribute(String name, String value, Configuration conf)
{
+ ((ConfigurationImpl)conf).addAttribute(name,value);
+ }
+
+ /**
+ * Add an attribute to this configuration element, returning its old
+ * value or <b>null</b>.
+ */
+ public void addConfiguration(Configuration child, Configuration conf) {
+ ((ConfigurationImpl)conf).addConfiguration(child);
+ }
}
No revision
No revision
1.1.2.2 +125 -51
xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
Index: sitemap.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- sitemap.xsl 2000/07/02 19:23:18 1.1.2.1
+++ sitemap.xsl 2000/07/06 04:57:43 1.1.2.2
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
<!-- Sitemap Core logicsheet for the Java language -->
+
<xsl:stylesheet version="1.0"
- xmlns:map="http://xml.apache.org/cocoon/sitemap/1.0"
+ xmlns:map="http://apache.org/cocoon/sitemap/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
@@ -14,13 +15,8 @@
<xsl:apply-templates/>
</code>
</xsl:template>
-
- <xsl:template match="map:sitemap">
- <xsl:if test="not (@xmlns='http://apache.org/cocoon/sitemap/1.0')">
- <xsl:call-template name="error">
- <xsl:with-param name="message">the namespace of the sitemap must be
http://apache.org/cocoon/sitemap/1.0</xsl:with-param>
- </xsl:call-template>
- </xsl:if>
+
+ <xsl:template match="map:sitemap">
package <xsl:value-of select="translate(@file-path, '/', '.')"/>;
import java.util.Map;
@@ -44,11 +40,13 @@
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/02 19:23:18 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/06 04:57:43 $
*/
public class <xsl:value-of select="@file-name"/> extends
AbstractSitemapProcessor {
SitemapConfigurationBuilder confBuilder = new
SitemapConfigurationBuilder ();
+
+ <!-- generate variables for all components -->
/** The generators */
<xsl:call-template name="define-components">
<xsl:with-param name="name-prefix">generator</xsl:with-param>
@@ -90,10 +88,9 @@
*/
public void setConfiguration(Configuration xconf) {
// throws ConfigurationException {
-
- Configuration conf = null;
-
- /** The generators */
+
+ <!-- configure all components -->
+ /* Configure generators */
<xsl:call-template name="config-components">
<xsl:with-param name="name">generator</xsl:with-param>
<xsl:with-param name="interface">Generator</xsl:with-param>
@@ -103,7 +100,7 @@
select="/map:sitemap/map:components/map:generators/@default"/>
</xsl:call-template>
- /** The filters */
+ /* Configure filters */
<xsl:call-template name="config-components">
<xsl:with-param name="name">transformer</xsl:with-param>
<xsl:with-param name="interface">Transformer</xsl:with-param>
@@ -113,7 +110,7 @@
select="/map:sitemap/map:components/map:transformers/@default"/>
</xsl:call-template>
- /** The serializers */
+ /* Configure serializers */
<xsl:call-template name="config-components">
<xsl:with-param name="name">serializer</xsl:with-param>
<xsl:with-param name="interface">Serializer</xsl:with-param>
@@ -123,7 +120,7 @@
select="/map:sitemap/map:components/map:serializers/@default"/>
</xsl:call-template>
- /** The matchers */
+ /* Configure matchers */
<xsl:call-template name="config-components">
<xsl:with-param name="name">matcher</xsl:with-param>
<xsl:with-param name="interface">Matcher</xsl:with-param>
@@ -133,7 +130,7 @@
select="/map:sitemap/map:components/map:matchers/@default"/>
</xsl:call-template>
- /** The choosers */
+ /* Configure choosers */
<xsl:call-template name="config-components">
<xsl:with-param name="name">chooser</xsl:with-param>
<xsl:with-param name="interface">Chooser</xsl:with-param>
@@ -143,8 +140,18 @@
select="/map:sitemap/map:components/map:choosers/@default"/>
</xsl:call-template>
}
-
- protected ResourcePipeline constructPipeline (Request request, Response
resposne) {
+
+ /**
+ * Process the given <code>Request</code> producing the output to the
+ * specified <code>Response</code> and <code>OutputStream</code>.
+ */
+ public boolean process(Request req, Response res, OutputStream out)
+ throws SAXException, IOException, ProcessingException {
+ ResourcePipeline pipeline = constructPipeline (req, res);
+ return pipeline.startPipeline(req, res, out);
+ }
+
+
protected ResourcePipeline constructPipeline (Request request, Response
resposne) {
ResourcePipeline pipeline = new ResourcePipeline ();
Stack resultStack = new Stack();
Map map = null;
@@ -158,24 +165,24 @@
</xsl:template> <!-- match="map:sitemap" -->
<xsl:template match="map:match">
- <xsl:if test="not(ancestor::*[name()='pipeline'])">
+ <xsl:if test="not(ancestor::*[local-name()='pipeline'])">
<xsl:call-template name="error">
- <xsl:with-param name="message"><{$prefix}:match can only appear
in a <pipeline></xsl:with-param>
+ <xsl:with-param name="message"><match can only appear in a
<pipeline></xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:variable name="matcher-type">
<xsl:call-template name="get-parameter">
- <xsl:with-param name="name">type</xsl:with-param>
+ <xsl:with-param name="parname">type</xsl:with-param>
<xsl:with-param name="default"><xsl:value-of
select="/map:sitemap/map:components/map:matchers/@default"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="pattern-value">
<xsl:call-template name="get-parameter">
- <xsl:with-param name="name">pattern</xsl:with-param>
+ <xsl:with-param name="parname">pattern</xsl:with-param>
<xsl:with-param name="required">true</xsl:with-param>
</xsl:call-template>
</xsl:variable>
- if ((map = matcher_<xsl:value-of select="translate($matcher-type, '-',
'_')"/>.match ("<xsl:value-of select="$pattern-value"/>", request)) != null) {
+ if ((map = matcher_<xsl:value-of select="translate($matcher-type, '- ',
'__')"/>.match ("<xsl:value-of select="$pattern-value"/>", request)) != null) {
resultStack.push (map);
<xsl:apply-templates/>
<xsl:if test="not(descendant::map:match or descendant::map:choose)">
@@ -187,18 +194,18 @@
<xsl:template match="map:choose">
<xsl:variable name="chooser-type">
<xsl:call-template name="get-parameter">
- <xsl:with-param name="name">type</xsl:with-param>
+ <xsl:with-param name="parname">type</xsl:with-param>
<xsl:with-param name="default"><xsl:value-of
select="/map:sitemap/map:components/map:choosers/@default"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:for-each select="./map:when">
<xsl:variable name="test-value">
<xsl:call-template name="get-parameter">
- <xsl:with-param name="name">test</xsl:with-param>
+ <xsl:with-param name="parname">test</xsl:with-param>
<xsl:with-param name="required">true</xsl:with-param>
</xsl:call-template>
</xsl:variable>
- if (chooser_<xsl:value-of select="translate($chooser-type, '-',
'_')"/>.choose ("<xsl:value-of select="$test-value"/>", request)) {
+ if (chooser_<xsl:value-of select="translate($chooser-type, '- ',
'__')"/>.choose ("<xsl:value-of select="$test-value"/>", request)) {
<xsl:apply-templates/>
<xsl:if test="not(descendant::map:match or descendant::map:choose)">
return pipeline;
@@ -244,7 +251,7 @@
</xsl:template> <!-- match="map:mount" -->
<xsl:template match="map:param">
- param.setParameter ("<xsl:value-of select="@name"/>", "<xsl:value-of
select="@value"/>");
+ param.setParameter ("<xsl:value-of select="@name"/>", "<xsl:value-of
select="@map:value"/>");
</xsl:template> <!-- match="map:param" -->
<!-- Sitemap Utility templates -->
@@ -254,25 +261,91 @@
<xsl:param name="interface"/>
<xsl:param name="components"/>
<xsl:for-each select="$components">
- private <xsl:value-of select="$interface"/><xsl:text>
</xsl:text><xsl:value-of select="$name-prefix"/>_<xsl:value-of
select="translate(./@type, '-', '_')"/> = null;
+ private <xsl:value-of select="$interface"/><xsl:text>
+ </xsl:text><xsl:value-of select="$name-prefix"/>_<xsl:value-of
select="translate(./@type, '- ', '__')"/> = null;
</xsl:for-each>
private <xsl:value-of select="$interface"/><xsl:text>
</xsl:text><xsl:value-of select="$name-prefix"/>_default = null;
</xsl:template>
- <xsl:template name="config-components">
- <xsl:param name="name"/>
- <xsl:param name="interface"/>
- <xsl:param name="components"/>
- <xsl:param name="default"/>
- <xsl:for-each select="$components">
- conf = confBuilder.newConfiguration ("<xsl:value-of
select="concat(local-name(.),'/',./@type)"/>");
- <xsl:for-each select="./*">
- confBuilder.addAttribute ("<xsl:value-of select="name(.)"/>",
"<xsl:value-of select="./@value"/>", conf);
- </xsl:for-each>
- <xsl:value-of select="$name"/>_<xsl:value-of
select="translate(./@type, '-', '_')"/> = (<xsl:value-of
select="$interface"/>)load_component ("<xsl:value-of select="./@src"/>", conf);
- </xsl:for-each>
- <xsl:value-of select="$name"/>_default = <xsl:value-of
select="translate($name, '-', '_')"/>_<xsl:value-of select="translate($default,
'-', '_')"/>;
- </xsl:template>
+ <xsl:template name="config-components">
+ <xsl:param name="name"/>
+ <xsl:param name="interface"/>
+ <xsl:param name="components"/>
+ <xsl:param name="default"/>
+
+ <xsl:variable name="qname">
+ <xsl:value-of select="concat($prefix, ':value')"/>
+ </xsl:variable>
+
+ <xsl:for-each select="$components">
+ <xsl:variable name="confname">
+ conf_<xsl:value-of select="$name"/>_<xsl:value-of select="@type"/>
+ </xsl:variable>
+ <xsl:call-template name="nested-config-components">
+ <xsl:with-param name="name" select="$name"/>
+ <xsl:with-param name="config-name"><xsl:value-of
select="concat(local-name(.),'/',@type)"/></xsl:with-param>
+ <xsl:with-param name="interface" select="$interface"/>
+ <xsl:with-param name="components" select="*"/>
+ <xsl:with-param name="type" select="@type"/>
+ </xsl:call-template>
+ <xsl:value-of select="$name"/>_<xsl:value-of select="translate(@type,
'- ', '__')"/> =
+ (<xsl:value-of select="$interface"/>)load_component ("<xsl:value-of
select="@src"/>", <xsl:value-of select="$confname"/>);
+ </xsl:for-each>
+ <xsl:value-of select="$name"/>_default = <xsl:value-of
select="translate($name, '- ', '__')"/>_<xsl:value-of
select="translate($default, '- ', '__')"/>;
+ </xsl:template>
+
+ <xsl:template name="nested-config-components">
+ <xsl:param name="name"/>
+ <xsl:param name="config-name"/>
+ <xsl:param name="interface"/>
+ <xsl:param name="components"/>
+ <xsl:param name="type"/>
+ <xsl:param name="subname"/>
+
+ <xsl:variable name="qname">
+ <xsl:value-of select="concat($prefix, ':value')"/>
+ </xsl:variable>
+
+ <xsl:variable name="confname">
+ conf_<xsl:value-of select="$name"/>_<xsl:value-of
select="$type"/><xsl:value-of select="$subname"/>
+ </xsl:variable>
+
+ Configuration <xsl:value-of select="$confname"/> =
confBuilder.newConfiguration ("<xsl:value-of select="$config-name"/>");
+
+ <!-- process content with map:value -->
+ <xsl:for-each select="$components">
+ <xsl:choose>
+ <xsl:when test="name(@*)=$qname">
+ confBuilder.addAttribute ("<xsl:value-of select="name(.)"/>",
"<xsl:value-of select="@*[name(.)=$qname]"/>", <xsl:value-of
select="$confname"/>);
+ </xsl:when>
+ <xsl:when test="count(./*)=0">
+ confBuilder.addAttribute ("<xsl:value-of select="name(.)"/>",
"<xsl:value-of select="."/>", <xsl:value-of select="$confname"/>);
+ </xsl:when>
+ <xsl:when test="count(./*)>0">
+ <xsl:variable name="newsubname">
+ <xsl:choose>
+ <xsl:when test="not($subname)">1</xsl:when>
+ <xsl:otherwise><xsl:value-of
select="number($subname)+1"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:call-template name="nested-config-components">
+ <xsl:with-param name="name"><xsl:value-of
select="$name"/></xsl:with-param>
+ <xsl:with-param name="config-name"><xsl:value-of
select="local-name(.)"/></xsl:with-param>
+ <xsl:with-param name="interface"><xsl:value-of
select="$interface"/></xsl:with-param>
+ <xsl:with-param name="components" select="./*"/>
+ <xsl:with-param name="type"><xsl:value-of
select="$type"/></xsl:with-param>
+ <xsl:with-param name="subname">_<xsl:value-of
select="$newsubname"/></xsl:with-param>
+ </xsl:call-template>
+ <xsl:variable name="newconfname">
+ conf_<xsl:value-of select="$name"/>_<xsl:value-of
select="$type"/><xsl:value-of select="$newsubname"/>
+ </xsl:variable>
+ confBuilder.addConfiguration (<xsl:value-of
select="$newconfname"/>, <xsl:value-of select="$confname"/>);
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:template>
<xsl:template name="setup-component">
<xsl:param name="default-component"/>
@@ -280,13 +353,13 @@
<xsl:param name="prefix"/>
<xsl:variable name="component-type">
<xsl:call-template name="get-parameter">
- <xsl:with-param name="name">type</xsl:with-param>
+ <xsl:with-param name="parname">type</xsl:with-param>
<xsl:with-param name="default"><xsl:value-of
select="$default-component"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="component-source">
<xsl:call-template name="get-parameter">
- <xsl:with-param name="name">src</xsl:with-param>
+ <xsl:with-param name="parname">src</xsl:with-param>
<xsl:with-param name="default">null</xsl:with-param>
</xsl:call-template>
</xsl:variable>
@@ -306,7 +379,8 @@
<xsl:apply-templates select="./map:param"/>
<xsl:choose>
<xsl:when test="$component-source='null'">
- pipeline.<xsl:value-of select="$method"/> (<xsl:value-of
select="$prefix"/>_<xsl:value-of select="$component-type"/>, null,
<xsl:value-of select="$component-param"/>);
+ pipeline.<xsl:value-of select="$method"/> (<xsl:value-of
select="$prefix"/>_<xsl:value-of select="$component-type"/>,
+ null, <xsl:value-of select="$component-param"/>);
</xsl:when>
<xsl:otherwise>
pipeline.<xsl:value-of select="$method"/> (<xsl:value-of
select="$prefix"/>_<xsl:value-of select="$component-type"/>,
@@ -317,7 +391,7 @@
<!-- Utility templates -->
<xsl:template name="get-parameter">
- <xsl:param name="name"/>
+ <xsl:param name="parname"/>
<xsl:param name="default"/>
<xsl:param name="required">false</xsl:param>
@@ -326,11 +400,11 @@
</xsl:variable>
<xsl:choose>
- <xsl:when test="@*[name(.) = $name]"><xsl:value-of select="@*[name(.)
= $name]"/> </xsl:when>
- <xsl:when test="(*[name(.) = $qname])[EMAIL PROTECTED] = $name]">
+ <xsl:when test="@*[name(.) = $parname]"><xsl:value-of
select="@*[name(.) = $parname]"/> </xsl:when>
+ <xsl:when test="(*[name(.) = $qname])[EMAIL PROTECTED] = $parname]">
<xsl:call-template name="get-nested-content">
<xsl:with-param name="content"
- select="(*[name(.) = $qname])[EMAIL PROTECTED] =
$name]"/>
+ select="(*[name(.) = $qname])[EMAIL PROTECTED] =
$parname]"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
@@ -340,7 +414,7 @@
<xsl:when test="$required = 'true'">
<xsl:call-template name="error">
<xsl:with-param name="message">[Logicsheet processor]
-Parameter '<xsl:value-of select="$name"/>' missing in dynamic tag
<<xsl:value-of select="name(.)"/>>
+Parameter '<xsl:value-of select="$parname"/>' missing in dynamic tag
<<xsl:value-of select="name(.)"/>>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
No revision
No revision
1.1.2.2 +41 -11
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/AbstractSitemapProcessor.java
Index: AbstractSitemapProcessor.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/AbstractSitemapProcessor.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- AbstractSitemapProcessor.java 2000/07/02 18:59:24 1.1.2.1
+++ AbstractSitemapProcessor.java 2000/07/06 04:57:50 1.1.2.2
@@ -7,6 +7,7 @@
*****************************************************************************/
package org.apache.cocoon.sitemap;
+import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -26,13 +27,19 @@
* Base class for XSP-generated <code>SitemapProcessor</code> classes
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/02 18:59:24 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/06 04:57:50 $
*/
public abstract class AbstractSitemapProcessor
implements SitemapProcessor {
/** The component manager instance */
protected ComponentManager manager=null;
+
+ /** The creation date */
+ protected static long dateCreated = -1L;
+
+ /** The dependency file list */
+ protected static File[] dependencies = null;
/**
* Set the current <code>ComponentManager</code> instance used by
this
@@ -41,6 +48,39 @@
public void setComponentManager(ComponentManager manager) {
this.manager=manager;
}
+
+ /**
+ * Determines whether this generator's source files have changed
+ *
+ * @return Whether any of the files this generator depends on has changed
+ * since it was created
+ */
+ public final boolean modifiedSince(long date) {
+ if (dateCreated < date) {
+ return true;
+ }
+
+ for (int i = 0; i < dependencies.length; i++) {
+ if (dateCreated < dependencies[i].lastModified()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Determines whether generated content has changed since
+ * last invocation. Users may override this method to take
+ * advantage of SAX event cacheing
+ *
+ * @param request The request whose data must be inspected to assert
whether
+ * dynamically generated content has changed
+ * @return Whether content has changes for this request's data
+ */
+ public boolean hasContentChanged(Request request) {
+ return true;
+ }
/**
* Loads a class specified in a sitemap component definition
@@ -48,16 +88,6 @@
protected Object load_component (String ClassURL, Configuration conf) {
return ("");
}
-
- /**
- * Process the given <code>Request</code> producing the output to the
- * specified <code>Response</code> and <code>OutputStream</code>.
- */
- public boolean process(Request req, Response res, OutputStream out)
- throws SAXException, IOException, ProcessingException {
- ResourcePipeline pipeline = constructPipeline (req, res);
- return pipeline.startPipeline(req, res, out);
- }
/**
* Resolve a link against a source into the target URI space.
1.1.2.2 +4 -3
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapProcessor.java
Index: SitemapProcessor.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapProcessor.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- SitemapProcessor.java 2000/07/02 18:59:25 1.1.2.1
+++ SitemapProcessor.java 2000/07/06 04:57:50 1.1.2.2
@@ -7,7 +7,8 @@
*****************************************************************************/
package org.apache.cocoon.sitemap;
-import org.apache.arch.Composer;
+import org.apache.arch.Composer;
+import org.apache.arch.Modifiable;
import org.apache.arch.config.Configurable;
import org.apache.cocoon.Processor;
@@ -15,8 +16,8 @@
* Base class for XSP-generated <code>SitemapProcessor</code> classes
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/02 18:59:25 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/06 04:57:50 $
*/
public interface SitemapProcessor
- extends Composer, Configurable, Processor, LinkResolver {
+ extends Composer, Configurable, Processor, LinkResolver, Modifiable {
}