cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r687670 - in /cocoon/whiteboard/corona/trunk/corona-stringtemplate: pom.xml src/main/java/org/apache/cocoon/corona/stringtemplate/StringTemplateGenerator.java
Date Thu, 21 Aug 2008 09:41:12 GMT
Author: reinhard
Date: Thu Aug 21 02:41:09 2008
New Revision: 687670

URL: http://svn.apache.org/viewvc?rev=687670&view=rev
Log:
Escapes the characters in a String using XML entities using StringEscapeUtils.escapeXML()

Modified:
    cocoon/whiteboard/corona/trunk/corona-stringtemplate/pom.xml
    cocoon/whiteboard/corona/trunk/corona-stringtemplate/src/main/java/org/apache/cocoon/corona/stringtemplate/StringTemplateGenerator.java

Modified: cocoon/whiteboard/corona/trunk/corona-stringtemplate/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-stringtemplate/pom.xml?rev=687670&r1=687669&r2=687670&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-stringtemplate/pom.xml (original)
+++ cocoon/whiteboard/corona/trunk/corona-stringtemplate/pom.xml Thu Aug 21 02:41:09 2008
@@ -49,6 +49,10 @@
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
     </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
         
     <dependency>
       <groupId>junit</groupId>

Modified: cocoon/whiteboard/corona/trunk/corona-stringtemplate/src/main/java/org/apache/cocoon/corona/stringtemplate/StringTemplateGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-stringtemplate/src/main/java/org/apache/cocoon/corona/stringtemplate/StringTemplateGenerator.java?rev=687670&r1=687669&r2=687670&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-stringtemplate/src/main/java/org/apache/cocoon/corona/stringtemplate/StringTemplateGenerator.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-stringtemplate/src/main/java/org/apache/cocoon/corona/stringtemplate/StringTemplateGenerator.java
Thu Aug 21 02:41:09 2008
@@ -24,6 +24,7 @@
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.antlr.stringtemplate.AttributeRenderer;
 import org.antlr.stringtemplate.StringTemplate;
 import org.apache.cocoon.corona.pipeline.caching.CacheKey;
 import org.apache.cocoon.corona.pipeline.caching.CompoundCacheKey;
@@ -33,6 +34,7 @@
 import org.apache.cocoon.corona.pipeline.component.sax.AbstractXMLProducer;
 import org.apache.cocoon.corona.servlet.controller.ControllerContextHelper;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLReaderFactory;
@@ -90,6 +92,11 @@
             InputStream inputStream = this.source.openStream();
             try {
                 StringTemplate stringTemplate = new StringTemplate(IOUtils.toString(inputStream,
"UTF-8"));
+                stringTemplate.registerRenderer(String.class, new AttributeRenderer() {
+                    public String toString(Object object) {
+                        return StringEscapeUtils.escapeXml(object.toString());
+                    }
+                });
 
                 Map<String, Object> controllerContext = ControllerContextHelper.getContext(this.parameters);
                 for (Entry<String, Object> eachEntry : controllerContext.entrySet())
{



Mime
View raw message