incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r825035 - in /sling/trunk/contrib/extensions/rewriter: ./ src/main/java/org/apache/sling/rewriter/impl/components/
Date Wed, 14 Oct 2009 07:04:13 GMT
Author: cziegeler
Date: Wed Oct 14 07:04:12 2009
New Revision: 825035

URL: http://svn.apache.org/viewvc?rev=825035&view=rev
Log:
Finish new implementation.

Modified:
    sling/trunk/contrib/extensions/rewriter/pom.xml
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/AbstractTraxSerializerFactory.java
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/HtmlSerializerFactory.java
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/TraxSerializer.java
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/XHtmlSerializerFactory.java

Modified: sling/trunk/contrib/extensions/rewriter/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/pom.xml?rev=825035&r1=825034&r2=825035&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/pom.xml (original)
+++ sling/trunk/contrib/extensions/rewriter/pom.xml Wed Oct 14 07:04:12 2009
@@ -65,8 +65,7 @@
                         </Export-Package>
                         <Private-Package>
                             org.apache.sling.rewriter.impl,
-                            org.apache.cocoon.components.serializers.encoding,
-                            org.apache.cocoon.components.serializers.util
+                            org.apache.sling.rewriter.impl.components
                         </Private-Package>
                     </instructions>
                 </configuration>

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/AbstractTraxSerializerFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/AbstractTraxSerializerFactory.java?rev=825035&r1=825034&r2=825035&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/AbstractTraxSerializerFactory.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/AbstractTraxSerializerFactory.java
Wed Oct 14 07:04:12 2009
@@ -55,6 +55,9 @@
     private boolean needsNamespacesAsAttributes;
 
     protected abstract String getOutputFormat();
+    protected abstract String getDoctypePublic();
+    protected abstract String getDoctypeSystem();
+
     /**
      * @see org.apache.sling.rewriter.SerializerFactory#createSerializer()
      */
@@ -72,7 +75,7 @@
         } else {
             ch = tHandler;
         }
-        return new TraxSerializer(tHandler, ch, getOutputFormat());
+        return new TraxSerializer(tHandler, ch, getOutputFormat(), getDoctypePublic(), getDoctypeSystem());
     }
 
     protected void activate(final ComponentContext ctx) {

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/HtmlSerializerFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/HtmlSerializerFactory.java?rev=825035&r1=825034&r2=825035&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/HtmlSerializerFactory.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/HtmlSerializerFactory.java
Wed Oct 14 07:04:12 2009
@@ -30,4 +30,11 @@
         return "html";
     }
 
+    protected String getDoctypePublic() {
+        return "-//W3C//DTD HTML 4.01 Transitional//EN";
+    }
+
+    protected String getDoctypeSystem() {
+        return "http://www.w3.org/TR/html4/loose.dtd";
+    }
 }

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/TraxSerializer.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/TraxSerializer.java?rev=825035&r1=825034&r2=825035&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/TraxSerializer.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/TraxSerializer.java
Wed Oct 14 07:04:12 2009
@@ -51,12 +51,16 @@
     private final LexicalHandler lexicalHandler;
 
     public TraxSerializer(final TransformerHandler transformerHandler,
-                                  final ContentHandler handler,
-                                  final String outputFormat) {
+                          final ContentHandler handler,
+                          final String outputFormat,
+                          final String doctypePublic,
+                          final String doctypeSystem) {
         this.contentHandler = handler;
         this.lexicalHandler = (LexicalHandler)handler;
         this.transformerHandler = transformerHandler;
         this.format.put(OutputKeys.METHOD, outputFormat);
+        this.format.put(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
+        this.format.put(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
     }
 
     /**
@@ -68,21 +72,22 @@
         if ( this.transformerHandler == null ) {
             throw new IOException("Transformer handler could not be instantiated.");
         }
-
-        if (!this.format.containsKey(OutputKeys.ENCODING)) {
+        if ( context.getResponse().getCharacterEncoding() != null ) {
+            this.format.put(OutputKeys.ENCODING, context.getResponse().getCharacterEncoding());
+        } else {
             this.format.put(OutputKeys.ENCODING, DEFAULT_ENCODING);
         }
 
-        String cdataSectionElements = config.getConfiguration().get("cdata-section-elements",
String.class);
-        String dtPublic = config.getConfiguration().get("doctype-public", String.class);
-        String dtSystem = config.getConfiguration().get("doctype-system", String.class);
-        String encoding = config.getConfiguration().get("encoding", String.class);
-        String indent = config.getConfiguration().get("indent", String.class);
-        String mediaType = config.getConfiguration().get("media-type", String.class);
-        String method = config.getConfiguration().get("method", String.class);
-        String omitXMLDeclaration = config.getConfiguration().get("omit-xml-declaration",
String.class);
-        String standAlone = config.getConfiguration().get("standalone", String.class);
-        String version = config.getConfiguration().get("version", String.class);
+        final String cdataSectionElements = config.getConfiguration().get("cdata-section-elements",
String.class);
+        final String dtPublic = config.getConfiguration().get("doctype-public", String.class);
+        final String dtSystem = config.getConfiguration().get("doctype-system", String.class);
+        final String encoding = config.getConfiguration().get("encoding", String.class);
+        final String indent = config.getConfiguration().get("indent", String.class);
+        final String mediaType = config.getConfiguration().get("media-type", String.class);
+        final String method = config.getConfiguration().get("method", String.class);
+        final String omitXMLDeclaration = config.getConfiguration().get("omit-xml-declaration",
String.class);
+        final String standAlone = config.getConfiguration().get("standalone", String.class);
+        final String version = config.getConfiguration().get("version", String.class);
 
         if (cdataSectionElements != null) {
             format.put(OutputKeys.CDATA_SECTION_ELEMENTS, cdataSectionElements);

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/XHtmlSerializerFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/XHtmlSerializerFactory.java?rev=825035&r1=825034&r2=825035&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/XHtmlSerializerFactory.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/components/XHtmlSerializerFactory.java
Wed Oct 14 07:04:12 2009
@@ -29,4 +29,12 @@
     protected String getOutputFormat() {
         return "xhtml";
     }
+
+    protected String getDoctypePublic() {
+        return "-//W3C//DTD XHTML 1.0 Strict//EN";
+    }
+
+    protected String getDoctypeSystem() {
+        return "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
+    }
 }



Mime
View raw message