Bug 36127 - validation with xerces 2.7.1
Summary: validation with xerces 2.7.1
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.5.9
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL: http://pastebin.com/333771
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-10 17:28 UTC by Florent BENOIT
Modified: 2005-08-11 06:01 UTC (History)
0 users



Attachments
Example reproducing the problem (3.33 KB, text/plain)
2005-08-10 17:30 UTC, Florent BENOIT
Details
Patch for fixing this issue (770 bytes, patch)
2005-08-10 17:33 UTC, Florent BENOIT
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florent BENOIT 2005-08-10 17:28:54 UTC
Hi,

When using Tomcat with the last xerces version (2.7.1), there is a problem on
jsp validation. (Note that next Tomcat version will have also 2.7.1 version (as
it was put in the changelog) in current CVS tree).

One way to fix it is in the org/apache/jasper/compiler/JspDocumentParser.java file.
By replacing :

        factory.setFeature(
            "http://xml.org/sax/features/validation",
            validating);

by :

       factory.setValidating(validating);

(Patch at the end)

Note that the setValidating() method is also used by digester which is used by
Tomcat as other places.
See getFactory() method.
http://cvs.apache.org/viewcvs.cgi/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java?view=markup

I provide a sample (you could extract the xml snippet if you want to test it in
Tomcat directly without the sample Class).
I tried this example with Sun JDK 1.4.2_08, JDK 5_update4 and with xerces 2.6.2
and 2.7.1 (with endorsed java -Djava.endorsed.dirs=...) and with 
factory.setValidating(validating); it works in all cases. (like in Digester).


It will be fine if it could be fixed in CVS for next Tomcat version.

Regards,

Florent


Index: JspDocumentParser.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v
retrieving revision 1.84
diff -u -r1.84 JspDocumentParser.java
--- JspDocumentParser.java	30 Mar 2005 20:27:22 -0000	1.84
+++ JspDocumentParser.java	10 Aug 2005 15:22:04 -0000
@@ -1370,9 +1370,10 @@
         factory.setFeature(
             "http://xml.org/sax/features/namespace-prefixes",
             true);
-        factory.setFeature(
-            "http://xml.org/sax/features/validation",
-            validating);
+        factory.setValidating(validating);
 
         // Configure the parser
         SAXParser saxParser = factory.newSAXParser();

 
         // Configure the parser
         SAXParser saxParser = factory.newSAXParser();
Comment 1 Florent BENOIT 2005-08-10 17:30:45 UTC
Created attachment 15995 [details]
Example reproducing the problem

Class reproducing the jasper problem with xerces 2.7.1

java -Djava.endorsed.dirs=<path with xerces2.7.1 jars inside> sax.Sax
Comment 2 Florent BENOIT 2005-08-10 17:33:39 UTC
Created attachment 15996 [details]
Patch for fixing this issue

Patch for fixing this issue (with xerces 2.7.1), also it works with other
xerces version and JDK
Comment 3 Remy Maucherat 2005-08-10 18:00:56 UTC
Wouldn't it be better to set both ?
Comment 4 Florent BENOIT 2005-08-10 18:13:32 UTC
It works for me only with one thing.
Also, only xml with DTD have to be validated in this case of JSP (no schema).
(Section JSP 6.2.4)

So I think the use of only factory.setValidating(validating); will be OK.

Regards,

Florent
Comment 5 Remy Maucherat 2005-08-11 14:01:10 UTC
It's actually section 6.2.4. I think the change is reasonable, but I'll leave
the old code in commented out.