You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2009/10/15 09:51:28 UTC
svn commit: r825425 - in /cocoon/cocoon3/trunk:
cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/
cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/
cocoon-optional/src/main/java/org/apache/cocoon/optional/serv...
Author: reinhard
Date: Thu Oct 15 07:51:28 2009
New Revision: 825425
URL: http://svn.apache.org/viewvc?rev=825425&view=rev
Log:
add EncodingXMLSerializer, EncodingXHTMLSerializer, EncodingHTMLSerializer that use the cocoon-serializers-charsets library instead of JAXP
add integration tests
add samples
Added:
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingHTMLSerializer.java (with props)
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXHTMLSerializer.java (with props)
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXMLSerializer.java (with props)
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/util/
cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/util/ConfigurationUtils.java (with props)
cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml (with props)
cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SerializersTest.java (with props)
Modified:
cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ExpressionLanguageTest.java
cocoon/cocoon3/trunk/cocoon-sample/pom.xml
cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml
Added: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingHTMLSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingHTMLSerializer.java?rev=825425&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingHTMLSerializer.java (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingHTMLSerializer.java Thu Oct 15 07:51:28 2009
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.optional.servlet.components.sax.serializers;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+import org.apache.cocoon.components.serializers.util.EncodingSerializer;
+import org.apache.cocoon.optional.servlet.components.sax.serializers.util.ConfigurationUtils;
+import org.apache.cocoon.pipeline.SetupException;
+import org.apache.cocoon.pipeline.caching.CacheKey;
+import org.apache.cocoon.pipeline.caching.ParameterCacheKey;
+import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
+import org.apache.cocoon.pipeline.component.Finisher;
+import org.apache.cocoon.pipeline.util.StringRepresentation;
+import org.apache.cocoon.sax.SAXConsumer;
+import org.apache.cocoon.sax.SAXPipelineComponent;
+import org.apache.cocoon.servlet.util.HttpContextHelper;
+
+/**
+ * <p>
+ * A serializer converting XHTML into plain old HTML.
+ * </p>
+ *
+ * <p>
+ * For configuration options of this serializer, please look at the {@link EncodingXHTMLSerializer} and
+ * {@link EncodingSerializer}.
+ * </p>
+ *
+ * <p>
+ * Any of the XHTML document type declared or used will be converted into its HTML 4.01 counterpart,
+ * and in addition to those a "compatible" doctype can be supported to exploit a couple of shortcuts
+ * into MSIE's rendering engine. The values for the <code>doctype-default</code> can then be:
+ * </p>
+ *
+ * <dl>
+ * <dt>"<code>none</code>"</dt>
+ * <dd>Not to emit any dococument type declaration.</dd>
+ * <dt>"<code>compatible</code>"</dt>
+ * <dd>The HTML 4.01 Transitional (exploiting MSIE shortcut).</dd>
+ * <dt>"<code>strict</code>"</dt>
+ * <dd>The HTML 4.01 Strict document type.</dd>
+ * <dt>"<code>loose</code>"</dt>
+ * <dd>The HTML 4.01 Transitional document type.</dd>
+ * <dt>"<code>frameset</code>"</dt>
+ * <dd>The HTML 4.01 Frameset document type.</dd>
+ * </dl>
+ *
+ * @version $Id$
+ */
+public class EncodingHTMLSerializer extends org.apache.cocoon.components.serializers.util.HTMLSerializer implements
+ SAXPipelineComponent, Finisher, SAXConsumer, CachingPipelineComponent {
+
+ private String encoding;
+ private int indent = 0;
+ private String docType;
+
+ public CacheKey constructCacheKey() {
+ ParameterCacheKey parameterCacheKey = new ParameterCacheKey();
+ parameterCacheKey.addParameter("encoding", this.encoding);
+ parameterCacheKey.addParameter("indent", this.indent);
+ parameterCacheKey.addParameter("docType", this.docType);
+ return parameterCacheKey;
+ }
+
+ public void finish() {
+ }
+
+ public String getContentType() {
+ return this.getMimeType();
+ }
+
+ public void setConfiguration(Map<String, ? extends Object> configuration) {
+ try {
+ this.encoding = ConfigurationUtils.getEncoding(configuration);
+ this.setEncoding(this.encoding);
+ } catch (UnsupportedEncodingException e) {
+ throw new SetupException(e);
+ }
+
+ try {
+ this.indent = ConfigurationUtils.getIndent(configuration);
+ this.setIndentPerLevel(this.indent);
+ } catch (NumberFormatException nfe) {
+ throw new SetupException(nfe);
+ }
+
+ this.docType = (String) configuration.get("doctype-default");
+ this.setDoctypeDefault(this.docType);
+ }
+
+ @Override
+ public void setOutputStream(OutputStream outputStream) {
+ try {
+ super.setOutputStream(outputStream);
+ } catch (IOException e) {
+ throw new SetupException(e);
+ }
+ }
+
+ public void setup(Map<String, Object> parameters) {
+ this.setup(HttpContextHelper.getRequest(parameters));
+ }
+
+ @Override
+ public String toString() {
+ return StringRepresentation.buildString(this);
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingHTMLSerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingHTMLSerializer.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingHTMLSerializer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXHTMLSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXHTMLSerializer.java?rev=825425&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXHTMLSerializer.java (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXHTMLSerializer.java Thu Oct 15 07:51:28 2009
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.optional.servlet.components.sax.serializers;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+import org.apache.cocoon.optional.servlet.components.sax.serializers.util.ConfigurationUtils;
+import org.apache.cocoon.pipeline.SetupException;
+import org.apache.cocoon.pipeline.caching.CacheKey;
+import org.apache.cocoon.pipeline.caching.ParameterCacheKey;
+import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
+import org.apache.cocoon.pipeline.component.Finisher;
+import org.apache.cocoon.pipeline.util.StringRepresentation;
+import org.apache.cocoon.sax.SAXConsumer;
+import org.apache.cocoon.sax.SAXPipelineComponent;
+import org.apache.cocoon.servlet.util.HttpContextHelper;
+
+/**
+ * <p>
+ * A pedantinc XHTML serializer encoding all recognized entities with their proper HTML names.
+ * </p>
+ *
+ * <p>
+ * For configuration options of this serializer, please look at the
+ * {@link org.apache.cocoon.components.serializers.util.EncodingSerializer}, in addition to those,
+ * this serializer also support the specification of a default doctype. This default will be used if
+ * no document type is received in the SAX events, and can be configured in the following way:
+ * </p>
+ *
+ * <pre>
+ * <map:serialize type="exhtml" doctype-default="mytype" />
+ * </pre>
+ *
+ * <p>
+ * The value <i>mytype</i> can be one of:
+ * </p>
+ *
+ * <dl>
+ * <dt>"<code>none</code>"</dt>
+ * <dd>Not to emit any dococument type declaration.</dd>
+ * <dt>"<code>strict</code>"</dt>
+ * <dd>The XHTML 1.0 Strict document type.</dd>
+ * <dt>"<code>loose</code>"</dt>
+ * <dd>The XHTML 1.0 Transitional document type.</dd>
+ * <dt>"<code>frameset</code>"</dt>
+ * <dd>The XHTML 1.0 Frameset document type.</dd>
+ * </dl>
+ *
+ *
+ * @version $Id$
+ */
+public class EncodingXHTMLSerializer extends org.apache.cocoon.components.serializers.util.XHTMLSerializer implements
+ SAXPipelineComponent, Finisher, SAXConsumer, CachingPipelineComponent {
+
+ private String encoding;
+ private int indent = 0;
+ private String omitXmlDeclaration;
+ private String docType;
+
+ public CacheKey constructCacheKey() {
+ ParameterCacheKey parameterCacheKey = new ParameterCacheKey();
+ parameterCacheKey.addParameter("encoding", this.encoding);
+ parameterCacheKey.addParameter("indent", this.indent);
+ parameterCacheKey.addParameter("docType", this.docType);
+ parameterCacheKey.addParameter("omitXmlDeclaration", this.omitXmlDeclaration);
+ return parameterCacheKey;
+ }
+
+ public void finish() {
+ }
+
+ public String getContentType() {
+ return this.getMimeType();
+ }
+
+ public void setConfiguration(Map<String, ? extends Object> configuration) {
+ try {
+ this.encoding = ConfigurationUtils.getEncoding(configuration);
+ this.setEncoding(this.encoding);
+ } catch (UnsupportedEncodingException e) {
+ throw new SetupException(e);
+ }
+
+ try {
+ this.indent = ConfigurationUtils.getIndent(configuration);
+ this.setIndentPerLevel(this.indent);
+ } catch (NumberFormatException nfe) {
+ throw new SetupException(nfe);
+ }
+
+ this.omitXmlDeclaration = (String) configuration.get("omit-xml-declaration");
+ this.setOmitXmlDeclaration(this.omitXmlDeclaration);
+
+ this.docType = (String) configuration.get("doctype-default");
+ this.setDoctypeDefault(this.docType);
+ }
+
+ @Override
+ public void setOutputStream(OutputStream outputStream) {
+ try {
+ super.setOutputStream(outputStream);
+ } catch (IOException e) {
+ throw new SetupException(e);
+ }
+ }
+
+ public void setup(Map<String, Object> parameters) {
+ this.setup(HttpContextHelper.getRequest(parameters));
+ }
+
+ @Override
+ public String toString() {
+ return StringRepresentation.buildString(this);
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXHTMLSerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXHTMLSerializer.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXHTMLSerializer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXMLSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXMLSerializer.java?rev=825425&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXMLSerializer.java (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXMLSerializer.java Thu Oct 15 07:51:28 2009
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.optional.servlet.components.sax.serializers;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+import org.apache.cocoon.optional.servlet.components.sax.serializers.util.ConfigurationUtils;
+import org.apache.cocoon.pipeline.SetupException;
+import org.apache.cocoon.pipeline.caching.CacheKey;
+import org.apache.cocoon.pipeline.caching.ParameterCacheKey;
+import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
+import org.apache.cocoon.pipeline.component.Finisher;
+import org.apache.cocoon.pipeline.util.StringRepresentation;
+import org.apache.cocoon.sax.SAXConsumer;
+import org.apache.cocoon.sax.SAXPipelineComponent;
+import org.apache.cocoon.servlet.util.HttpContextHelper;
+
+/**
+ * <p>
+ * A fancy XML serializer not relying on the JAXP API.
+ * </p>
+ *
+ * @version $Id$
+ */
+public class EncodingXMLSerializer extends org.apache.cocoon.components.serializers.util.XMLSerializer implements
+ SAXPipelineComponent, Finisher, SAXConsumer, CachingPipelineComponent {
+
+ private String encoding;
+ private int indent = 0;
+
+ public CacheKey constructCacheKey() {
+ ParameterCacheKey parameterCacheKey = new ParameterCacheKey();
+ parameterCacheKey.addParameter("encoding", this.encoding);
+ parameterCacheKey.addParameter("indent", this.indent);
+ return parameterCacheKey;
+ }
+
+ public void finish() {
+ }
+
+ public String getContentType() {
+ return this.getMimeType();
+ }
+
+ public void setConfiguration(Map<String, ? extends Object> configuration) {
+ try {
+ this.encoding = ConfigurationUtils.getEncoding(configuration);
+ this.setEncoding(this.encoding);
+ } catch (UnsupportedEncodingException e) {
+ throw new SetupException(e);
+ }
+
+ try {
+ this.indent = ConfigurationUtils.getIndent(configuration);
+ this.setIndentPerLevel(this.indent);
+ } catch (NumberFormatException nfe) {
+ throw new SetupException(nfe);
+ }
+
+ }
+
+ @Override
+ public void setOutputStream(OutputStream outputStream) {
+ try {
+ super.setOutputStream(outputStream);
+ } catch (IOException e) {
+ throw new SetupException(e);
+ }
+ }
+
+ public void setup(Map<String, Object> parameters) {
+ this.setup(HttpContextHelper.getRequest(parameters));
+ }
+
+ @Override
+ public String toString() {
+ return StringRepresentation.buildString(this);
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXMLSerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXMLSerializer.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/EncodingXMLSerializer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/util/ConfigurationUtils.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/util/ConfigurationUtils.java?rev=825425&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/util/ConfigurationUtils.java (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/util/ConfigurationUtils.java Thu Oct 15 07:51:28 2009
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.optional.servlet.components.sax.serializers.util;
+
+import java.util.Map;
+
+public class ConfigurationUtils {
+
+ private ConfigurationUtils() {
+ }
+
+ public static String getEncoding(Map<String, ? extends Object> configuration) {
+ String encoding = (String) configuration.get("encoding");
+
+ if (encoding == null || "".equals(encoding)) {
+ encoding = "UTF-8";
+ }
+
+ return encoding;
+ }
+
+ public static int getIndent(Map<String, ? extends Object> configuration) {
+ int indent = 0;
+ String indentConf = (String) configuration.get("indent");
+ if (indentConf != null && !"".equals(indentConf)) {
+ indent = Integer.parseInt(indentConf);
+ }
+ return indent;
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/util/ConfigurationUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/util/ConfigurationUtils.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/servlet/components/sax/serializers/util/ConfigurationUtils.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml?rev=825425&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml Thu Oct 15 07:51:28 2009
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<!-- $Id$ -->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+ <bean name="serializer:exml" class="org.apache.cocoon.optional.servlet.components.sax.serializers.EncodingXMLSerializer"
+ scope="prototype" />
+
+ <bean name="serializer:exhtml" class="org.apache.cocoon.optional.servlet.components.sax.serializers.EncodingXHTMLSerializer"
+ scope="prototype" />
+
+ <bean name="serializer:ehtml" class="org.apache.cocoon.optional.servlet.components.sax.serializers.EncodingHTMLSerializer"
+ scope="prototype" />
+</beans>
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ExpressionLanguageTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ExpressionLanguageTest.java?rev=825425&r1=825424&r2=825425&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ExpressionLanguageTest.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/ExpressionLanguageTest.java Thu Oct 15 07:51:28 2009
@@ -57,5 +57,4 @@
assertEquals("text/xml", this.response.getContentType());
this.assertXPath("/simple", "simple-text");
}
-
}
Added: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SerializersTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SerializersTest.java?rev=825425&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SerializersTest.java (added)
+++ cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SerializersTest.java Thu Oct 15 07:51:28 2009
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.it;
+
+/**
+ * Test the serializers components.
+ */
+public class SerializersTest extends CocoonHtmlUnitTestCase {
+
+ public void testEXML() throws Exception {
+ this.loadResponse("/serializers/exml");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/xml", this.response.getContentType());
+ assertEquals("utf-8", this.response.getContentCharSet());
+ assertTrue(this.response.getContentAsString().indexOf("-//W3C//DTD XHTML 1.0 Strict//EN") == -1);
+ }
+
+ public void testEXHTML() throws Exception {
+ this.loadResponse("/serializers/exhtml");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/html", this.response.getContentType());
+ assertEquals("utf-8", this.response.getContentCharSet());
+ assertTrue(this.response.getContentAsString().indexOf("-//W3C//DTD XHTML 1.0 Strict//EN") > 0);
+ }
+
+ public void testEHTML() throws Exception {
+ this.loadResponse("/serializers/ehtml");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/html", this.response.getContentType());
+ assertEquals("iso-8859-1", this.response.getContentCharSet());
+ assertTrue(this.response.getContentAsString().indexOf("-//W3C//DTD HTML 4.01 Transitional//EN") > 0);
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SerializersTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SerializersTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SerializersTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cocoon/cocoon3/trunk/cocoon-sample/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/pom.xml?rev=825425&r1=825424&r2=825425&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/pom.xml Thu Oct 15 07:51:28 2009
@@ -67,7 +67,11 @@
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cocoon</groupId>
+ <artifactId>cocoon-serializers-charsets</artifactId>
+ </dependency>
<!-- Other dependencies -->
<dependency>
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html?rev=825425&r1=825424&r2=825425&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html Thu Oct 15 07:51:28 2009
@@ -109,5 +109,11 @@
<ul>
<li><a href="fop/test.pdf">PDF</a>: Create a PDF document by using Apache FOP.</li>
</ul>
+ <h2>Encoding Serializers</h2>
+ <ul>
+ <li><a href="serializers/exml">eXML</a>: A XML serializer not relying on the JAXP API.</li>
+ <li><a href="serializers/exhtml">eXHTML</a>: A pedantinc XHTML serializer encoding all recognized entities with their proper HTML names.</li>
+ <li><a href="serializers/ehtml">eHTML</a>: A serializer converting XHTML into plain old HTML.</li>
+ </ul>
</body>
</html>
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap?rev=825425&r1=825424&r2=825425&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap Thu Oct 15 07:51:28 2009
@@ -415,6 +415,7 @@
</map:handle-errors>
</map:pipeline>
+ <!-- FOP -->
<map:pipeline>
<map:match pattern="fop/test.pdf">
<map:generate src="fop/page.xml" />
@@ -423,6 +424,32 @@
</map:match>
</map:pipeline>
+ <!-- Encoding serializers -->
+ <map:pipeline>
+ <map:match equals="serializers/exml">
+ <map:generate src="sax-pipeline/simple.xml" />
+ <map:transform src="sax-pipeline/simple.xslt">
+ <map:parameter name="myParam" value="1" />
+ </map:transform>
+ <map:serialize type="exml" indent="2"/>
+ </map:match>
+ <map:match equals="serializers/exhtml">
+ <map:generate src="sax-pipeline/simple.xml" />
+ <map:transform src="sax-pipeline/simple.xslt">
+ <map:parameter name="myParam" value="2" />
+ </map:transform>
+ <map:serialize type="exhtml" doctype-default="strict" />
+ </map:match>
+ <map:match equals="serializers/ehtml">
+ <map:generate src="sax-pipeline/simple.xml" />
+ <map:transform src="sax-pipeline/simple.xslt">
+ <map:parameter name="myParam" value="2" />
+ </map:transform>
+ <map:serialize type="ehtml" encoding="iso-8859-1"/>
+ </map:match>
+ </map:pipeline>
+
+ <!-- Global error handling -->
<map:handle-errors>
<map:select value="{jexl:cocoon.exception.class.name}">
<map:when contains="NoMatchingPipelineException">
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml?rev=825425&r1=825424&r2=825425&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml Thu Oct 15 07:51:28 2009
@@ -23,4 +23,5 @@
<import resource="classpath:META-INF/cocoon/spring-optional/cocoon-optional-fop.xml" />
+ <import resource="classpath:META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml" />
</beans>