sylvain 2003/01/09 10:20:19 Modified: . changes.xml src/java/org/apache/cocoon/components/treeprocessor/sitemap ReadNode.java ReadNodeBuilder.java SerializeNode.java SerializeNodeBuilder.java src/java/org/apache/cocoon/components/treeprocessor/variables PreparedVariableResolver.java VariableResolver.java src/webapp/WEB-INF cocoon.xconf Log: Added sitemap variable expansion to "mime-type" in <map:read> and <map:serialize> Revision Changes Path 1.334 +5 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.333 retrieving revision 1.334 diff -u -r1.333 -r1.334 --- changes.xml 9 Jan 2003 17:39:45 -0000 1.333 +++ changes.xml 9 Jan 2003 18:20:19 -0000 1.334 @@ -40,6 +40,10 @@ </devs> <release version="@version@" date="@date@"> + <action dev="SW" type="update"> + The "mime-type" attribute on <map:read> and <map:serialize> is now + expanded if it contains sitemap variables. + </action> <action dev="CH" type="add"> InputModule to access XMLForm instances. </action> 1.6 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java Index: ReadNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ReadNode.java 5 Dec 2002 10:25:51 -0000 1.5 +++ ReadNode.java 9 Jan 2003 18:20:19 -0000 1.6 @@ -71,7 +71,7 @@ private VariableResolver source; - private String mimeType; + private VariableResolver mimeType; private int statusCode; @@ -84,7 +84,7 @@ * @param mimeType the mime-type, or <code>null</code> not specified. * @param statusCode the HTTP response status code, or <code>-1</code> if not specified. */ - public ReadNode(String name, VariableResolver source, String mimeType, int statusCode) { + public ReadNode(String name, VariableResolver source, VariableResolver mimeType, int statusCode) { this.readerName = name; this.source = source; this.mimeType = mimeType; @@ -106,7 +106,7 @@ this.readerName, source.resolve(context, objectModel), VariableResolver.buildParameters(this.parameters, context, objectModel), - this.mimeType + this.mimeType.resolve(context, objectModel) ); // Set status code if there is one 1.4 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNodeBuilder.java Index: ReadNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNodeBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ReadNodeBuilder.java 5 Dec 2002 10:25:51 -0000 1.3 +++ ReadNodeBuilder.java 9 Jan 2003 18:20:19 -0000 1.4 @@ -72,7 +72,7 @@ ReadNode node = new ReadNode( type, VariableResolverFactory.getResolver(config.getAttribute("src", null), this.manager), - config.getAttribute("mime-type", null), + VariableResolverFactory.getResolver(config.getAttribute("mime-type", null), this.manager), config.getAttributeAsInteger("status-code", -1) ); 1.10 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java Index: SerializeNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- SerializeNode.java 7 Jan 2003 23:56:12 -0000 1.9 +++ SerializeNode.java 9 Jan 2003 18:20:19 -0000 1.10 @@ -73,7 +73,7 @@ private String serializerName; - private String mimeType; + private VariableResolver mimeType; private int statusCode; @@ -85,7 +85,7 @@ * @param mimeType the mime-type, or <code>null</code> not specified. * @param statusCode the HTTP response status code, or <code>-1</code> if not specified. */ - public SerializeNode(String name, String mimeType, int statusCode) throws PatternException { + public SerializeNode(String name, VariableResolver mimeType, int statusCode) throws PatternException { this.serializerName = name; this.mimeType = mimeType; this.statusCode = statusCode; @@ -135,7 +135,7 @@ this.pipelineHints == null ? Parameters.EMPTY_PARAMETERS : VariableResolver.buildParameters(this.pipelineHints, context, objectModel), - this.mimeType + this.mimeType.resolve(context, env.getObjectModel()) ); // Set status code if there is one 1.4 +4 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNodeBuilder.java Index: SerializeNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNodeBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SerializeNodeBuilder.java 5 Dec 2002 10:25:51 -0000 1.3 +++ SerializeNodeBuilder.java 9 Jan 2003 18:20:19 -0000 1.4 @@ -54,6 +54,8 @@ import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; + import org.apache.cocoon.serialization.Serializer; import java.util.Collection; @@ -87,7 +89,7 @@ this.node = new SerializeNode( type, - config.getAttribute("mime-type", null), + VariableResolverFactory.getResolver(config.getAttribute("mime-type", null), this.manager), config.getAttributeAsInteger("status-code", -1) ); this.node.setPipelineHints(this.pipelineHints); 1.9 +15 -7 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java Index: PreparedVariableResolver.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- PreparedVariableResolver.java 5 Dec 2002 10:25:52 -0000 1.8 +++ PreparedVariableResolver.java 9 Jan 2003 18:20:19 -0000 1.9 @@ -79,11 +79,12 @@ final private List items = new ArrayList(); // Special constants used for levels + // ROOT and ANCHOR are placed first as they need a context to be resolved (see resolve()) static final int ROOT = 0; - static final int LITERAL = -1; - static final int THREADSAFE_MODULE = -2; - static final int STATEFUL_MODULE = -3; - static final int ANCHOR = -4; + static final int ANCHOR = -1; + static final int LITERAL = -2; + static final int THREADSAFE_MODULE = -3; + static final int STATEFUL_MODULE = -4; private static final Integer ROOT_OBJ = new Integer(ROOT); private static final Integer LITERAL_OBJ = new Integer(LITERAL); @@ -222,14 +223,21 @@ } public final String resolve(InvokeContext context, Map objectModel) throws PatternException { - List mapStack = context.getMapStack(); + List mapStack = null; // = context.getMapStack(); + int stackSize = 0; StringBuffer result = new StringBuffer(); - int stackSize = mapStack.size(); - for (int i = 0; i < this.items.size(); i++) { int type = ((Integer)this.items.get(i)).intValue(); + + if (type >= ANCHOR && mapStack == null) { + if (context == null) { + throw new PatternException("Need an invoke context to resolve " + this); + } + mapStack = context.getMapStack(); + stackSize = mapStack.size(); + } if (type > 0) { // relative sitemap variable 1.6 +8 -1 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolver.java Index: VariableResolver.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolver.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- VariableResolver.java 5 Dec 2002 10:25:52 -0000 1.5 +++ VariableResolver.java 9 Jan 2003 18:20:19 -0000 1.6 @@ -102,6 +102,13 @@ } /** + * Resolve all {...} patterns using the values given in the object model. + */ + public String resolve(Map objectModel) throws PatternException { + return resolve(null, objectModel); + } + + /** * Resolve all {...} patterns using the values given in the list of maps and the object model. */ public abstract String resolve(InvokeContext context, Map objectModel) throws PatternException; 1.53 +3 -3 xml-cocoon2/src/webapp/WEB-INF/cocoon.xconf Index: cocoon.xconf =================================================================== RCS file: /home/cvs/xml-cocoon2/src/webapp/WEB-INF/cocoon.xconf,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- cocoon.xconf 9 Jan 2003 05:46:43 -0000 1.52 +++ cocoon.xconf 9 Jan 2003 18:20:19 -0000 1.53 @@ -132,9 +132,6 @@ <!-- Allows access to resources available from the ClassLoader, using getResource() method. --> <protocol class="org.apache.cocoon.components.url.ResourceURLFactory" name="resource"/> - <!-- Allows access to resources available from the servlet context, - using getResource() method. --> - <protocol class="org.apache.cocoon.components.url.ContextURLFactory" name="context"/> <!-- Add here protocol factories for your own protocols --> </url-factory> @@ -147,6 +144,9 @@ <source-handler logger="core.source-handler"> <!-- file protocol : this is a WriteableSource --> <protocol class="org.apache.cocoon.components.source.FileSourceFactory" name="file"/> + <!-- Allows access to resources available from the servlet context, + using getResource() method. --> + <protocol class="org.apache.cocoon.components.source.ContextSourceFactory" name="context"/> </source-handler>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]