cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r1447255 - /cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/neko/NekoGenerator.java
Date Mon, 18 Feb 2013 13:44:57 GMT
Author: thorsten
Date: Mon Feb 18 13:44:57 2013
New Revision: 1447255

URL: http://svn.apache.org/r1447255
Log:
COCOON3-120
Making nekoGenerator configurable. You can now inject the default encoding via the sitemap
like:
<map:generate src="{global:host}.html" type="html">
  <map:parameter name="default-encoding" value="UTF-8"/>
</map:generate>

Modified:
    cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/neko/NekoGenerator.java

Modified: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/neko/NekoGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/neko/NekoGenerator.java?rev=1447255&r1=1447254&r2=1447255&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/neko/NekoGenerator.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/neko/NekoGenerator.java
Mon Feb 18 13:44:57 2013
@@ -29,6 +29,7 @@ import org.apache.cocoon.sax.AbstractSAX
 import org.apache.cocoon.sax.AbstractSAXProducer;
 import org.apache.cocoon.sax.SAXConsumer;
 import org.apache.cocoon.sax.component.XMLGenerator;
+import org.apache.commons.lang.StringUtils;
 import org.cyberneko.html.parsers.SAXParser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,6 +40,8 @@ import org.xml.sax.SAXNotSupportedExcept
 
 public class NekoGenerator extends AbstractSAXGenerator {
 
+    public static final String DEFAULT_ENCODING = "http://cyberneko.org/html/properties/default-encoding";
+
     public static final String BALANCE_TAGS_URI = "http://cyberneko.org/html/features/balance-tags";
 
     public static final String ELEMS_URI = "http://cyberneko.org/html/properties/names/elems";
@@ -108,6 +111,14 @@ public class NekoGenerator extends Abstr
     public void setConfiguration(Map<String, ? extends Object> configuration) {
         ((URLGenerator) this.generator).setSource((URL) configuration
                 .get("source"));
+        try {
+            String value = (String) configuration.get("default-encoding");
+            if(StringUtils.isNotBlank(value)) {
+                this.saxParser.setProperty(DEFAULT_ENCODING, value);
+            }
+        } catch (Exception e) {
+            LOG.error("Fatal could not set default-encoding. ", e);
+        }
     }
 
     @Override



Mime
View raw message