You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Doug Chestnut <dh...@virginia.edu> on 2006/07/12 23:53:34 UTC

Re: svn commit: r421425 - /lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java

Hey, should we use tidy for some of the other editor usecases as well? 
(one-form, forms)

--Doug

chestnut@apache.org wrote:
> Author: chestnut
> Date: Wed Jul 12 14:40:11 2006
> New Revision: 421425
> 
> URL: http://svn.apache.org/viewvc?rev=421425&view=rev
> Log:
> use tidy to clean up entities and xml from fck editor
> 
> Modified:
>     lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java
> 
> 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?rev=421425&r1=421424&r2=421425&view=diff
> ==============================================================================
> --- 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 Jul 12 14:40:11 2006
> @@ -20,10 +20,14 @@
>  import java.io.FileOutputStream;
>  import java.io.IOException;
>  import java.io.OutputStreamWriter;
> +import java.io.PrintWriter;
> +import java.io.StringWriter;
>  import java.io.UnsupportedEncodingException;
>  import java.io.Writer;
> +
>  import org.apache.cocoon.components.ContextHelper;
>  import org.apache.cocoon.environment.Request;
> +import org.apache.cocoon.xml.XMLUtils;
>  import org.apache.excalibur.source.ModifiableSource;
>  import org.apache.excalibur.source.Source;
>  import org.apache.excalibur.source.SourceResolver;
> @@ -32,10 +36,10 @@
>  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.w3c.tidy.Tidy;
>  import org.xml.sax.SAXException;
>  
>  /**
> @@ -122,14 +126,28 @@
>              resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
>              xmlSource = (ModifiableSource) resolver.resolveURI(getSourceDocument().getSourceURI());
>              saveXMLFile(encoding, content, xmlSource);
> +            
> +            // Setup an instance of Tidy.
> +            Tidy tidy = new Tidy();
> +            tidy.setXmlOut(true);
> +            tidy.setNumEntities(true);
> +            
> +            //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;
>  
> -            try {
> -                xmlDoc = DocumentHelper.readDocument(xmlSource.getInputStream());
> -            } catch (SAXException e) {
> -                addErrorMessage("error-document-form", new String[] { e.getMessage() });
> -            }
> +            xmlDoc = tidy.parseDOM(xmlSource.getInputStream(), null);
> +            
> +            // FIXME: Jtidy doesn't warn or strip duplicate attributes in same
> +            // tag; stripping.
> +            XMLUtils.stripDuplicateAttributes(xmlDoc, null);
>  
>              if (xmlDoc != null) {
>                  ResourceType resourceType = getSourceDocument().getResourceType();
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
> For additional commands, e-mail: commits-help@lenya.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: svn commit: r421425 - /lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java

Posted by Doug Chestnut <dh...@virginia.edu>.
Feel free to take this up with the FCK community.  I believe this change 
was to take care of various entities (&nbsp, etc) being used instead of 
their unicode equivlent.  The use of tidy for the fckeditor is a fix the 
the fckeditor lenya module (seems to be working w/o problems now).

--Doug

Andreas Hartmann wrote:
> Jörn Nettingsmeier wrote:
> 
>> Doug Chestnut wrote:
>>
>>> Hey, should we use tidy for some of the other editor usecases as 
>>> well? (one-form, forms)
>>
>>
>> i'm against this, as it will hide bugs.
>> if an editor produces unclean output, it should be fixed.
> 
> 
> Yes, I agree to this. But it seems to be quite complicated to
> get the editors to produce clean output ...
> 
> -- Andreas
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: svn commit: r421425 - /lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java

Posted by Andreas Hartmann <an...@apache.org>.
Jörn Nettingsmeier wrote:
> Doug Chestnut wrote:
>> Hey, should we use tidy for some of the other editor usecases as well? 
>> (one-form, forms)
> 
> i'm against this, as it will hide bugs.
> if an editor produces unclean output, it should be fixed.

Yes, I agree to this. But it seems to be quite complicated to
get the editors to produce clean output ...

-- Andreas


-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: svn commit: r421425 - /lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java

Posted by Doug Chestnut <dh...@virginia.edu>.

Andreas Hartmann wrote:
> Michael Wechner wrote:
> 
>> Jörn Nettingsmeier wrote:
>>
>>> Doug Chestnut wrote:
>>>
>>>> Hey, should we use tidy for some of the other editor usecases as 
>>>> well? (one-form, forms)
>>>
>>>
>>>
>>> i'm against this, as it will hide bugs.
>>> if an editor produces unclean output, it should be fixed.
>>>
>>
>> well, fixed if possible with a warning and otherwise rejected with an 
>> exception.
> 
> 
> I guess what Jörn meant was that one should fix the editor instead
> of cleaning up its output.
In our case, the fckeditor is the module (we can't include fckeditor 
source due to license issues) and tidy was the fix.

I agree that a warning would be nice in the logs.  Not sure if it is 
logged, I will take a look.  An end user could care less if tidy 
replaces &nbsp; with &#160; when they pressed the spacebar in the editor.
> 
>> If Lenya isn't strict on this, then it will always cause problems in 
>> the long run.
> 
> 
> I'd even add validation at repository level (i.e., when something
> is written to a document source).
+1
> 
> -- Andreas
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: svn commit: r421425 - /lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java

Posted by Andreas Hartmann <an...@apache.org>.
Michael Wechner wrote:
> Jörn Nettingsmeier wrote:
> 
>> Doug Chestnut wrote:
>>
>>> Hey, should we use tidy for some of the other editor usecases as 
>>> well? (one-form, forms)
>>
>>
>> i'm against this, as it will hide bugs.
>> if an editor produces unclean output, it should be fixed.
>>
> 
> well, fixed if possible with a warning and otherwise rejected with an 
> exception.

I guess what Jörn meant was that one should fix the editor instead
of cleaning up its output.

> If Lenya isn't strict on this, then it will always cause problems in the 
> long run.

I'd even add validation at repository level (i.e., when something
is written to a document source).

-- Andreas


-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: svn commit: r421425 - /lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java

Posted by Michael Wechner <mi...@wyona.com>.
Jörn Nettingsmeier wrote:

> Doug Chestnut wrote:
>
>> Hey, should we use tidy for some of the other editor usecases as 
>> well? (one-form, forms)
>
>
> i'm against this, as it will hide bugs.
> if an editor produces unclean output, it should be fixed.
>

well, fixed if possible with a warning and otherwise rejected with an 
exception.

If Lenya isn't strict on this, then it will always cause problems in the 
long run.

Michi


-- 
Michael Wechner
Wyona      -   Open Source Content Management   -    Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
michael.wechner@wyona.com                        michi@apache.org
+41 44 272 91 61


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: svn commit: r421425 - /lenya/trunk/src/modules/fckeditor/java/src/org/apache/lenya/cms/editors/fckeditor/Fckeditor.java

Posted by Jörn Nettingsmeier <po...@uni-duisburg.de>.
Doug Chestnut wrote:
> Hey, should we use tidy for some of the other editor usecases as well? 
> (one-form, forms)

i'm against this, as it will hide bugs.
if an editor produces unclean output, it should be fixed.

-- 
"Open source takes the bullshit out of software."
	- Charles Ferguson on TechnologyReview.com

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: pol-admin@uni-due.de, Telefon: 0203/379-2736

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org