You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gc...@apache.org on 2004/01/28 17:59:31 UTC
cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/transformation DASLTransformer.java
gcasper 2004/01/28 08:59:31
Modified: src/blocks/webdav/java/org/apache/cocoon/transformation
DASLTransformer.java
Log:
substitution values for DASL queries
PR: 26460
Submitted by: Daniele Madama (d.madama@pro-netics.com)
Revision Changes Path
1.4 +31 -0 cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java
Index: DASLTransformer.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DASLTransformer.java 20 Dec 2003 02:38:45 -0000 1.3
+++ DASLTransformer.java 28 Jan 2004 16:59:31 -0000 1.4
@@ -118,6 +118,19 @@
* lt;/D:searchrequestgt;
* lt;/dasl:querygt;
*
+ * Features
+ * - Substitution of a value: with this feature it's possible to pass value from sitemap
+ * that are substituted into a query.
+ * sitemap example:
+ * lt;map:transformer type="dasl"gt;
+ * lt;parameter name="repos" value="/repos/"gt;
+ * lt;/map:transformergt;
+ * query example:
+ * ....
+ * lt;D:hrefgt;lt;substitute-value name="repos"/gt;lt;/D:hrefgt;
+ * ....
+ * This feature is like substitute-value of SQLTransformer
+ *
* TODO: the SWCL Search method doesn't preserve the result order, which makes
* order-by clauses useless.
*
@@ -141,6 +154,10 @@
static final String WEBDAV_SCHEME = "webdav://";
/** The tag name of root_tag for result */
static final String RESULT_ROOT_TAG = "query-result";
+ /** The tag name for substitution of query parameter */
+ static final String SUBSTITUTE_TAG = "substitute-value";
+ /** The tag name for substitution of query parameter */
+ static final String SUBSTITUTE_TAG_NAME_ATTRIBUTE = "name";
protected static final String PATH_NODE_NAME = "path";
protected static final String RESOURCE_NODE_NAME = "resource";
@@ -170,6 +187,17 @@
"http://" + targetUrl.substring(WEBDAV_SCHEME.length());
if (!targetUrl.startsWith("http"))
throw new SAXException("Illegal value for target, must be an http:// or webdav:// URL");
+ } else if (name.equals(SUBSTITUTE_TAG) && uri.equals(DASL_QUERY_NS)) {
+ String parName = attr.getValue( DASL_QUERY_NS, SUBSTITUTE_TAG_NAME_ATTRIBUTE );
+ if ( parName == null ) {
+ throw new IllegalStateException( "Substitute value elements must have a " +
+ SUBSTITUTE_TAG_NAME_ATTRIBUTE + " attribute" );
+ }
+ String substitute = this.parameters.getParameter( parName, null );
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug( "SUBSTITUTE VALUE " + substitute );
+ }
+ super.characters(substitute.toCharArray(), 0, substitute.length());
} else {
super.startElement(uri, name, raw, attr);
}
@@ -193,6 +221,8 @@
} catch (ProcessingException e) {
throw new SAXException("Unable to fetch the query data:", e);
}
+ } else if (name.equals(SUBSTITUTE_TAG) && uri.equals(DASL_QUERY_NS)) {
+ //Do nothing!!!!
} else {
super.endElement(uri, name, raw);
}
@@ -263,3 +293,4 @@
}
}
+