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 2004/11/27 15:55:03 UTC

svn commit: r106717 - in cocoon/branches/BRANCH_2_1_X: . lib lib/optional src/blocks/forms/conf src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor src/blocks/forms/samples src/blocks/forms/samples/flow src/blocks/forms/samples/forms src/blocks/forms/samples/resources src/java/org/apache/cocoon/xml

Author: reinhard
Date: Sat Nov 27 06:55:02 2004
New Revision: 106717

URL: http://svn.apache.org/viewcvs?view=rev&rev=106717
Log:
sync htmlarea enchancements and fixes with trunk (cleaning, XMLStringStreaming, examples, htmlarea in tables)
Added:
   cocoon/branches/BRANCH_2_1_X/lib/optional/daisy-htmlcleaner-1.1.jar   (contents, props changed)
   cocoon/branches/BRANCH_2_1_X/lib/optional/daisy-util-1.1.jar   (contents, props changed)
   cocoon/branches/BRANCH_2_1_X/lib/optional/nekodtd-0.1.10.jar   (contents, props changed)
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleanerConfiguration.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/StringXMLizable.java
Modified:
   cocoon/branches/BRANCH_2_1_X/gump.xml
   cocoon/branches/BRANCH_2_1_X/lib/jars.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/conf/forms-datatype.xconf
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/htmlarea.js
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_success.jx
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_template.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-htmlarea-styling.xsl
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-lib.js
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-samples-styling.xsl
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap
   cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/gump.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/gump.xml?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/gump.xml&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/gump.xml&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/gump.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/gump.xml	Sat Nov 27 06:55:02 2004
@@ -854,9 +854,15 @@
     <depend project="xreporter-expression"/>
     <depend project="jakarta-oro"/>
     <depend project="cocoon-block-xsp" type="samples"/>
+    <depend project="nekohtml"/>
+    <depend project="nekodtd"/>
+    <depend project="daisy-util"/>
+    <depend project="daisy-htmlcleaner"/>
 
     <library name="xreporter-expression"/>
     <library name="jakarta-oro"/>
+    <library name="neko"/>
+    <library name="daisy"/>    
 
     <work nested="build/cocoon-@@DATE@@/blocks/forms/test"/>
     <work nested="tools/anttasks"/>
@@ -1474,5 +1480,20 @@
   <project name="cocoon-serializers-charsets">
     <jar name="lib/optional/cocoon-serializers-charsets-0.1.jar"/>
   </project>
+
+  <project name="nekodtd">
+    <package>org.cyberneko.dtd</package>
+    <jar name="lib/optional/nekodtd-0.1.10.jar"/>
+  </project>  
+
+  <project name="daisy-htmlcleaner">
+    <package>org.outerj.daisy.htmlcleaner</package>
+    <jar name="lib/optional/daisy-htmlcleaner-1.1.jar"/>
+  </project>  
+  
+  <project name="daisy-util">
+    <package>org.outerj.daisy.xmlutil</package>
+    <jar name="lib/optional/daisy-util-1.1.jar"/>
+  </project>     
 
 </module>

Modified: cocoon/branches/BRANCH_2_1_X/lib/jars.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/lib/jars.xml?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/lib/jars.xml&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/lib/jars.xml&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/lib/jars.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/lib/jars.xml	Sat Nov 27 06:55:02 2004
@@ -518,13 +518,42 @@
   </file>
 
   <file>
-    <title>Transform HTML to XML</title>
+    <title>CyberNeko: Transform HTML to XML</title>
     <description>NekoHTML is a lightweight HTML syntax correcter written using Xerces Native Interface.</description>
     <used-by>NekoHTML generator (html block)</used-by>
     <lib>optional/nekohtml-0.9.3.jar</lib>
     <homepage>http://www.apache.org/~andyc/neko/</homepage>
   </file>
 
+  <file>
+    <title>CyberNeko DTD Converter</title>
+    <description>NekoHTML is a lightweight HTML syntax correcter written using Xerces Native Interface.</description>
+    <used-by>Forms block</used-by>
+    <lib>optional/nekodtd-0.1.10.jar</lib>
+    <homepage>http://www.apache.org/~andyc/neko/</homepage>
+  </file>
+  
+  <file>
+    <title>Daisy HTMLCleaner</title>
+    <description>
+      NekoHTML, but then performs further filtering, conversion and restructuring 
+      on it to have a nice output, limitted to a subset of the HTML DTD
+    </description>
+    <used-by>Forms block</used-by>
+    <lib>optional/daisy-htmlcleaner-1.1.jar</lib>
+    <homepage>http://daisy.cocoondev.org/</homepage>
+  </file>  
+
+  <file>
+    <title>Daisy Utils</title>
+    <description>
+      Java Utility classes of Daisy
+    </description>
+    <used-by>Forms block - HTMLCleaner</used-by>
+    <lib>optional/daisy-util-1.1.jar</lib>
+    <homepage>http://daisy.cocoondev.org/</homepage>
+  </file>   
+  
   <file>
     <title>Search engine</title>
     <description>

Added: cocoon/branches/BRANCH_2_1_X/lib/optional/daisy-htmlcleaner-1.1.jar
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/lib/optional/daisy-htmlcleaner-1.1.jar?view=auto&rev=106717
==============================================================================
Binary file. No diff available.

Added: cocoon/branches/BRANCH_2_1_X/lib/optional/daisy-util-1.1.jar
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/lib/optional/daisy-util-1.1.jar?view=auto&rev=106717
==============================================================================
Binary file. No diff available.

Added: cocoon/branches/BRANCH_2_1_X/lib/optional/nekodtd-0.1.10.jar
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/lib/optional/nekodtd-0.1.10.jar?view=auto&rev=106717
==============================================================================
Binary file. No diff available.

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/conf/forms-datatype.xconf
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/conf/forms-datatype.xconf?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/conf/forms-datatype.xconf&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/conf/forms-datatype.xconf&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/conf/forms-datatype.xconf	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/conf/forms-datatype.xconf	Sat Nov 27 06:55:02 2004
@@ -25,6 +25,7 @@
       <datatype name="string" src="org.apache.cocoon.forms.datatype.typeimpl.StringTypeBuilder">
         <convertors default="dummy" plain="dummy">
           <convertor name="dummy" src="org.apache.cocoon.forms.datatype.convertor.DummyStringConvertorBuilder"/>
+          <convertor name="htmlcleaner" src="org.apache.cocoon.forms.datatype.convertor.HtmlCleaningConvertorBuilder"/>
         </convertors>
       </datatype>
       <datatype name="integer" src="org.apache.cocoon.forms.datatype.typeimpl.IntegerTypeBuilder">

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleanerConfiguration.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleanerConfiguration.xml?view=auto&rev=106717
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleanerConfiguration.xml	Sat Nov 27 06:55:02 2004
@@ -0,0 +1,143 @@
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<htmlcleaner>
+  <cleanup>
+    <!-- Span elements will only be retained if they have one of the classes listed belowed. -->
+    <allowed-span-classes>
+    </allowed-span-classes>
+
+    <!-- Div elements will only be retained if they have one of the classes listed belowed. -->
+    <allowed-div-classes>
+    </allowed-div-classes>
+
+    <!-- The class attribute of p elements will only be retained if they have one of the classes listed belowed. -->
+    <allowed-para-classes>
+      <class>note</class>
+      <class>warn</class>
+      <class>fixme</class>
+    </allowed-para-classes>
+
+    <!-- The class attribute of pre elements will only be retained if they have one of the classes listed belowed. -->
+    <allowed-pre-classes>
+      <class>query</class>
+      <class>include</class>
+      <class>query-and-include</class>      
+    </allowed-pre-classes>
+
+    <img-alternate-src-attr name="title"/>
+
+    <!-- Lists the allowed elements and their allowed attributes.
+
+         For the correct worker of the cleaner, some elements cannot be removed,
+         usch as html, body, p, some others...
+     -->
+    <allowed-elements>
+      <element name="html"/>
+      <element name="body"/>
+
+      <element name="div">
+        <attribute name="class"/>
+      </element>
+      <element name="span">
+        <attribute name="class"/>
+      </element>
+
+      <element name="p">
+        <attribute name="align"/>
+        <attribute name="class"/>
+      </element>
+      <element name="br"/>
+      <element name="pre">
+        <attribute name="class"/>
+      </element>
+
+      <!-- titles -->
+      <element name="h1"/>
+      <element name="h2"/>
+      <element name="h3"/>
+      <element name="h4"/>
+      <element name="h5"/>
+
+      <!-- linking -->
+      <element name="a">
+        <attribute name="href"/>
+      </element>
+
+      <!-- inline styles -->
+      <element name="strong"/>
+      <element name="em"/>
+      <element name="sup"/>
+      <element name="sub"/>
+
+      <!-- lists -->
+      <element name="ul"/>
+      <element name="ol"/>
+      <element name="li"/>
+
+      <element name="img">
+        <attribute name="src"/>
+        <attribute name="align"/>
+      </element>
+
+      <!-- tables -->
+      <element name="table">
+        <attribute name="class"/>
+      </element>
+      <element name="tbody"/>
+      <element name="tr"/>
+      <element name="td">
+        <attribute name="colspan"/>
+        <attribute name="rowspan"/>
+        <attribute name="valign"/>
+      </element>
+      <element name="th">
+        <attribute name="colspan"/>
+        <attribute name="rowspan"/>
+        <attribute name="valign"/>
+      </element>
+      <element name="hr"/>
+    </allowed-elements>
+  </cleanup>
+
+  <serialization>
+    <linewidth value="80"/>
+    <elements>
+      <!-- Note: to avoid unexpected results, mention all block-type tags here,
+           and NO inline tags. -->
+      <element name="html" afterOpen="1" beforeClose="1"/>
+      <element name="body" afterOpen="1" beforeClose="1"/>
+      <element name="p" beforeOpen="1" afterClose="1"/>
+      <element name="h1" beforeOpen="1" afterClose="1"/>
+      <element name="h2" beforeOpen="1" afterClose="1"/>
+      <element name="h3" beforeOpen="1" afterClose="1"/>
+      <element name="h4" beforeOpen="1" afterClose="1"/>
+      <element name="h5" beforeOpen="1" afterClose="1"/>
+      <element name="pre" beforeOpen="1" afterClose="1"/>
+      <element name="div" beforeOpen="1" afterClose="1"/>
+      <element name="ul" beforeOpen="1" beforeClose="1" afterClose="1"/>
+      <element name="ol" beforeOpen="1" beforeClose="1" afterClose="1"/>
+      <element name="li" beforeOpen="1"/>
+      <element name="table" beforeOpen="1" beforeClose="1" afterClose="1"/>
+      <element name="tbody" beforeOpen="1" beforeClose="1"/>
+      <element name="tr" beforeOpen="1" beforeClose="1"/>
+      <element name="td" beforeOpen="1"/>
+      <element name="th" beforeOpen="1"/>
+      <element name="br" afterClose="1"/>
+
+    </elements>
+  </serialization>
+
+</htmlcleaner>
\ No newline at end of file

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java?view=auto&rev=106717
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java	Sat Nov 27 06:55:02 2004
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2004 Outerthought bvba and Schaubroeck nv
+ *
+ * Licensed 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.forms.datatype.convertor;
+
+import org.apache.cocoon.forms.datatype.convertor.Convertor;
+import org.apache.cocoon.forms.datatype.convertor.ConversionResult;
+import org.apache.cocoon.forms.validation.ValidationError;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.outerj.daisy.htmlcleaner.HtmlCleanerTemplate;
+import org.outerj.daisy.htmlcleaner.HtmlCleaner;
+
+import java.util.Locale;
+
+/**
+ * A CForms convertor doing string-to-string conversion by utilizing
+ * the Daisy HtmlCleaner component.
+ */
+public class HtmlCleaningConvertor implements Convertor {
+    HtmlCleanerTemplate template;
+
+    public HtmlCleaningConvertor(HtmlCleanerTemplate template) {
+        this.template = template;
+    }
+
+    public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+        HtmlCleaner cleaner = template.newHtmlCleaner();
+        try {
+            String result = cleaner.cleanToString(value);
+            return new ConversionResult(result);
+        } catch (Exception e) {
+            Throwable t = ExceptionUtils.getRootCause(e);
+            if (t == null)
+                t = e;
+            String message = t.getMessage();
+            if (message == null)
+                message = t.toString();
+            ValidationError validationError = new ValidationError(message, false);
+            return new ConversionResult(validationError);
+        }
+    }
+
+    public String convertToString(Object object, Locale locale, Convertor.FormatCache formatCache) {
+        return (String)object;
+    }
+
+    public Class getTypeClass() {
+        return java.lang.String.class;
+    }
+
+    public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+        // nothing to say about me
+    }
+}

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java?view=auto&rev=106717
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java	Sat Nov 27 06:55:02 2004
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004 Outerthought bvba and Schaubroeck nv
+ *
+ * Licensed 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.forms.datatype.convertor;
+
+import org.apache.cocoon.forms.datatype.convertor.ConvertorBuilder;
+import org.apache.cocoon.forms.datatype.convertor.Convertor;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.cocoon.forms.CacheManager;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.Source;
+import org.w3c.dom.Element;
+import org.outerj.daisy.htmlcleaner.HtmlCleanerTemplate;
+import org.outerj.daisy.htmlcleaner.HtmlCleanerFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Builds {@link HtmlCleaningConvertor}s.
+ */
+public class HtmlCleaningConvertorBuilder implements ConvertorBuilder, Serviceable {
+    private ServiceManager serviceManager;
+
+    public void service(ServiceManager serviceManager) throws ServiceException {
+        this.serviceManager = serviceManager;
+    }
+
+    public Convertor build(Element element) throws Exception {
+        String config = DomHelper.getAttribute(element, "config");
+
+        Source source = null;
+        SourceResolver sourceResolver = null;
+        CacheManager cacheManager = null;
+        try {
+            cacheManager = (CacheManager)serviceManager.lookup(CacheManager.ROLE);
+            sourceResolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
+            source = sourceResolver.resolveURI(config);
+
+            String prefix = HtmlCleanerTemplate.class.getName();
+            HtmlCleanerTemplate template = (HtmlCleanerTemplate)cacheManager.get(source, prefix);
+            if (template == null) {
+                HtmlCleanerFactory factory = new HtmlCleanerFactory();
+                InputSource is = SourceUtil.getInputSource(source);
+                template = factory.buildTemplate(is);
+                cacheManager.set(template, source, prefix);
+            }
+
+            return new HtmlCleaningConvertor(template);
+        } finally {
+            if (source != null)
+                sourceResolver.release(source);
+            if (sourceResolver != null)
+                serviceManager.release(sourceResolver);
+            if (cacheManager != null)
+                serviceManager.release(cacheManager);
+        }
+    }
+}

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/htmlarea.js
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/htmlarea.js?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/htmlarea.js&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/htmlarea.js&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/htmlarea.js	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/htmlarea.js	Sat Nov 27 06:55:02 2004
@@ -21,6 +21,9 @@
     form.showForm("htmlarea-display-pipeline");
 
     var model = form.getModel();
-    var htmldata = { "data" : model.data }
+    var htmldata = { 
+                      "data1" : model.data1,
+                      "data2" : new Packages.org.apache.cocoon.xml.StringXMLizable(model.data2)
+                   }
     cocoon.sendPage("htmlarea-success-pipeline", htmldata);
-}
+}
\ No newline at end of file

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea.xml?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea.xml&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea.xml&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea.xml	Sat Nov 27 06:55:02 2004
@@ -19,9 +19,15 @@
   xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
 
   <fd:widgets>
-    <fd:field id="data">
-      <fd:label>HTML:</fd:label>
-      <fd:datatype base="string" />
+    <fd:field id="data1">
+      <fd:label>in div; configuration within cForms template</fd:label>
+      <fd:datatype base="string"/>
+    </fd:field>    
+    <fd:field id="data2">
+      <fd:label>in a table</fd:label>
+      <fd:datatype base="string">
+        <fd:convertor type="htmlcleaner" config="resource://org/apache/cocoon/forms/datatype/convertor/HtmlCleanerConfiguration.xml"/>
+      </fd:datatype>
     </fd:field>
   </fd:widgets>
 </fd:form>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_success.jx
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_success.jx?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_success.jx&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_success.jx&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_success.jx	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_success.jx	Sat Nov 27 06:55:02 2004
@@ -14,11 +14,7 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<page>
-  <title>Editing successful</title>
-  <content>
-    Editing was successful:<br/>
-    <br/>
-    ${data}
-  </content>
-</page>
+<result>
+  <data1>#{data1}</data1>
+  <data2>#{data2}</data2>
+</result>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_template.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_template.xml?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_template.xml&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_template.xml&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_template.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/htmlarea_template.xml	Sat Nov 27 06:55:02 2004
@@ -19,14 +19,48 @@
   <title>HTMLArea</title>
   <content>
     <ft:form-template action="#{$continuation/id}.continue" method="POST">
-      <div>
-        <ft:widget-label id="data"/><br/>
-        <ft:widget id="data">
-          <fi:styling type="htmlarea" style="width: 100%;" rows="20" cols="80"/>
+      <div style="width:500px">
+        <ft:widget-label id="data1"/><br/>
+        <ft:widget id="data1">
+          <fi:styling type="htmlarea" rows="8" style="width:100%">
+            <!-- at this place, the configuration property of the HTMLArea is under 'conf'
+                 available. Find more info about the available properties at
+                 http://www.htmlarea.com/htmlarea_2/documentation.html -->
+            <conf>
+              conf.statusBar = false;
+              conf.sizeIncludesToolbar = false;
+              conf.fullPage = false;
+              conf.toolbar = [
+                [ "bold", "italic", "separator",
+                  "subscript", "superscript", "separator",
+                  "insertorderedlist", "insertunorderedlist",
+                  "outdent", "indent", "separator",
+                  "inserthorizontalrule", "separator",
+                  "copy", "cut", "paste", "space", "undo", "redo",
+                  "separator", "showhelp"]
+                ];               
+            </conf>
+          </fi:styling>
         </ft:widget>
-        <br/>
-        <input type="submit"/>
       </div>
+      <p/>
+      <table border="1">
+        <tr>
+          <td><ft:widget-label id="data2"/></td>
+        </tr>
+        <tr>
+          <td>
+            <ft:widget id="data2">
+              <fi:styling type="htmlarea" rows="8" cols="70">
+                <!-- if you add initFunction, make sure that it is available at the browser -->
+                <!--initFunction>myInit</initFunction-->
+              </fi:styling>
+            </ft:widget>
+          </td>
+        </tr>
+      </table>
+      <p/>
+      <input type="submit"/>      
     </ft:form-template>
   </content>
 </page>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl	Sat Nov 27 06:55:02 2004
@@ -24,7 +24,7 @@
       | The very specific advanced stylings as the calendar or htmlarea (both
       | also need additional JS files) are separated out of this file.
       +-->
-
+       
   <xsl:import href="forms-field-styling.xsl"/>
   <xsl:include href="forms-calendar-styling.xsl"/>
   <xsl:include href="forms-htmlarea-styling.xsl"/>
@@ -99,7 +99,7 @@
             </th>
             <th> </th>
             <th>
-              <xsl:copy-of select="fi:styling/fi:selected-label/node()"/>
+              <xsl:copy-of select="fi:styling/fi:selected-label/node()"/>    
             </th>
           </tr>
         </xsl:if>
@@ -116,7 +116,7 @@
                     <xsl:copy-of select="fi:label/node()"/>
                   </option>
                 </xsl:if>
-              </xsl:for-each>
+              </xsl:for-each>  
             </select>
           </td>
           <td>
@@ -125,7 +125,7 @@
             <xsl:text>&#160;</xsl:text>
             <input type="button" value="&gt;" onclick="opt{generate-id()}.forms_transferRight()">
               <xsl:if test="@state='disabled'">
-                <xsl:attribute name="disabled">disabled</xsl:attribute>
+                <xsl:attribute name="disabled">disabled</xsl:attribute> 
               </xsl:if>
             </input>
             <xsl:text>&#160;</xsl:text>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl	Sat Nov 27 06:55:02 2004
@@ -33,7 +33,13 @@
 
   <xsl:template match="body" mode="forms-field">
     <xsl:copy-of select="@*"/>
-    <xsl:attribute name="onload">forms_onload(); <xsl:value-of select="@onload"/></xsl:attribute>
+    <xsl:attribute name="onload">forms_onload();<xsl:value-of select="@onload"/></xsl:attribute>
+  </xsl:template>
+  
+  <xsl:template match="body" mode="forms-afterload">
+    <script language="Javascript">
+       forms_afterLoad();
+    </script>   
   </xsl:template>
 
   <!--+

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-htmlarea-styling.xsl
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-htmlarea-styling.xsl?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-htmlarea-styling.xsl&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-htmlarea-styling.xsl&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-htmlarea-styling.xsl	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-htmlarea-styling.xsl	Sat Nov 27 06:55:02 2004
@@ -47,11 +47,46 @@
     </textarea>
     <xsl:apply-templates select="." mode="common"/>
     <xsl:choose>
-      <xsl:when test="fi:styling/initFunction">
-        <script language="JavaScript"><xsl:value-of select="fi:styling/initFunction"/>('<xsl:value-of select="@id"/>');</script>
+      <xsl:when test="fi:styling/conf">
+        <!-- use an 'ad hoc'  configuration -->
+        <script  type="text/javascript">
+          var handler = new Object();    
+          handler.fieldId = "<xsl:value-of select="@id"/>";     
+          handler.forms_onload = function() {
+            var id = "<xsl:value-of select="@id"/>";
+            var textarea = document.getElementById(id);
+            var editor = new HTMLArea(id);
+            textarea.htmlarea = editor;
+            var conf = editor.config;
+            <xsl:value-of select="fi:styling/conf/text()"/>
+            editor.generate();
+          }
+          forms_onloadHandlers.push(handler);      
+        </script>        
       </xsl:when>
+      <!-- use a passed configuration function -->
+      <xsl:when test="fi:styling/initFunction and not(fi:styling/conf)">
+        <script  type="text/javascript">
+          var handler = new Object();    
+          handler.fieldId = "<xsl:value-of select="@id"/>";
+          if(typeof(<xsl:value-of select="fi:styling/initFunction"/>)!="function") {
+            alert("<xsl:value-of select="fi:styling/initFunction"/> is not a function " +
+            or not available! Can't render widget '<xsl:value-of select="@id"/>'");
+          }
+          handler.forms_onload = <xsl:value-of select="fi:styling/initFunction"/>;
+          forms_onloadHandlers.push(handler);   
+        </script>
+      </xsl:when>    
+      <!-- default mode with all buttons available -->  
       <xsl:otherwise>
-        <script type="text/javascript">HTMLArea.replace('<xsl:value-of select="@id"/>');</script>        
+        <script  type="text/javascript">
+          var handler = new Object();    
+          handler.fieldId = "<xsl:value-of select="@id"/>";     
+          handler.forms_onload = function() {
+            HTMLArea.replace('<xsl:value-of select="@id"/>');
+          }
+          forms_onloadHandlers.push(handler);      
+        </script>  
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-lib.js
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-lib.js?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-lib.js&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-lib.js&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-lib.js	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-lib.js	Sat Nov 27 06:55:02 2004
@@ -32,7 +32,7 @@
 }
 
 // Handlers that are to be called in form's "onsubmit" event
-//FIXME: this single var implies only one form per page, and needs to be
+// FIXME: this single var implies only one form per page, and needs to be
 //       visited if we decide to support several forms per page.
 var forms_onsubmitHandlers = new Array();
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-samples-styling.xsl
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-samples-styling.xsl?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-samples-styling.xsl&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-samples-styling.xsl&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-samples-styling.xsl	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-samples-styling.xsl	Sat Nov 27 06:55:02 2004
@@ -29,7 +29,7 @@
     <head>
       <xsl:apply-templates/>
       <xsl:apply-templates select="." mode="forms-page"/>
-      <xsl:apply-templates select="." mode="forms-field"/>
+      <xsl:apply-templates select="." mode="forms-field"/>  
     </head>
   </xsl:template>
 
@@ -40,7 +40,7 @@
           +-->
       <xsl:apply-templates select="." mode="forms-page"/>
       <xsl:apply-templates select="." mode="forms-field"/>
-      <xsl:apply-templates/>
+      <xsl:apply-templates/>   
     </body>
   </xsl:template>
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap	Sat Nov 27 06:55:02 2004
@@ -18,12 +18,8 @@
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
  <map:components>
-  <map:generators default="file">
-    <map:generator name="form" src="org.apache.cocoon.forms.generation.FormsGenerator"/>
-  </map:generators>
 
   <map:transformers default="xslt">    
-    <map:transformer name="form" src="org.apache.cocoon.forms.transformation.FormsTemplateTransformer"/>
     <map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
       <catalogues default="other">
         <catalogue id="other" name="OtherMessages" location="messages"/>
@@ -44,6 +40,10 @@
   <map:view name="content" from-label="content">
    <map:serialize type="xml"/>
   </map:view>
+  
+  <map:view name="content1" from-label="content1">
+   <map:serialize type="xml"/>
+  </map:view>  
 
   <map:view from-label="content" name="pretty-content">
    <map:transform src="context://stylesheets/system/xml2html.xslt"/>
@@ -128,7 +128,7 @@
 
        <!-- pipeline to show the form -->
        <map:generate src="forms/form1_template_action.xml"/>
-       <map:transform type="forms">
+       <map:transform type="forms" label="content1">
          <map:parameter name="attribute-name" value="form1"/>
        </map:transform>
        <map:transform type="i18n">
@@ -166,7 +166,7 @@
         -->
      <map:match pattern="*-display-pipeline">
        <map:generate src="forms/{1}_template.xml"/>
-       <map:transform type="forms"/>
+       <map:transform type="forms" label="content1"/>
        <map:transform type="i18n">
          <map:parameter name="locale" value="en-US"/>
        </map:transform>
@@ -181,7 +181,7 @@
         | Show a form, using the jx template macros
         -->
      <map:match pattern="*-display-pipeline.jx">
-       <map:generate type="jx" src="forms/{1}_template.xml"/>
+       <map:generate type="jx" src="forms/{1}_template.xml" label="content1"/>
        <map:transform type="i18n">
          <map:parameter name="locale" value="en-US"/>
        </map:transform>
@@ -324,6 +324,50 @@
          </map:otherwise>
        </map:select>
      </map:match>
+
+     <!--
+         | Car selector sample with XMLHTTPRequest
+         -->
+
+     <map:match pattern="xhr_carselector">
+       <map:select type="request-method">
+         <map:when test="POST">
+           <map:call continuation="{request-param:continuation-id}"/>
+         </map:when>
+         <map:otherwise>
+           <map:call function="xhrSelectCar">
+             <map:parameter name="defaultMake" value="Maserati"/>
+           </map:call>
+         </map:otherwise>
+       </map:select>
+     </map:match>
+
+     <map:match pattern="xhr_cars">
+       <map:generate src="forms/car-db.xml"/>
+       <map:transform src="xsl/xhr_carfilter.xsl">
+         <map:parameter name="list" value="makes"/>
+       </map:transform>
+       <map:serialize type="xml"/>
+     </map:match>
+
+     <map:match pattern="xhr_cars/*">
+       <map:generate src="forms/car-db.xml"/>
+       <map:transform src="xsl/xhr_carfilter.xsl">
+         <map:parameter name="list" value="types"/>
+         <map:parameter name="make" value="{1}"/>
+       </map:transform>
+       <map:serialize type="xml"/>
+     </map:match>
+
+     <map:match pattern="xhr_cars/*/*">
+       <map:generate src="forms/car-db.xml"/>
+       <map:transform src="xsl/xhr_carfilter.xsl">
+         <map:parameter name="list" value="models"/>
+         <map:parameter name="make" value="{1}"/>
+         <map:parameter name="type" value="{2}"/>
+       </map:transform>
+       <map:serialize type="xml"/>
+     </map:match>
      
      <!--
          | Country selector sample.
@@ -374,14 +418,7 @@
 
      <map:match pattern="htmlarea-success-pipeline">
        <map:generate type="jx" src="forms/htmlarea_success.jx"/>
-       <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
-         <map:parameter name="contextPath" value="{request:contextPath}"/>
-         <map:parameter name="servletPath" value="{request:servletPath}"/>
-         <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
-         <map:parameter name="file" value="forms/htmlarea_success.jx"/>
-         <map:parameter name="remove" value="{0}"/>
-       </map:transform>
-       <map:serialize/>
+       <map:serialize type="xml"/>
      </map:match>
 
      <map:match pattern="resources/**">

Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/StringXMLizable.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/StringXMLizable.java?view=auto&rev=106717
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/StringXMLizable.java	Sat Nov 27 06:55:02 2004
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.xml;
+
+import org.apache.excalibur.xml.sax.XMLizable;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
+
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.StringReader;
+
+/**
+ * XMLizable a String
+ * 
+ * @since 2.1.7
+ * @author Bruno Dumon
+ */
+public class StringXMLizable implements XMLizable {
+    private String data;
+
+    public StringXMLizable(String data) {
+        this.data = data;
+    }
+
+    public void toSAX(ContentHandler contentHandler) throws SAXException {
+        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+        parserFactory.setNamespaceAware(true);
+        SAXParser parser = null;
+        try {
+            parser = parserFactory.newSAXParser();
+        } catch (ParserConfigurationException e) {
+            throw new SAXException("Error creating SAX parser.", e);
+        }
+        parser.getXMLReader().setContentHandler(contentHandler);
+        InputSource is = new InputSource(new StringReader(data));
+        try {
+            parser.getXMLReader().parse(is);
+        } catch (IOException e) {
+            throw new SAXException(e);
+        }
+    }
+}

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&rev=106717&p1=cocoon/branches/BRANCH_2_1_X/status.xml&r1=106716&p2=cocoon/branches/BRANCH_2_1_X/status.xml&r2=106717
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml	Sat Nov 27 06:55:02 2004
@@ -202,6 +202,48 @@
 
   <changes>
  <release version="@version@" date="@date@">
+   <action dev="RP" type="add">
+    cForms: added HTMLCleaning convertor (taken from Outerthought's Daisy) that cleans
+            up the result by HTMLArea fields. The cleanup process, that is based upon
+            Nekohtml can be configured. One confiugration is available at
+            resource://org/apache/cocoon/forms/datatype/convertor/HtmlCleanerConfiguration.xml
+            and guarantees valid XHTML
+     <br/>
+     Example:
+     <code>
+&lt;fd:datatype base="string"&gt;
+  &lt;fd:convertor type="htmlcleaner"
+      config="resource://org/apache/cocoon/forms/datatype/convertor/HtmlCleanerConfiguration.xml"/&gt;
+&lt;/fd:datatype&gt;
+     </code>
+   </action>
+   <action dev="RP" type="add">
+    cForms: 'htmlarea' fields can be directly configured in cForms templates
+    <br/>
+    Example configuration (within the &lt;conf&gt; part the variable conf contains
+    the configuration object of HTMLArea
+    <code>
+&lt;fi:styling type="htmlarea" rows="8" style="width:100%"&gt;
+  &lt;conf&gt;
+    conf.statusBar = false;
+    conf.sizeIncludesToolbar = false;
+    conf.fullPage = false;
+    conf.toolbar = [
+      [ "bold", "italic", "separator",
+        "subscript", "superscript", "separator",
+        "insertorderedlist", "insertunorderedlist",
+        "outdent", "indent", "separator",
+        "inserthorizontalrule", "separator",
+        "copy", "cut", "paste", "space", "undo", "redo",
+        "separator", "showhelp"]
+      ];
+  &lt;/conf&gt;
+&lt;/fi:styling&gt;
+    </code>
+   </action>
+   <action dev="RP" type="fix">
+    cForms: fields styled as 'htmlarea' can be used in tables (workaround for strange IE behaviour)
+   </action> 
    <action dev="SW" type="add">
      CForms: add a new "link" styling for action widgets, that renders the action
      as an hypertext link.