giacomo 00/07/17 14:06:15
Modified: samples/stylesheets Tag: xml-cocoon2 simple-status.xsl
src/org/apache/cocoon/components/language/markup/sitemap
Tag: xml-cocoon2 SitemapMarkupLanguage.java
src/org/apache/cocoon/components/language/markup/sitemap/java
Tag: xml-cocoon2 sitemap.xsl
src/org/apache/cocoon/matching Tag: xml-cocoon2
BrowserMatcherFactory.java Matcher.java
MatcherFactory.java WildcardURIMatcherFactory.java
src/org/apache/cocoon/selection Tag: xml-cocoon2
BrowserSelectorFactory.java Selector.java
SelectorFactory.java
src/org/apache/cocoon/serialization Tag: xml-cocoon2
FO2PDFSerializer.java
src/org/apache/cocoon/sitemap Tag: xml-cocoon2
AbstractSitemapProcessor.java ResourcePipeline.java
XSLTMatcherFactoryLoader.java
XSLTSelectorFactoryLoader.java
xdocs/drafts Tag: xml-cocoon2 sitemap-working-draft.xmap
Log:
Revision Changes Path
No revision
No revision
1.1.2.2 +7 -7 xml-cocoon/samples/stylesheets/Attic/simple-status.xsl
Index: simple-status.xsl
===================================================================
RCS file: /home/cvs/xml-cocoon/samples/stylesheets/Attic/simple-status.xsl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- simple-status.xsl 2000/07/12 22:16:43 1.1.2.1
+++ simple-status.xsl 2000/07/17 21:06:10 1.1.2.2
@@ -1,10 +1,10 @@
-<?xml version="1.0"?>
-
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:status="http://apache.org/cocoon/status"
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:status="http://apache.org/cocoon/status"
>
-
+
<xsl:template match="status:statusinfo">
<html>
<head>
@@ -15,7 +15,7 @@
<xsl:apply-templates />
</table>
</body>
- </html>
+ </html>
</xsl:template>
<xsl:template match="status:group">
No revision
No revision
1.1.2.3 +258 -258
xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java
Index: SitemapMarkupLanguage.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- SitemapMarkupLanguage.java 2000/07/06 18:53:20 1.1.2.2
+++ SitemapMarkupLanguage.java 2000/07/17 21:06:10 1.1.2.3
@@ -1,258 +1,258 @@
-/*****************************************************************************
- * 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.components.language.markup.sitemap;
-
-import java.io.File;
-import java.util.Date;
-import java.util.Vector;
-import java.util.Hashtable;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-
-import org.apache.cocoon.util.DOMUtils;
-import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
-
-import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
-
-
-import java.io.IOException;
-import org.xml.sax.SAXException;
-
-/**
- * This class implements <code>MarkupLanguage</code> for Cocoon's
- * <a href="http://xml.apache.org/cocoon/sitemap.html">Sitemap</a>.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/06 18:53:20 $
- */
-public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
- /**
- * The default constructor.
- */
- public SitemapMarkupLanguage() throws SAXException, IOException {
- super();
- }
-
- /**
- * Return the Sitemap language name: <i>map</i> :-)
- *
- * @return The <i>map</i> constant
- */
- public String getName() {
- return "map";
- }
-
- /**
- * Return the document-declared encoding or <code>null</code> if it's the
- * platform's default encoding
- *
- * @param document The input document
- * @return The document-declared encoding
- */
- public String getEncoding(Document document) {
- String encoding = document.getDocumentElement().getAttribute("encoding");
-
- if (encoding.length() > 0) {
- return encoding;
- }
-
- return null;
- }
-
- /**
- * Prepare the document for logicsheet processing and code generation. This
- * method sets the base filename, file path and creation date as root
element
- * attibutes and encodes text nodes as strings.
- *
- * @param document The input document
- * @param filename The input source filename
- * @param language The target programming language
- * @return The augmented document
- */
- protected Document preprocessDocument(
- Document document, String filename, ProgrammingLanguage language
- )
- {
- // Store path and file name
- int pos = filename.lastIndexOf(File.separatorChar);
- String name = filename.substring(pos + 1);
- String path = filename.substring(0, pos).replace(File.separatorChar,
'/');
-
- Element root = document.getDocumentElement();
-
- root.setAttribute("file-name", name);
- root.setAttribute("file-path", path);
- root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
-
- this.quoteStrings(document, language);
-
- return document;
- }
-
- /**
- * Encode text nodes as strings according to the target programming
languages
- * string constant escaping rules.
- *
- * @param node The node to be escaped
- * @param language The target programming language
- */
- protected void quoteStrings(Node node, ProgrammingLanguage language) {
- switch (node.getNodeType()) {
- case Node.PROCESSING_INSTRUCTION_NODE:
- ProcessingInstruction pi = (ProcessingInstruction) node;
- if (!pi.getTarget().equals("xml-logicsheet")) {
- pi.setData(language.quoteString(pi.getData()));
- }
- break;
- case Node.TEXT_NODE:
- if (true) break; // the sitemap shouldn't have any text node
- Element parent = (Element) node.getParentNode();
-
- String tagName = parent.getTagName();
-
- if (
- tagName.equals("xsp:expr") ||
- tagName.equals("xsp:logic") ||
- tagName.equals("xsp:structure") ||
- tagName.equals("xsp:include")
- ) {
- return;
- }
-
- String value = language.quoteString(node.getNodeValue());
- Text textNode = node.getOwnerDocument().createTextNode(value);
-
- Element textElement =
node.getOwnerDocument().createElement("xsp:text");
-
- textElement.appendChild(textNode);
- parent.replaceChild(textElement, node);
-
- break;
- case Node.ELEMENT_NODE:
- ((Element) node).normalize();
- // Fall through
- default:
- NodeList childList = node.getChildNodes();
- int childCount = childList.getLength();
-
- for (int i = 0; i < childCount; i++) {
- this.quoteStrings(childList.item(i), language);
- }
-
- break;
- }
- }
-
- /**
- * Returns a list of logicsheets to be applied to this document for source
- * code generation. This method scans the input document for
- * <?xml-logicsheet?> processing instructions and top-level
- * <xsp:logicsheet> elements. Logicsheet declarations are removed
from
- * the input document.
- *
- * @param document The input document
- * @return An array of logicsheet <i>names</i>
- */
- protected String[] getLogicsheets(Document document) {
- Vector removedNodes = new Vector();
- Vector logicsheetList = new Vector();
- Element root = document.getDocumentElement();
-
- // Retrieve logicsheets declared by processing-instruction
- NodeList nodeList = document.getChildNodes();
- int count = nodeList.getLength();
- for (int i = 0; i < count; i++) {
- Node node = nodeList.item(i);
- if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
- ProcessingInstruction pi = (ProcessingInstruction) node;
-
- if (pi.getTarget().equals("xml-logicsheet")) {
- Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
- logicsheetList.addElement(attrs.get("href"));
-
- removedNodes.addElement(pi);
- }
- }
- }
-
- // Retrieve logicsheets declared by top-level elements
- nodeList = root.getElementsByTagName("map:logicsheet");
- count = nodeList.getLength();
-
- for (int i = 0; i < count; i++) {
- Element logicsheetElement = (Element) nodeList.item(i);
- removedNodes.addElement(logicsheetElement);
- logicsheetList.addElement(logicsheetElement.getAttribute("location"));
- }
-
- String[] logicsheetLocations = new String[logicsheetList.size()];
- logicsheetList.copyInto(logicsheetLocations);
-
-
- // Remove logicsheet directives
- count = removedNodes.size();
- for (int i = 0; i < count; i++) {
- Node node = (Node) removedNodes.elementAt(i);
- Node parent = node.getParentNode();
- parent.removeChild(node);
- }
-
- return logicsheetLocations;
- }
-
- /**
- * Add a dependency on an external file to the document for inclusion in
- * generated code. This is used by
<code>AbstractServerPagesGenerator</code>
- * to populate a list of <code>File</code>'s tested for change on each
- * invocation; this information, in turn, is used by
- * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
- * necessary. XSP uses <xsp:dependency> elements for this purpose
- *
- * @param PARAM_NAME Param description
- * @return the value
- * @exception EXCEPTION_NAME If an error occurs
- * @see ServerPages <code>AbstractServerPagesGenerator</code>
- * and <code>ServerPagesLoaderImpl</code>
- */
-/** Sitemaps don't (yet) have dependencies */
- protected void addDependency(Document document, String location) {
- Element root = document.getDocumentElement();
- Element dependency = document.createElement("xsp:dependency");
- dependency.appendChild(document.createTextNode(location));
- root.appendChild(dependency);
- }
-/* */
-
- /**
- * Scan top-level document elements for non-xsp tag names returning the
first
- * (and hopefully <i>only</i>) user-defined element
- *
- * @param document The input document
- * @return The first non-xsp element
- */
-/** Sitemaps don't have a user root
- protected Element getUserRoot(Document document) {
- Element root = document.getDocumentElement();
- NodeList elements = root.getElementsByTagName("*");
- int elementCount = elements.getLength();
- for (int i = 0; i < elementCount; i++) {
- Element userRoot = (Element) elements.item(i);
- if (!userRoot.getTagName().startsWith("map:")) {
- return userRoot;
- }
- }
-
- return null;
- }
-*/
-}
+/*****************************************************************************
+ * 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.components.language.markup.sitemap;
+
+import java.io.File;
+import java.util.Date;
+import java.util.Vector;
+import java.util.Hashtable;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ProcessingInstruction;
+
+import org.apache.cocoon.util.DOMUtils;
+import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
+
+import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
+
+
+import java.io.IOException;
+import org.xml.sax.SAXException;
+
+/**
+ * This class implements <code>MarkupLanguage</code> for Cocoon's
+ * <a href="http://xml.apache.org/cocoon/sitemap.html">Sitemap</a>.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
+ * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/17 21:06:10 $
+ */
+public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
+ /**
+ * The default constructor.
+ */
+ public SitemapMarkupLanguage() throws SAXException, IOException {
+ super();
+ }
+
+ /**
+ * Return the Sitemap language name: <i>map</i> :-)
+ *
+ * @return The <i>map</i> constant
+ */
+ public String getName() {
+ return "map";
+ }
+
+ /**
+ * Return the document-declared encoding or <code>null</code> if it's the
+ * platform's default encoding
+ *
+ * @param document The input document
+ * @return The document-declared encoding
+ */
+ public String getEncoding(Document document) {
+ String encoding = document.getDocumentElement().getAttribute("encoding");
+
+ if (encoding.length() > 0) {
+ return encoding;
+ }
+
+ return null;
+ }
+
+ /**
+ * Prepare the document for logicsheet processing and code generation. This
+ * method sets the base filename, file path and creation date as root
element
+ * attibutes and encodes text nodes as strings.
+ *
+ * @param document The input document
+ * @param filename The input source filename
+ * @param language The target programming language
+ * @return The augmented document
+ */
+ protected Document preprocessDocument(
+ Document document, String filename, ProgrammingLanguage language
+ )
+ {
+ // Store path and file name
+ int pos = filename.lastIndexOf(File.separatorChar);
+ String name = filename.substring(pos + 1);
+ String path = filename.substring(0, pos).replace(File.separatorChar,
'/');
+
+ Element root = document.getDocumentElement();
+
+ root.setAttribute("file-name", name);
+ root.setAttribute("file-path", path);
+ root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
+
+ this.quoteStrings(document, language);
+
+ return document;
+ }
+
+ /**
+ * Encode text nodes as strings according to the target programming
languages
+ * string constant escaping rules.
+ *
+ * @param node The node to be escaped
+ * @param language The target programming language
+ */
+ protected void quoteStrings(Node node, ProgrammingLanguage language) {
+ switch (node.getNodeType()) {
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ ProcessingInstruction pi = (ProcessingInstruction) node;
+ if (!pi.getTarget().equals("xml-logicsheet")) {
+ pi.setData(language.quoteString(pi.getData()));
+ }
+ break;
+ case Node.TEXT_NODE:
+ if (true) break; // the sitemap shouldn't have any text node
+ Element parent = (Element) node.getParentNode();
+
+ String tagName = parent.getTagName();
+
+ if (
+ tagName.equals("xsp:expr") ||
+ tagName.equals("xsp:logic") ||
+ tagName.equals("xsp:structure") ||
+ tagName.equals("xsp:include")
+ ) {
+ return;
+ }
+
+ String value = language.quoteString(node.getNodeValue());
+ Text textNode = node.getOwnerDocument().createTextNode(value);
+
+ Element textElement =
node.getOwnerDocument().createElement("xsp:text");
+
+ textElement.appendChild(textNode);
+ parent.replaceChild(textElement, node);
+
+ break;
+ case Node.ELEMENT_NODE:
+ ((Element) node).normalize();
+ // Fall through
+ default:
+ NodeList childList = node.getChildNodes();
+ int childCount = childList.getLength();
+
+ for (int i = 0; i < childCount; i++) {
+ this.quoteStrings(childList.item(i), language);
+ }
+
+ break;
+ }
+ }
+
+ /**
+ * Returns a list of logicsheets to be applied to this document for source
+ * code generation. This method scans the input document for
+ * <?xml-logicsheet?> processing instructions and top-level
+ * <xsp:logicsheet> elements. Logicsheet declarations are removed
from
+ * the input document.
+ *
+ * @param document The input document
+ * @return An array of logicsheet <i>names</i>
+ */
+ protected String[] getLogicsheets(Document document) {
+ Vector removedNodes = new Vector();
+ Vector logicsheetList = new Vector();
+ Element root = document.getDocumentElement();
+
+ // Retrieve logicsheets declared by processing-instruction
+ NodeList nodeList = document.getChildNodes();
+ int count = nodeList.getLength();
+ for (int i = 0; i < count; i++) {
+ Node node = nodeList.item(i);
+ if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
+ ProcessingInstruction pi = (ProcessingInstruction) node;
+
+ if (pi.getTarget().equals("xml-logicsheet")) {
+ Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
+ logicsheetList.addElement(attrs.get("href"));
+
+ removedNodes.addElement(pi);
+ }
+ }
+ }
+
+ // Retrieve logicsheets declared by top-level elements
+ nodeList = root.getElementsByTagName("map:logicsheet");
+ count = nodeList.getLength();
+
+ for (int i = 0; i < count; i++) {
+ Element logicsheetElement = (Element) nodeList.item(i);
+ removedNodes.addElement(logicsheetElement);
+ logicsheetList.addElement(logicsheetElement.getAttribute("location"));
+ }
+
+ String[] logicsheetLocations = new String[logicsheetList.size()];
+ logicsheetList.copyInto(logicsheetLocations);
+
+
+ // Remove logicsheet directives
+ count = removedNodes.size();
+ for (int i = 0; i < count; i++) {
+ Node node = (Node) removedNodes.elementAt(i);
+ Node parent = node.getParentNode();
+ parent.removeChild(node);
+ }
+
+ return logicsheetLocations;
+ }
+
+ /**
+ * Add a dependency on an external file to the document for inclusion in
+ * generated code. This is used by
<code>AbstractServerPagesGenerator</code>
+ * to populate a list of <code>File</code>'s tested for change on each
+ * invocation; this information, in turn, is used by
+ * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
+ * necessary. XSP uses <xsp:dependency> elements for this purpose
+ *
+ * @param PARAM_NAME Param description
+ * @return the value
+ * @exception EXCEPTION_NAME If an error occurs
+ * @see ServerPages <code>AbstractServerPagesGenerator</code>
+ * and <code>ServerPagesLoaderImpl</code>
+ */
+/** Sitemaps don't (yet) have dependencies */
+ protected void addDependency(Document document, String location) {
+ Element root = document.getDocumentElement();
+ Element dependency = document.createElement("xsp:dependency");
+ dependency.appendChild(document.createTextNode(location));
+ root.appendChild(dependency);
+ }
+/* */
+
+ /**
+ * Scan top-level document elements for non-xsp tag names returning the
first
+ * (and hopefully <i>only</i>) user-defined element
+ *
+ * @param document The input document
+ * @return The first non-xsp element
+ */
+/** Sitemaps don't have a user root
+ protected Element getUserRoot(Document document) {
+ Element root = document.getDocumentElement();
+ NodeList elements = root.getElementsByTagName("*");
+ int elementCount = elements.getLength();
+ for (int i = 0; i < elementCount; i++) {
+ Element userRoot = (Element) elements.item(i);
+ if (!userRoot.getTagName().startsWith("map:")) {
+ return userRoot;
+ }
+ }
+
+ return null;
+ }
+*/
+}
No revision
No revision
1.1.2.8 +488 -480
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.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- sitemap.xsl 2000/07/12 22:15:07 1.1.2.7
+++ sitemap.xsl 2000/07/17 21:06:11 1.1.2.8
@@ -1,368 +1,376 @@
-<?xml version="1.0"?>
-<!-- Sitemap Core logicsheet for the Java language -->
-
-<xsl:stylesheet version="1.0"
- xmlns:map="http://apache.org/cocoon/sitemap/1.0"
- xmlns:java="http://xml.apache.org/xslt/java"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
->
-
- <xsl:output method="text"/>
-
- <xsl:variable name="prefix">map</xsl:variable>
- <xsl:variable name="matcher-factory-loader"
select="java:org.apache.cocoon.sitemap.XSLTMatcherFactoryLoader.new()"/>
- <xsl:variable name="selector-factory-loader"
select="java:org.apache.cocoon.sitemap.XSLTSelectorFactoryLoader.new()"/>
-
- <xsl:template match="/">
- <code xml:space="preserve">
- <xsl:apply-templates/>
- </code>
- </xsl:template>
-
- <xsl:template match="map:sitemap">
- package <xsl:value-of select="translate(@file-path, '/', '.')"/>;
-
- import java.util.Map;
- import java.util.Stack;
- import java.util.Vector;
-
- import org.apache.avalon.Configuration;
- import org.apache.avalon.ConfigurationException;
- import org.apache.avalon.SAXConfigurationBuilder;
- import org.apache.avalon.utils.Parameters;
-
- import org.apache.cocoon.Request;
- import org.apache.cocoon.Response;
- import org.apache.cocoon.selection.Selector;
- import org.apache.cocoon.transformation.Transformer;
- import org.apache.cocoon.generation.Generator;
- import org.apache.cocoon.matching.Matcher;
- import org.apache.cocoon.serialization.Serializer;
- import org.apache.cocoon.sitemap.AbstractSitemapProcessor;
- import org.apache.cocoon.sitemap.ResourcePipeline;
-
- import org.xml.sax.helpers.AttributesImpl;
-
-/**
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.7 $ $Date: 2000/07/12 22:15:07 $
- */
-public class <xsl:value-of select="@file-name"/> extends
AbstractSitemapProcessor {
-
- SAXConfigurationBuilder confBuilder = new SAXConfigurationBuilder ();
- Parameters emptyParam = new Parameters();
-
- <!-- generate variables for all components -->
- /** The generators */
- <xsl:for-each
select="/map:sitemap/map:components/map:generators/map:generator">
- private Generator generator_<xsl:value-of select="translate(./@name,
'- ', '__')"/> = null;
- </xsl:for-each>
-
- /** The transformers */
- <xsl:for-each
select="/map:sitemap/map:components/map:transformers/map:transformer">
- private Transformer transformer_<xsl:value-of
select="translate(./@name, '- ', '__')"/> = null;
- </xsl:for-each>
-
- /** The serializers */
- <xsl:for-each
select="/map:sitemap/map:components/map:serializers/map:serializer">
- private Serializer serializer_<xsl:value-of select="translate(./@name,
'- ', '__')"/> = null;
- </xsl:for-each>
-
- /** The matchers */
- <xsl:for-each
select="/map:sitemap/map:components/map:matchers/map:[EMAIL PROTECTED]">
- private Matcher matcher_<xsl:value-of select="translate(./@name, '- ',
'__')"/> = null;
- </xsl:for-each>
-
- /** The selectors */
- <xsl:for-each
select="/map:sitemap/map:components/map:selctors/map:[EMAIL PROTECTED]">
- private Selector selector_<xsl:value-of select="translate(./@name, '-
', '__')"/> = null;
- </xsl:for-each>
-
- /** The sub sitemaps */
- <xsl:for-each select="/map:sitemap/map:pipelines//map:mount">
- SitemapProcessor sitemap_<xsl:value-of select="position()"/> = null;
- </xsl:for-each>
-
- /** The generated matchers */
- <xsl:for-each
select="/map:sitemap/map:components/map:matchers/map:[EMAIL PROTECTED]">
- <xsl:variable name="factory" select="@factory"/>
- <xsl:variable name="type" select="@name"/>
- <xsl:variable name="default"><xsl:if test="$type =
../@default">true</xsl:if></xsl:variable>
- <xsl:for-each
select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:[EMAIL
PROTECTED] or (not(@type) and $default!='')]">
- <xsl:variable name="matcher-name1" select="translate(@pattern,'/-
*?@:{}()[].#^\\$|!','_')"/>
- <xsl:variable name="matcher-name"
select='translate($matcher-name1,"'","")'/>
- private Map _matcher_<xsl:value-of select="$matcher-name"/> (Request
request) {
- <xsl:value-of select="java:getSource($matcher-factory-loader,
string($factory), string(@pattern))"/>
- }
- </xsl:for-each>
- </xsl:for-each>
-
- /** The generated selectors */
- <xsl:for-each
select="/map:sitemap/map:components/map:selectors/map:[EMAIL PROTECTED]">
- <xsl:variable name="factory" select="@factory"/>
- <xsl:variable name="type" select="@name"/>
- <xsl:variable name="default"><xsl:if test="$type =
../@default">true</xsl:if></xsl:variable>
- <xsl:for-each
select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:when[../map:selector/@type=$type
or (not(../map:selector/@type) and $default!='')]">
- <xsl:variable name="selector-name1" select="translate(@test,'/-
*?@:{}()[].#^\\$|!','_')"/>
- <xsl:variable name="selector-name"
select='translate($selector-name1,"'","")'/>
- private boolean _selector_<xsl:value-of select="$selector-name"/>
(Request request) {
- <xsl:value-of select="java:getSource($selector-factory-loader,
string($factory), string(@test))"/>
- }
- </xsl:for-each>
- </xsl:for-each>
-
- /**
- * Pass a <code>Configuration</code> instance to this
- * <code>Configurable</code> class.
- */
- public void setConfiguration(Configuration xconf) {
- throws ConfigurationException {
+<?xml version="1.0"?>
+<!-- Sitemap Core logicsheet for the Java language -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:map="http://apache.org/cocoon/sitemap/1.0"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+ <xsl:output method="text"/>
+
+ <xsl:variable name="prefix">map</xsl:variable>
+ <xsl:variable name="matcher-factory-loader"
select="java:org.apache.cocoon.sitemap.XSLTMatcherFactoryLoader.new()"/>
+ <xsl:variable name="selector-factory-loader"
select="java:org.apache.cocoon.sitemap.XSLTSelectorFactoryLoader.new()"/>
+
+ <xsl:template match="/">
+ <code xml:space="preserve">
+ <xsl:apply-templates/>
+ </code>
+ </xsl:template>
+
+ <xsl:template match="map:sitemap">
+ package <xsl:value-of select="translate(@file-path, '/', '.')"/>;
+
+ import java.io.OutputStream;
+
+ import java.util.Map;
+ import java.util.Stack;
+ import java.util.Vector;
+
+ import org.apache.avalon.Configuration;
+ import org.apache.avalon.ConfigurationException;
+ import org.apache.avalon.SAXConfigurationBuilder;
+ import org.apache.avalon.utils.Parameters;
+
+ import org.apache.cocoon.Request;
+ import org.apache.cocoon.Response;
+ import org.apache.cocoon.selection.Selector;
+ import org.apache.cocoon.transformation.Transformer;
+ import org.apache.cocoon.generation.Generator;
+ import org.apache.cocoon.matching.Matcher;
+ import org.apache.cocoon.serialization.Serializer;
+ import org.apache.cocoon.sitemap.AbstractSitemapProcessor;
+ import org.apache.cocoon.sitemap. SitemapProcessor;
+ import org.apache.cocoon.sitemap.ResourcePipeline;
+
+ import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
+ * @version CVS $Revision: 1.1.2.8 $ $Date: 2000/07/17 21:06:11 $
+ */
+public class <xsl:value-of select="@file-name"/> extends
AbstractSitemapProcessor {
+
+ SAXConfigurationBuilder confBuilder = new SAXConfigurationBuilder ();
+ Parameters emptyParam = new Parameters();
+
+ private Generator generator_error_handler = null;
+
+ <!-- generate variables for all components -->
+ /** The generators */
+ <xsl:for-each
select="/map:sitemap/map:components/map:generators/map:generator">
+ private Generator generator_<xsl:value-of select="translate(./@name,
'- ', '__')"/> = null;
+ </xsl:for-each>
+
+ /** The transformers */
+ <xsl:for-each
select="/map:sitemap/map:components/map:transformers/map:transformer">
+ private Transformer transformer_<xsl:value-of
select="translate(./@name, '- ', '__')"/> = null;
+ </xsl:for-each>
+
+ /** The serializers */
+ <xsl:for-each
select="/map:sitemap/map:components/map:serializers/map:serializer">
+ private Serializer serializer_<xsl:value-of select="translate(./@name,
'- ', '__')"/> = null;
+ </xsl:for-each>
+
+ /** The matchers */
+ <xsl:for-each
select="/map:sitemap/map:components/map:matchers/map:[EMAIL PROTECTED]">
+ private Matcher matcher_<xsl:value-of select="translate(./@name, '- ',
'__')"/> = null;
+ </xsl:for-each>
+
+ /** The selectors */
+ <xsl:for-each
select="/map:sitemap/map:components/map:selectors/map:[EMAIL PROTECTED]">
+ private Selector selector_<xsl:value-of select="translate(./@name, '-
', '__')"/> = null;
+ </xsl:for-each>
+
+ /** The sub sitemaps */
+ <xsl:for-each select="/map:sitemap/map:pipelines//map:mount">
+ SitemapProcessor sitemap_<xsl:value-of select="position()"/> = null;
+ </xsl:for-each>
+
+ /** The generated matchers */
+ <xsl:for-each
select="/map:sitemap/map:components/map:matchers/map:[EMAIL PROTECTED]">
+ <xsl:variable name="factory" select="@factory"/>
+ <xsl:variable name="type" select="@name"/>
+ <xsl:variable name="default"><xsl:if test="$type =
../@default">true</xsl:if></xsl:variable>
+ <xsl:variable name="config"><xsl:value-of select="./*"/></xsl:variable>
+ <xsl:for-each
select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:[EMAIL
PROTECTED] or (not(@type) and $default!='')]">
+ <xsl:variable name="matcher-name1" select="translate(@pattern,'/-
*?@:{}()[].#^\\$|!','_')"/>
+ <xsl:variable name="matcher-name"
select='translate($matcher-name1,"'","")'/>
+ private Map _matcher_<xsl:value-of select="$matcher-name"/> (Request
request) {
+ <xsl:value-of select="java:getSource($matcher-factory-loader,
string($factory), string(@pattern), $config)"/>
+ }
+ </xsl:for-each>
+ </xsl:for-each>
+
+ /** The generated selectors */
+ <xsl:for-each
select="/map:sitemap/map:components/map:selectors/map:[EMAIL PROTECTED]">
+ <xsl:variable name="factory" select="@factory"/>
+ <xsl:variable name="type" select="@name"/>
+ <xsl:variable name="default"><xsl:if test="$type =
../@default">true</xsl:if></xsl:variable>
+ <xsl:variable name="config"><xsl:value-of select="./*"/></xsl:variable>
+ <xsl:for-each
select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:when[../map:select/@type=$type
or (not(../map:select/@type) and $default!='')]">
+ <xsl:variable name="selector-name1" select="translate(@test,'/-
*?@:{}()[].#^\\$|!','_')"/>
+ <xsl:variable name="selector-name"
select='translate($selector-name1,"'","")'/>
+ private boolean _selector_<xsl:value-of select="$selector-name"/>
(Request request) {
+ <xsl:value-of select="java:getSource($selector-factory-loader,
string($factory), string(@test), $config)"/>
+ }
+ </xsl:for-each>
+ </xsl:for-each>
+
+ /**
+ * Pass a <code>Configuration</code> instance to this
+ * <code>Configurable</code> class.
+ */
+ public void setConfiguration(Configuration xconf)
+ throws ConfigurationException {
AttributeImpl attr = new AttributeImpl();
+
+ <!-- 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>
+ <xsl:with-param name="components"
+ select="/map:sitemap/map:components/map:generators/map:generator"/>
+ </xsl:call-template>
+
+ /* Configure transformers */
+ <xsl:call-template name="config-components">
+ <xsl:with-param name="name">transformer</xsl:with-param>
+ <xsl:with-param name="interface">Transformer</xsl:with-param>
+ <xsl:with-param name="components"
+
select="/map:sitemap/map:components/map:transformers/map:transformer"/>
+ </xsl:call-template>
+
+ /* 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>
+ <xsl:with-param name="components"
+
select="/map:sitemap/map:components/map:serializers/map:serializer"/>
+ </xsl:call-template>
+
+ /* 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>
+ <xsl:with-param name="components"
+ select="/map:sitemap/map:components/map:matchers/map:[EMAIL
PROTECTED]"/>
+ </xsl:call-template>
+
+ /* Configure selectors */
+ <xsl:call-template name="config-components">
+ <xsl:with-param name="name">selector</xsl:with-param>
+ <xsl:with-param name="interface">Selector</xsl:with-param>
+ <xsl:with-param name="components"
+ select="/map:sitemap/map:components/map:selectors/map:[EMAIL
PROTECTED]"/>
+ </xsl:call-template>
+
+ /* Configure mounted sitemaps */
+ SitemapManager sm = SitemapManager.getInstance();
+ sm.beginRegistration (this);
+ <xsl:for-each select="/map:sitemap/map:pipelines//map:mount">
+ sitemap_<xsl:value-of select="position()"/> = sm.registerSitemap
(this, "<xsl:value-of select="@src"/>");
+ sitemap_<xsl:value-of select="position()"/>.setConfiguration (null);
+ </xsl:for-each>
+ sm.endRegistration (this);
+ }
+
+ <xsl:for-each select="/map:sitemap/map:resources/map:resource">
+ private boolean resource_<xsl:value-of select="translate(@name, '- ',
'__')"/> (ResourcePipeline pipeline,
+ Stack mapStack, Request req, Response res, OutputStream out)
+ throws SAXException, IOException, ProcessingException {
+ Map map = null;
+ Parameters param = null;
+ <xsl:apply-templates select="./*"/>
+ }
+ </xsl:for-each>
+
+ /**
+ * Process the given <code>Request</code> producing the output to the
+ * specified <code>Response</code> and <code>OutputStream</code>.
+ */
+ public boolean process(Request request, Response response, OutputStream
out)
+ throws SAXException, IOException, ProcessingException {
+ ResourcePipeline pipeline = new ResourcePipeline ();
+ Stack mapStack = new Stack();
+ Map map = null;
+ Parameters param = null;
+ <xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline">
+ try {
+ <xsl:apply-templates select="./*"/>
+ } catch (Exception e) {
+ <xsl:choose>
+ <xsl:when test="not (./map:handle-errors)">
+ throw e;
+ </xsl:when>
+ <xsl:otherwise>
+ pipeline.setGenerator (generator_error_handler,
e.getMessage(), emptyParam);
+ <xsl:apply-templates select="./map:handle-error/*"/>
+ return pipeline.process (request, response, out);
+ </xsl:otherwise>
+ </xsl:choose>
+ }
+ </xsl:for-each>
+ }
+}
+
+ </xsl:template> <!-- match="map:sitemap" -->
- <!-- 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>
- <xsl:with-param name="components"
- select="/map:sitemap/map:components/map:generators/map:generator"/>
- </xsl:call-template>
-
- /* Configure transformers */
- <xsl:call-template name="config-components">
- <xsl:with-param name="name">transformer</xsl:with-param>
- <xsl:with-param name="interface">Transformer</xsl:with-param>
- <xsl:with-param name="components"
-
select="/map:sitemap/map:components/map:transformers/map:transformer"/>
- </xsl:call-template>
-
- /* 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>
- <xsl:with-param name="components"
-
select="/map:sitemap/map:components/map:serializers/map:serializer"/>
- </xsl:call-template>
-
- /* 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>
- <xsl:with-param name="components"
- select="/map:sitemap/map:components/map:matchers/map:matcher"/>
- </xsl:call-template>
-
- /* Configure selectors */
- <xsl:call-template name="config-components">
- <xsl:with-param name="name">selector</xsl:with-param>
- <xsl:with-param name="interface">Selector</xsl:with-param>
- <xsl:with-param name="components"
- select="/map:sitemap/map:components/map:selectors/map:selector"/>
- </xsl:call-template>
-
- /* Configure mounted sitemaps */
- SitemapManager sm = SitemapManager.getInstance();
- sm.beginRegistration (this);
- <xsl:for-each select="/map:sitemap/map:pipelines//map:mount">
- sitemap_<xsl:value-of select="position()"/> = sm.registerSitemap
(this, "<xsl:value-of select="@src"/>");
- sitemap_<xsl:value-of select="position()"/>.setConfiguration (null);
- </xsl:for-each>
- sm.endRegistration (this);
- }
-
- <xsl:for-each select="/map:sitemap/map:resources/map:resource">
- private boolean resource_<xsl:value-of select="translate(@name, '- ',
'__')"/> (ResourcePipeline pipeline,
- Stack mapStack, Request req, Response res, OutputStream out)
- throws SAXException, IOException, ProcessingException {
- Map map = null;
- Parameters param = null;
- <xsl:apply-templates select="./*"/>
- }
- </xsl:for-each>
-
- /**
- * 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 = new ResourcePipeline ();
- Stack mapStack = new Stack();
- Map map = null;
- Parameters param = null;
- <xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline">
- try {
- <xsl:apply-templates select="./*"/>
- } catch (Exception e) {
- <xsl:choose>
- <xsl:when test="not (./map:handle-errors)">
- throw e;
- </xsl:when>
- <xsl:otherwise>
- pipeline.setGenerator (generator_error_hanler, e.getMessage(),
emptyParam);
- <xsl:apply-templates select="./map:handle-error/*"/>
- return pipeline.process (request, response, out);
- </xsl:otherwise>
- </xsl:choose>
- }
- </xsl:for-each>
- }
-}
-
- </xsl:template> <!-- match="map:sitemap" -->
-
- <xsl:template match="map:match">
- <xsl:variable name="matcher-type">
- <xsl:call-template name="get-parameter">
- <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="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) {
- mapStack.push (map);
- <xsl:apply-templates/>
- }
- </xsl:template> <!-- match="map:match" -->
-
- <xsl:template match="map:select">
- <xsl:variable name="selector-type">
- <xsl:call-template name="get-parameter">
- <xsl:with-param name="parname">type</xsl:with-param>
- <xsl:with-param name="default"><xsl:value-of
select="/map:sitemap/map:components/map:selectors/@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="parname">test</xsl:with-param>
- <xsl:with-param name="required">true</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- if (selector_<xsl:value-of select="translate($selector-type, '- ',
'__')"/>.select ("<xsl:value-of select="$test-value"/>", request)) {
- <xsl:apply-templates/>
- }
- </xsl:for-each>
-
- <xsl:for-each select="./map:otherwise">
- else {
- <xsl:apply-templates/>
- }
- </xsl:for-each>
- </xsl:template> <!-- match="/map:sitemap/map:select" -->
-
- <xsl:template match="map:generate">
- <xsl:call-template name="setup-component">
- <xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:generators/@default"/>
- <xsl:with-param name="method">setGenerator</xsl:with-param>
- <xsl:with-param name="prefix">generator</xsl:with-param>
- </xsl:call-template>
- </xsl:template> <!-- match="map:generate" -->
-
- <xsl:template match="map:transform">
- <xsl:call-template name="setup-component">
- <xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:transformers/@default"/>
- <xsl:with-param name="method">addTransformer</xsl:with-param>
- <xsl:with-param name="prefix">transformer</xsl:with-param>
- </xsl:call-template>
- </xsl:template> <!-- match="map:transormer" -->
-
- <xsl:template match="map:serialize">
- <xsl:call-template name="setup-component">
- <xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:serializers/@default"/>
- <xsl:with-param name="method">setSerializer</xsl:with-param>
- <xsl:with-param name="prefix">serializer</xsl:with-param>
- </xsl:call-template>
- return pipeline.process (request, response, out);
- </xsl:template> <!-- match="map:serialize" -->
-
- <xsl:template match="map:mount">
- <xsl:variable name="src" select="@src"/>
- <xsl:variable name="pos">
- <xsl:for-each select="/map:sitemap/map:pipelines//map:mount">
- <xsl:if test="@src=$src">
- <xsl:value-of select="position()"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- return sitemap_<xsl:value-of select="$pos"/>.process(request, response,
out);
- </xsl:template> <!-- match="map:mount" -->
-
- <xsl:template match="map:read">
- return read (request, response, out,
- "<xsl:value-of select="@src"/>"<xsl:if test="(@mime-type)">,
"<xsl:value-of select="@mime-type"/>"</xsl:if>);
- </xsl:template> <!-- match="map:read" -->
-
- <xsl:template match="map:redirect-to">
- <xsl:choose>
- <xsl:when test="@resource">
- return resource_<xsl:value-of select="translate(@resource, '- ',
'__')"/>(pipeline, mapStack, request, response, out);
- </xsl:when>
- <xsl:when test="@uri">
- // request.setUri ("<xsl:value-of select="@uri"/>");
- // this.process(request, response, out);
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="error">
- <xsl:with-param name="message">Missing attribute uri= or resource=
to element redirect-to</xsl:with-param>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template> <!-- match="map:redirect-to" -->
-
- <xsl:template match="map:param">
- param.setParameter ("<xsl:value-of select="@name"/>", "<xsl:value-of
select="@map:value"/>");
- </xsl:template> <!-- match="map:param" -->
-
- <!-- Sitemap Utility templates -->
-
- <xsl:template name="config-components">
- <xsl:param name="name"/>
- <xsl:param name="interface"/>
- <xsl:param name="components"/>
-
- <xsl:variable name="qname">
- <xsl:value-of select="concat($prefix, ':value')"/>
- </xsl:variable>
-
- <xsl:for-each select="$components">
+ <xsl:template match="map:match">
+ <xsl:variable name="matcher-type">
+ <xsl:call-template name="get-parameter">
+ <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="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) {
+ mapStack.push (map);
+ <xsl:apply-templates/>
+ }
+ </xsl:template> <!-- match="map:match" -->
+
+ <xsl:template match="map:select">
+ <xsl:variable name="selector-type">
+ <xsl:call-template name="get-parameter">
+ <xsl:with-param name="parname">type</xsl:with-param>
+ <xsl:with-param name="default"><xsl:value-of
select="/map:sitemap/map:components/map:selectors/@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="parname">test</xsl:with-param>
+ <xsl:with-param name="required">true</xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ if (selector_<xsl:value-of select="translate($selector-type, '- ',
'__')"/>.select ("<xsl:value-of select="$test-value"/>", request)) {
+ <xsl:apply-templates/>
+ }
+ </xsl:for-each>
+
+ <xsl:for-each select="./map:otherwise">
+ else {
+ <xsl:apply-templates/>
+ }
+ </xsl:for-each>
+ </xsl:template> <!-- match="/map:sitemap/map:select" -->
+
+ <xsl:template match="map:generate">
+ <xsl:call-template name="setup-component">
+ <xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:generators/@default"/>
+ <xsl:with-param name="method">setGenerator</xsl:with-param>
+ <xsl:with-param name="prefix">generator</xsl:with-param>
+ </xsl:call-template>
+ </xsl:template> <!-- match="map:generate" -->
+
+ <xsl:template match="map:transform">
+ <xsl:call-template name="setup-component">
+ <xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:transformers/@default"/>
+ <xsl:with-param name="method">addTransformer</xsl:with-param>
+ <xsl:with-param name="prefix">transformer</xsl:with-param>
+ </xsl:call-template>
+ </xsl:template> <!-- match="map:transormer" -->
+
+ <xsl:template match="map:serialize">
+ <xsl:call-template name="setup-component">
+ <xsl:with-param name="default-component"
select="/map:sitemap/map:components/map:serializers/@default"/>
+ <xsl:with-param name="method">setSerializer</xsl:with-param>
+ <xsl:with-param name="prefix">serializer</xsl:with-param>
+ </xsl:call-template>
+ return pipeline.process (request, response, out);
+ </xsl:template> <!-- match="map:serialize" -->
+
+ <xsl:template match="map:mount">
+ <xsl:variable name="src" select="@src"/>
+ <xsl:variable name="pos">
+ <xsl:for-each select="/map:sitemap/map:pipelines//map:mount">
+ <xsl:if test="@src=$src">
+ <xsl:value-of select="position()"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ return sitemap_<xsl:value-of select="$pos"/>.process(request, response,
out);
+ </xsl:template> <!-- match="map:mount" -->
+
+ <xsl:template match="map:read">
+ return read (request, response, out,
+ "<xsl:value-of select="@src"/>"<xsl:if test="(@mime-type)">,
"<xsl:value-of select="@mime-type"/>"</xsl:if>);
+ </xsl:template> <!-- match="map:read" -->
+
+ <xsl:template match="map:redirect-to">
+ <xsl:choose>
+ <xsl:when test="@resource">
+ return resource_<xsl:value-of select="translate(@resource, '- ',
'__')"/>(pipeline, mapStack, request, response, out);
+ </xsl:when>
+ <xsl:when test="@uri">
+ // request.setUri ("<xsl:value-of select="@uri"/>");
+ // this.process(request, response, out);
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="error">
+ <xsl:with-param name="message">Missing attribute uri= or resource=
to element redirect-to</xsl:with-param>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template> <!-- match="map:redirect-to" -->
+
+ <xsl:template match="map:param">
+ param.setParameter ("<xsl:value-of select="@name"/>", "<xsl:value-of
select="@map:value"/>");
+ </xsl:template> <!-- match="map:param" -->
+
+ <!-- Sitemap Utility templates -->
+
+ <xsl:template name="config-components">
+ <xsl:param name="name"/>
+ <xsl:param name="interface"/>
+ <xsl:param name="components"/>
+
+ <xsl:variable name="qname">
+ <xsl:value-of select="concat($prefix, ':value')"/>
+ </xsl:variable>
+
+ <xsl:for-each select="$components">
<xsl:variable name="ns" select="namespace-uri(.)"/>
- confBuilder.startDocument ();
- <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:with-param name="ns" select="$ns"/>
- </xsl:call-template>
- confBuilder.endDocument ();
- <xsl:value-of select="$name"/>_<xsl:value-of select="translate(@type,
'- ', '__')"/> =
- (<xsl:value-of select="$interface"/>)load_component ("<xsl:value-of
select="@src"/>", confBuilder.getConfiguration());
- </xsl:for-each>
- </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="ns"/>
- <xsl:param name="subname"/>
-
- <xsl:variable name="qname">
- <xsl:value-of select="concat($prefix, ':value')"/>
- </xsl:variable>
-
- <!-- process content -->
- <xsl:for-each select="$components">
+ confBuilder.startDocument ();
+ <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(.),'/',@name)"/></xsl:with-param>
+ <xsl:with-param name="interface" select="$interface"/>
+ <xsl:with-param name="components" select="*"/>
+ <xsl:with-param name="type" select="@name"/>
+ <xsl:with-param name="ns" select="$ns"/>
+ </xsl:call-template>
+ confBuilder.endDocument ();
+ <xsl:value-of select="$name"/>_<xsl:value-of select="translate(@name,
'- ', '__')"/> =
+ (<xsl:value-of select="$interface"/>)load_component ("<xsl:value-of
select="@src"/>",
+ confBuilder.getConfiguration());
+ </xsl:for-each>
+ </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="ns"/>
+ <xsl:param name="subname"/>
+
+ <xsl:variable name="qname">
+ <xsl:value-of select="concat($prefix, ':value')"/>
+ </xsl:variable>
+
+ <!-- process content -->
+ <xsl:for-each select="$components">
<xsl:if test="$ns!=namespace-uri()">
confBuilder.startPrefixMapping("","<xsl:value-of
select="namespace-uri()"/>");
</xsl:if>
@@ -377,125 +385,125 @@
<xsl:if test="normalize-space(text())">
confBuilder.characters("<xsl:value-of
select="text()"/>".toCharArray(), 0, <xsl:value-of
select="string-length(text())"/>);
</xsl:if>
- <xsl:variable name="newsubname">
- <xsl:choose>
- <xsl:when test="not($subname)"><xsl:value-of
select="position()"/></xsl:when>
- <xsl:otherwise><xsl:value-of
select="concat($subname,position())"/></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="ns"><xsl:value-of
select="namespace-uri()"/></xsl:with-param>
- <xsl:with-param name="subname"><xsl:value-of
select="$newsubname"/></xsl:with-param>
- </xsl:call-template>
+ <xsl:variable name="newsubname">
+ <xsl:choose>
+ <xsl:when test="not($subname)"><xsl:value-of
select="position()"/></xsl:when>
+ <xsl:otherwise><xsl:value-of
select="concat($subname,position())"/></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="ns"><xsl:value-of
select="namespace-uri()"/></xsl:with-param>
+ <xsl:with-param name="subname"><xsl:value-of
select="$newsubname"/></xsl:with-param>
+ </xsl:call-template>
confBuilder.endElement("<xsl:value-of select="namespace-uri()"/>",
"<xsl:value-of select="local-name(.)"/>", "<xsl:value-of select="name(.)"/>");
<xsl:if test="$ns!=namespace-uri()">
confBuilder.endPrefixMapping("","<xsl:value-of
select="namespace-uri()"/>");
</xsl:if>
- </xsl:for-each>
- </xsl:template>
-
- <xsl:template name="setup-component">
- <xsl:param name="default-component"/>
- <xsl:param name="method"/>
- <xsl:param name="prefix"/>
- <xsl:variable name="component-type">
- <xsl:call-template name="get-parameter">
- <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="parname">src</xsl:with-param>
- <xsl:with-param name="default">null</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- <xsl:if test="descendant::map:param">
- param = new Parameters ();
- </xsl:if>
- <xsl:variable name="component-param">
- <xsl:choose>
- <xsl:when test="descendant::map:param">
- param
- </xsl:when>
- <xsl:otherwise>
- emptyParam
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <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"/>);
- </xsl:when>
- <xsl:otherwise>
- pipeline.<xsl:value-of select="$method"/> (<xsl:value-of
select="$prefix"/>_<xsl:value-of select="$component-type"/>,
- "<xsl:value-of select="$component-source"/>",
<xsl:value-of select="$component-param"/>);
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- Utility templates -->
-
- <xsl:template name="get-parameter">
- <xsl:param name="parname"/>
- <xsl:param name="default"/>
- <xsl:param name="required">false</xsl:param>
-
- <xsl:variable name="qname">
- <xsl:value-of select="concat($prefix, ':param')"/>
- </xsl:variable>
-
- <xsl:choose>
- <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] =
$parname]"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="string-length($default) = 0">
- <xsl:choose>
- <xsl:when test="$required = 'true'">
- <xsl:call-template name="error">
- <xsl:with-param name="message">[Logicsheet processor]
-Parameter '<xsl:value-of select="$parname"/>' missing in dynamic tag
<<xsl:value-of select="name(.)"/>>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>""</xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise><xsl:copy-of select="$default"/></xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="get-nested-content">
- <xsl:param name="content"/>
- <xsl:choose>
- <xsl:when test="$content/*">
- <xsl:apply-templates select="$content/*"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$content"/></xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="error">
- <xsl:param name="message"/>
- <xsl:message terminate="yes"><xsl:value-of
select="$message"/></xsl:message>
- </xsl:template>
-
- <!-- Ignored elements -->
- <xsl:template match="map:logicsheet|map:dependency|map:handle-errors"/>
-
-</xsl:stylesheet>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="setup-component">
+ <xsl:param name="default-component"/>
+ <xsl:param name="method"/>
+ <xsl:param name="prefix"/>
+ <xsl:variable name="component-type">
+ <xsl:call-template name="get-parameter">
+ <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="parname">src</xsl:with-param>
+ <xsl:with-param name="default">null</xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:if test="descendant::map:param">
+ param = new Parameters ();
+ </xsl:if>
+ <xsl:variable name="component-param">
+ <xsl:choose>
+ <xsl:when test="descendant::map:param">
+ param
+ </xsl:when>
+ <xsl:otherwise>
+ emptyParam
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <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"/>);
+ </xsl:when>
+ <xsl:otherwise>
+ pipeline.<xsl:value-of select="$method"/> (<xsl:value-of
select="$prefix"/>_<xsl:value-of select="$component-type"/>,
+ "<xsl:value-of select="$component-source"/>",
<xsl:value-of select="$component-param"/>);
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- Utility templates -->
+
+ <xsl:template name="get-parameter">
+ <xsl:param name="parname"/>
+ <xsl:param name="default"/>
+ <xsl:param name="required">false</xsl:param>
+
+ <xsl:variable name="qname">
+ <xsl:value-of select="concat($prefix, ':param')"/>
+ </xsl:variable>
+
+ <xsl:choose>
+ <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] =
$parname]"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="string-length($default) = 0">
+ <xsl:choose>
+ <xsl:when test="$required = 'true'">
+ <xsl:call-template name="error">
+ <xsl:with-param name="message">[Logicsheet processor]
+Parameter '<xsl:value-of select="$parname"/>' missing in dynamic tag
<<xsl:value-of select="name(.)"/>>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>""</xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise><xsl:copy-of select="$default"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="get-nested-content">
+ <xsl:param name="content"/>
+ <xsl:choose>
+ <xsl:when test="$content/*">
+ <xsl:apply-templates select="$content/*"/>
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$content"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="error">
+ <xsl:param name="message"/>
+ <xsl:message terminate="yes"><xsl:value-of
select="$message"/></xsl:message>
+ </xsl:template>
+
+ <!-- Ignored elements -->
+ <xsl:template match="map:logicsheet|map:dependency|map:handle-errors"/>
+
+</xsl:stylesheet>
No revision
No revision
1.1.2.3 +23 -3
xml-cocoon/src/org/apache/cocoon/matching/Attic/BrowserMatcherFactory.java
Index: BrowserMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/BrowserMatcherFactory.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- BrowserMatcherFactory.java 2000/07/12 22:15:11 1.1.2.2
+++ BrowserMatcherFactory.java 2000/07/17 21:06:11 1.1.2.3
@@ -6,17 +6,37 @@
* the LICENSE file.
*
*****************************************************************************/
package org.apache.cocoon.matching;
+
+import java.util.Stack;
+
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.xerces.dom.
/**
* This class generates source code which matches a specific browser pattern
* for request URIs
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/12 22:15:11 $
+ * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/17 21:06:11 $
*/
public class BrowserMatcherFactory implements MatcherFactory {
- public String generate (String test_expression) {
- return "return null;";
+ public String generate (String test_expression, DocumentFragment conf) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("/*\n");
+
+ Stack st = new Stack();
+ Node node = conf.getFirstChild();
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node node = nl.item(i);
+ sb.append("name="+node.getNodeName()
+ +" type="+node.getNodeType()
+ +" value="+node.getNodeValue()+"\n");
+ }
+ sb.append("*/return null;");
+ return (sb.toString());
}
}
1.1.2.2 +23 -23
xml-cocoon/src/org/apache/cocoon/matching/Attic/Matcher.java
Index: Matcher.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/Matcher.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- Matcher.java 2000/07/11 23:46:42 1.1.2.1
+++ Matcher.java 2000/07/17 21:06:11 1.1.2.2
@@ -1,23 +1,23 @@
-/*****************************************************************************
- * 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.matching;
-
-import java.util.Map;
-
-import org.apache.cocoon.sitemap.SitemapComponent;
-import org.apache.cocoon.Request;
-
-/**
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:42 $
- */
-public interface Matcher extends SitemapComponent {
+/*****************************************************************************
+ * 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.matching;
+
+import java.util.Map;
+
+import org.apache.cocoon.sitemap.SitemapComponent;
+import org.apache.cocoon.Request;
+
+/**
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:11 $
+ */
+public interface Matcher extends SitemapComponent {
/**
* Matches the pattern against some <code>Request</code> values
* and returns a <code>Map</code> object with replacements
@@ -32,6 +32,6 @@
* contained in the pattern.
* If the return value is null there was no match.
*/
- public Map match (String pattern, Request request);
-}
-
+ public Map match (String pattern, Request request);
+}
+
1.1.2.2 +4 -2
xml-cocoon/src/org/apache/cocoon/matching/Attic/MatcherFactory.java
Index: MatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/MatcherFactory.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- MatcherFactory.java 2000/07/11 23:46:43 1.1.2.1
+++ MatcherFactory.java 2000/07/17 21:06:11 1.1.2.2
@@ -6,6 +6,8 @@
* the LICENSE file.
*
*****************************************************************************/
package org.apache.cocoon.matching;
+
+import org.w3c.dom.DocumentFragment;
/**
* Interface a class has to implement that produces java source code
@@ -16,9 +18,9 @@
* sitemap code generation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:43 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:11 $
*/
public interface MatcherFactory {
- public String generate (String pattern) throws Exception;
+ public String generate (String pattern, DocumentFragment conf) throws
Exception;
}
1.1.2.2 +6 -4
xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java
Index: WildcardURIMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- WildcardURIMatcherFactory.java 2000/07/11 23:46:44 1.1.2.1
+++ WildcardURIMatcherFactory.java 2000/07/17 21:06:12 1.1.2.2
@@ -9,13 +9,15 @@
import org.apache.cocoon.sitemap.patterns.PatternTranslator;
import org.apache.cocoon.sitemap.patterns.PatternException;
+
+import org.w3c.dom.DocumentFragment;
/**
* This class generates source code which represents a specific pattern
matcher
* for request URIs
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:44 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:12 $
*/
public class WildcardURIMatcherFactory /*extends PatternTranslator*/
implements MatcherFactory {
@@ -33,7 +35,7 @@
/**
* Generates the matcher method source code
*/
- public String generate (String pattern)
+ public String generate (String pattern, DocumentFragment conf)
throws PatternException {
StringBuffer result = new StringBuffer();
this.setPattern (pattern);
@@ -51,7 +53,7 @@
result.append (sourcePattern[j]);
result.append ("};");
result.append ("if
(org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (stack,
request.getUri(), expr))");
- result.append ("return stack;");
+ result.append ("return (Map) stack;");
result.append ("else return null;");
return result.toString();
}
@@ -140,7 +142,7 @@
if (argv.length<1) return;
System.out.println("Matching Expr. \""+argv[0]+"\"");
WildcardURIMatcherFactory wm = new WildcardURIMatcherFactory();
- System.out.println(wm.generate (argv[0]));
+ System.out.println(wm.generate (argv[0], null));
} catch (Exception e) {
System.out.println(e.getClass().getName());
System.out.println(e.getMessage());
No revision
No revision
1.1.2.2 +4 -2
xml-cocoon/src/org/apache/cocoon/selection/Attic/BrowserSelectorFactory.java
Index: BrowserSelectorFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/BrowserSelectorFactory.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- BrowserSelectorFactory.java 2000/07/12 22:15:12 1.1.2.1
+++ BrowserSelectorFactory.java 2000/07/17 21:06:12 1.1.2.2
@@ -6,17 +6,19 @@
* the LICENSE file.
*
*****************************************************************************/
package org.apache.cocoon.selection;
+
+import org.w3c.dom.DocumentFragment;
/**
* This class generates source code which tests a specific browser pattern
* agains the requesting user-agent
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/12 22:15:12 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:12 $
*/
public class BrowserSelectorFactory implements SelectorFactory {
- public String generate (String test_expression) {
+ public String generate (String test_expression, DocumentFragment conf) {
return "return true;";
}
}
1.1.2.2 +22 -22
xml-cocoon/src/org/apache/cocoon/selection/Attic/Selector.java
Index: Selector.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/Selector.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- Selector.java 2000/07/11 23:46:47 1.1.2.1
+++ Selector.java 2000/07/17 21:06:12 1.1.2.2
@@ -1,21 +1,21 @@
-/*****************************************************************************
- * 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.selection;
-
-import org.apache.cocoon.sitemap.SitemapComponent;
-import org.apache.cocoon.Request;
-
-/**
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:47 $
- */
-public interface Selector extends SitemapComponent {
+/*****************************************************************************
+ * 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.selection;
+
+import org.apache.cocoon.sitemap.SitemapComponent;
+import org.apache.cocoon.Request;
+
+/**
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:12 $
+ */
+public interface Selector extends SitemapComponent {
/**
* Selectors test pattern against some <code>Request</code> values
* and signals success with the returned boolean value
@@ -24,7 +24,7 @@
* to select values to test the expression.
* @return boolean Signals successfull test.
*/
- public boolean select (String expression, Request request);
-}
-
-
+ public boolean select (String expression, Request request);
+}
+
+
1.1.2.2 +4 -2
xml-cocoon/src/org/apache/cocoon/selection/Attic/SelectorFactory.java
Index: SelectorFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/SelectorFactory.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- SelectorFactory.java 2000/07/12 22:15:13 1.1.2.1
+++ SelectorFactory.java 2000/07/17 21:06:13 1.1.2.2
@@ -6,6 +6,8 @@
* the LICENSE file.
*
*****************************************************************************/
package org.apache.cocoon.selection;
+
+import org.w3c.dom.DocumentFragment;
/**
* Interface a class has to implement that produces java source code
@@ -16,9 +18,9 @@
* sitemap code generation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/12 22:15:13 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:13 $
*/
public interface SelectorFactory {
- public String generate (String test) throws Exception;
+ public String generate (String test, DocumentFragment conf) throws
Exception;
}
No revision
No revision
1.1.2.2 +57 -57
xml-cocoon/src/org/apache/cocoon/serialization/Attic/FO2PDFSerializer.java
Index: FO2PDFSerializer.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/FO2PDFSerializer.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- FO2PDFSerializer.java 2000/07/11 23:46:49 1.1.2.1
+++ FO2PDFSerializer.java 2000/07/17 21:06:13 1.1.2.2
@@ -1,66 +1,66 @@
-/*****************************************************************************
- * 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.serialization;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-
-import org.apache.avalon.utils.Parameters;
-import org.apache.cocoon.Request;
-import org.apache.cocoon.Response;
+/*****************************************************************************
+ * 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.serialization;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import org.apache.avalon.utils.Parameters;
+import org.apache.cocoon.Request;
+import org.apache.cocoon.Response;
import org.apache.cocoon.xml.util.DocumentHandlerWrapper;
-
-import org.apache.fop.apps.Driver;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.Version;
-
-//import org.xml.sax.Attributes;
-//import org.xml.sax.AttributeList;
-import org.xml.sax.DocumentHandler;
-//import org.xml.sax.helpers.AttributeListImpl;
-//import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-/**
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * (PWR Organisation & Entwicklung)
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/11 23:46:49 $
+
+import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.Version;
+
+//import org.xml.sax.Attributes;
+//import org.xml.sax.AttributeList;
+import org.xml.sax.DocumentHandler;
+//import org.xml.sax.helpers.AttributeListImpl;
+//import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
*
- */
+ * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
+ * (PWR Organisation & Entwicklung)
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:13 $
+ *
+ */
public class FO2PDFSerializer extends DocumentHandlerWrapper
- implements Serializer {
+ implements Serializer {
/**
* The FOP driver
- */
- private Driver driver = null;
-
- /**
- * Set the <code>Request</code>, <code>Response</code> and sitemap
- * <code>Parameters</code> used to process the request.
- */
- public void setup(Request req, Response res, String src, Parameters par)
{
- driver = new Driver();
- driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",
Version.getVersion());
- driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
- driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
+ */
+ private Driver driver = null;
+
+ /**
+ * Set the <code>Request</code>, <code>Response</code> and sitemap
+ * <code>Parameters</code> used to process the request.
+ */
+ public void setup(Request req, Response res, String src, Parameters par)
{
+ driver = new Driver();
+ driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",
Version.getVersion());
+ driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
+ driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
res.setContentType(par.getParameter("contentType","application/pdf"));
- this.setDocumentHandler (driver.getDocumentHandler());
- }
-
- /**
- * Set the <code>OutputStream</code> where the XML should be serialized.
- */
- public void setOutputStream(OutputStream out) {
- driver.setWriter(new PrintWriter(out));
- }
+ this.setDocumentHandler (driver.getDocumentHandler());
+ }
+
+ /**
+ * Set the <code>OutputStream</code> where the XML should be serialized.
+ */
+ public void setOutputStream(OutputStream out) {
+ driver.setWriter(new PrintWriter(out));
+ }
/**
* Receive notification of the end of a document.
@@ -77,4 +77,4 @@
throw new SAXException (e);
}
}
-}
+}
No revision
No revision
1.1.2.4 +39 -32
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.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- AbstractSitemapProcessor.java 2000/07/11 03:10:03 1.1.2.3
+++ AbstractSitemapProcessor.java 2000/07/17 21:06:14 1.1.2.4
@@ -26,7 +26,7 @@
* Base class for XSP-generated <code>SitemapProcessor</code> classes
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/11 03:10:03 $
+ * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/17 21:06:14 $
*/
public abstract class AbstractSitemapProcessor
implements SitemapProcessor {
@@ -47,42 +47,46 @@
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;
+ /**
+ * 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;
}
- for (int i = 0; i < dependencies.length; i++) {
- if (dateCreated < dependencies[i].lastModified()) {
+ /**
+ * 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;
- }
}
- 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
*/
- protected Object load_component (String ClassURL, Configuration conf) {
return (""); }
+ protected Object load_component (String ClassURL, Configuration conf) {
+ return ("");
+ }
+
/**
* Resolve a link against a source into the target URI space.
*/
@@ -92,8 +96,11 @@
}
/**
- * Constructs a <code>ResourcePipeline</code> for the
<code>Request</code>.
+ * Constructs a resource to the supplied <code>OutputStream</code>
+ * for the <code>Request</code> and <code>Response</code> arguments.
* This method is supplied by the generated SitemapProcessor .
*/
- protected abstract ResourcePipeline constructPipeline (Request request,
Response resposne);
- /** Following methods are for testing purposes only and should later be
deleted */ protected boolean uri_wildcard_matcher (String pattern) {
return (true); } protected boolean uri_regexp_matcher (String pattern)
{ return (true); } protected boolean browser_matcher (String
pattern) { return (true); } }
\ No newline at end of file
+/*
+ public abstract boolean process (Request request, Response resposne,
OutputStream out);
+*/
+}
\ No newline at end of file
1.1.2.5 +2 -2
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ResourcePipeline.java
Index: ResourcePipeline.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ResourcePipeline.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- ResourcePipeline.java 2000/07/11 23:46:54 1.1.2.4
+++ ResourcePipeline.java 2000/07/17 21:06:14 1.1.2.5
@@ -26,7 +26,7 @@
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/11 23:46:54 $
+ * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/17 21:06:14 $
*/
public class ResourcePipeline {
private Generator generator = null;
@@ -60,7 +60,7 @@
this.transformerParams.add (param);
}
- public boolean startPipeline (Request req, Response res, OutputStream
out)
+ public boolean process (Request req, Response res, OutputStream out)
throws ProcessingException, IOException,
SAXException {
if (generator == null) {
throw new ProcessingException ("Generator not specified");
1.1.2.3 +5 -3
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTMatcherFactoryLoader.java
Index: XSLTMatcherFactoryLoader.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTMatcherFactoryLoader.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- XSLTMatcherFactoryLoader.java 2000/07/12 22:15:17 1.1.2.2
+++ XSLTMatcherFactoryLoader.java 2000/07/17 21:06:14 1.1.2.3
@@ -8,6 +8,8 @@
package org.apache.cocoon.sitemap;
import org.apache.cocoon.matching.MatcherFactory;
+
+import org.w3c.dom.DocumentFragment;
/**
* This class is used as a XSLT extension class. It is used by the sitemap
@@ -15,15 +17,15 @@
* generated source code.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/12 22:15:17 $
+ * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/17 21:06:14 $
*/
public class XSLTMatcherFactoryLoader {
- public String getSource (String matcherFactoryClassname, String pattern)
+ public String getSource (String matcherFactoryClassname, String pattern,
DocumentFragment conf)
throws ClassNotFoundException, InstantiationException,
IllegalAccessException, Exception {
Class cl =
this.getClass().getClassLoader().loadClass(matcherFactoryClassname);
MatcherFactory factory = (MatcherFactory) cl.newInstance();
- return factory.generate (pattern);
+ return factory.generate (pattern, conf);
}
}
1.1.2.2 +5 -3
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTSelectorFactoryLoader.java
Index: XSLTSelectorFactoryLoader.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/XSLTSelectorFactoryLoader.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- XSLTSelectorFactoryLoader.java 2000/07/12 22:15:18 1.1.2.1
+++ XSLTSelectorFactoryLoader.java 2000/07/17 21:06:14 1.1.2.2
@@ -8,6 +8,8 @@
package org.apache.cocoon.sitemap;
import org.apache.cocoon.selection.SelectorFactory;
+
+import org.w3c.dom.DocumentFragment;
/**
* This class is used as a XSLT extension class. It is used by the sitemap
@@ -15,15 +17,15 @@
* generated source code.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/07/12 22:15:18 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/17 21:06:14 $
*/
public class XSLTSelectorFactoryLoader {
- public String getSource (String selectorFactoryClassname, String test)
+ public String getSource (String selectorFactoryClassname, String test,
DocumentFragment conf)
throws ClassNotFoundException, InstantiationException,
IllegalAccessException, Exception {
Class cl =
this.getClass().getClassLoader().loadClass(selectorFactoryClassname);
SelectorFactory factory = (SelectorFactory) cl.newInstance();
- return factory.generate (test);
+ return factory.generate (test, conf);
}
}
No revision
No revision
1.1.2.10 +22 -18 xml-cocoon/xdocs/drafts/Attic/sitemap-working-draft.xmap
Index: sitemap-working-draft.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon/xdocs/drafts/Attic/sitemap-working-draft.xmap,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- sitemap-working-draft.xmap 2000/07/12 22:15:26 1.1.2.9
+++ sitemap-working-draft.xmap 2000/07/17 21:06:15 1.1.2.10
@@ -226,7 +226,7 @@
-->
<map:matchers default="uri-wildcard">
<map:matcher name="uri-wildcard"
factory="org.apache.cocoon.matching.WildcardURIMatcherFactory">
- ...
+ ...
</map:matcher>
<map:matcher name="uri-regexp"
src="class:///org.apache.cocoon.matching.RegexpURIMatcher">
@@ -234,7 +234,11 @@
</map:matcher>
<map:matcher name="browser"
factory="org.apache.cocoon.matching.BrowserMatcherFactory">
- ...
+ <foo value="bar">baz</foo>
+ <lines>
+ <left>red</left>
+ <right>white</right>
+ </lines>
</map:matcher>
</map:matchers>
@@ -359,7 +363,7 @@
match some of their parameters
-->
<map:match pattern="cocoon/dist/*">
- <map:choose type="ip-filter">
+ <map:select type="ip-filter">
<map:when test="allowsAddress()">
<!--
the <redirect-to> element is used to redirect one requested URI
@@ -370,7 +374,7 @@
<map:otherwise>
<map:redirect-to resource="Access refused"/>
</map:otherwise>
- </map:choose>
+ </map:select>
</map:match>
<!--
@@ -385,7 +389,7 @@
</map:match>
<map:match pattern="images/logo">
- <map:choose>
+ <map:select>
<map:when test="accepts('image/svg')">
<!--
the <map:read> element is used to read the src directly without
@@ -396,20 +400,20 @@
</map:when>
<map:otherwise>
<map:generate src="./images/logo.svg"/>
- <map:choose>
+ <map:select>
<map:when test="accepts('image/png')">
<map:serialize type="svg2png"/>
</map:when>
<map:otherwise>
<map:serialize type="svg2jpg"/>
</map:otherwise>
- </map:choose>
+ </map:select>
</map:otherwise>
- </map:choose>
+ </map:select>
</map:match>
<map:match pattern="restricted/*">
- <map:choose type="user">
+ <map:select type="user">
<map:when test="is('administrator')">
<map:generate src="./restricted/{1}"/>
<map:transform src="./stylesheets/restricted.xsl"/>
@@ -418,7 +422,7 @@
<map:otherwise>
<map:redirect-to resource="Access refused"/>
</map:otherwise>
- </map:choose>
+ </map:select>
</map:match>
<!--
@@ -445,7 +449,7 @@
</map:match>
</map:match>
- <map:match type="uri-regexp"
pattern="/\([0-9]\{4\}\)/\([0-9]\{2\}\)/\([0-9]\{2\}\)/">
+ <map:match type="uri-regexp" pattern="([0-9]{4})/([0-9]{2})/([0-9]{2})/">
<!--
Here we implement the ability to indicate semantic information
on the processed URI. This is mostly used to avoid to encode
@@ -458,33 +462,33 @@
<map:param name="month" value="{2}"/>
<map:param name="day" value="{3}"/>
- <map:generate name="serverpages" src="./dailynews.xsp"/>
+ <map:generate type="serverpages" src="./dailynews.xsp"/>
<map:transform src="./stylesheet/{1}/news.xsl"/>
<map:serialize/>
</map:match>
<map:match pattern="*">
<map:generate src="{1}.xml"/>
- <map:choose type="load">
+ <map:select type="load">
<map:when test="greaterThen('2.5')">
<map:transform src="./stylesheet/low-graphics.xsl"/>
</map:when>
<map:otherwise>
- <map:choose>
+ <map:select>
<map:when test="is('Mozilla5')">
<map:transform src="./stylesheet/xul-enabled.xsl"/>
</map:when>
<map:otherwise>
<map:transform src="./stylesheet/general-browser.xsl"/>
</map:otherwise>
- </map:choose>
+ </map:select>
</map:otherwise>
- </map:choose>
+ </map:select>
<map:serialize/>
</map:match>
<map:handle-errors>
- <map:choose>
+ <map:select>
<map:when test="accepts('text/vnd.wap.wml')">
<map:transform src="./styles/Pipeline2WML.xsl"/>
<map:serialize type="wap"/>
@@ -493,7 +497,7 @@
<map:transform src="./styles/Pipeline2HTML.xsl"/>
<map:serialize/>
</map:otherwise>
- </map:choose>
+ </map:select>
</map:handle-errors>
</map:pipeline>