logo       
Google Custom Search
    AddThis Social Bookmark Button

svn commit: r443137 - in /lenya/trunk/src/modules/fckeditor: config/jtidy.p: msg#00064

Subject: svn commit: r443137 - in /lenya/trunk/src/modules/fckeditor: config/jtidy.properties java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java
Author: chestnut
Date: Wed Sep 13 14:43:04 2006
New Revision: 443137

URL: http://svn.apache.org/viewvc?view=rev&rev=443137
Log:
edit.fckeditor usecase will only use tidy if properties file is given in 
usecase conf (usecases-edit-fckeditor.xconf)

and I added some handy tidy options to the tidy properties

Modified:
    lenya/trunk/src/modules/fckeditor/config/jtidy.properties
    
lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java

Modified: lenya/trunk/src/modules/fckeditor/config/jtidy.properties
URL: 
http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/config/jtidy.properties?view=diff&rev=443137&r1=443136&r2=443137
==============================================================================
--- lenya/trunk/src/modules/fckeditor/config/jtidy.properties (original)
+++ lenya/trunk/src/modules/fckeditor/config/jtidy.properties Wed Sep 13 
14:43:04 2006
@@ -1,9 +1,21 @@
-markup=no
-output-xhtml=yes
-tidy-mark=no
-clean=yes
+add-xml-decl=yes
+add-xml-space=yes
+alt-text=""
+assume-xml-procins=yes
 bare=yes
+clean=yes
 drop-empty-paras=yes
 drop-font-tags=yes
-quote-nbsp=no
+drop-proprietary-attributes=yes
+enclose-text=yes
+indent-cdata=yes
+logical-emphasis=yes
 numeric-entities=yes
+output-xhtml=yes
+quote-nbsp=no
+word-2000=yes
+break-before-br=yes
+indent=auto
+vertical-space=yes
+markup=no
+tidy-mark=no

Modified: 
lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java
URL: 
http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java?view=diff&rev=443137&r1=443136&r2=443137
==============================================================================
--- 
lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java
 (original)
+++ 
lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java
 Wed Sep 13 14:43:04 2006
@@ -31,7 +31,6 @@
 import javax.xml.transform.Transformer;
 import javax.xml.transform.OutputKeys;
 
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.cocoon.components.ContextHelper;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.xml.XMLUtils;
@@ -43,9 +42,11 @@
 import org.apache.lenya.cms.usecase.UsecaseException;
 import org.apache.lenya.cms.usecase.xml.UsecaseErrorHandler;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
+import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.Schema;
 import org.apache.lenya.xml.ValidationUtil;
 import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 import org.w3c.tidy.Tidy;
 
 /**
@@ -136,6 +137,8 @@
             xmlSource = (ModifiableSource) 
resolver.resolveURI(getSourceDocument().getSourceURI());
             saveXMLFile(encoding, content, xmlSource);
             
+            Document xmlDoc = null;
+            
             // Setup an instance of Tidy.
             Tidy tidy = new Tidy();
             
@@ -148,50 +151,54 @@
                 }
                 properties = new Properties();
                 properties.load(tidySource.getInputStream());
-            }
-
-            if (properties == null) {
-                tidy.setXHTML(true);
-            } else {
-                tidy.setConfigurationFromProps(properties);
-            }
             
-            //Set Jtidy warnings on-off
-            tidy.setShowWarnings(getLogger().isWarnEnabled());
-            //Set Jtidy final result summary on-off
-            tidy.setQuiet(!getLogger().isInfoEnabled());
-            //Set Jtidy infos to a String (will be logged) instead of 
System.out
-            StringWriter stringWriter = new StringWriter();
-            PrintWriter errorWriter = new PrintWriter(stringWriter);
-            tidy.setErrout(errorWriter);
-
-            Document xmlDoc = null;
 
-            xmlDoc = tidy.parseDOM(xmlSource.getInputStream(), null);
+                if (properties == null) {
+                    tidy.setXHTML(true);
+                } else {
+                    tidy.setConfigurationFromProps(properties);
+                }
             
-            // FIXME: Jtidy doesn't warn or strip duplicate attributes in same
-            // tag; stripping.
-            XMLUtils.stripDuplicateAttributes(xmlDoc, null);
-            
-            StringWriter output = new StringWriter();
-            StreamResult strResult = new StreamResult(output);
-            TransformerFactory tfac = TransformerFactory.newInstance();
-            try {
-                Transformer t = tfac.newTransformer();
-                t.setOutputProperty(OutputKeys.ENCODING, encoding);
-                t.setOutputProperty(OutputKeys.INDENT, "yes");
-                t.setOutputProperty(OutputKeys.METHOD, "xml");
-                
t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount";, "4");
-                t.transform(new DOMSource(xmlDoc.getDocumentElement()), 
strResult);
+                //Set Jtidy warnings on-off
+                tidy.setShowWarnings(getLogger().isWarnEnabled());
+                //Set Jtidy final result summary on-off
+                tidy.setQuiet(!getLogger().isInfoEnabled());
+                //Set Jtidy infos to a String (will be logged) instead of 
System.out
+                StringWriter stringWriter = new StringWriter();
+                PrintWriter errorWriter = new PrintWriter(stringWriter);
+                tidy.setErrout(errorWriter);
+
+                xmlDoc = tidy.parseDOM(xmlSource.getInputStream(), null);
+            
+                // FIXME: Jtidy doesn't warn or strip duplicate attributes in 
same
+                // tag; stripping.
+                XMLUtils.stripDuplicateAttributes(xmlDoc, null);
+            
+                StringWriter output = new StringWriter();
+                StreamResult strResult = new StreamResult(output);
+                TransformerFactory tfac = TransformerFactory.newInstance();
+                try {
+                    Transformer t = tfac.newTransformer();
+                    t.setOutputProperty(OutputKeys.ENCODING, encoding);
+                    t.setOutputProperty(OutputKeys.INDENT, "yes");
+                    t.setOutputProperty(OutputKeys.METHOD, "xml");
+                    
t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount";, "4");
+                    t.transform(new DOMSource(xmlDoc.getDocumentElement()), 
strResult);
+                
+                    content = strResult.getWriter().toString();
+                } catch (Exception e) {
+                    addErrorMessage(e.getMessage());
+                }
                 
-                content = strResult.getWriter().toString();
-            } catch (Exception e) {
-                this.addErrorMessage(e.getMessage());
+                saveXMLFile(encoding, content, xmlSource);
+            } else {
+                try {
+                  xmlDoc = 
DocumentHelper.readDocument(xmlSource.getInputStream());
+                } catch (SAXException e) {
+                    addErrorMessage("error-document-form", new String[] { 
e.getMessage() });
+                }
             }
             
-            
-            saveXMLFile(encoding, content, xmlSource);
-
             if (xmlDoc != null) {
                 ResourceType resourceType = 
getSourceDocument().getResourceType();
                 Schema schema = resourceType.getSchema();



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>