Bug 147033 - [validation] Eclipse accepts a restriction which is rejected by other tools such as Visual Studio and XMLSpy
Summary: [validation] Eclipse accepts a restriction which is rejected by other tools s...
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xsd (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M3   Edit
Assignee: Valentin Baciu CLA
QA Contact: Keith Chong CLA
URL:
Whiteboard:
Keywords: bugday, contributed, helpwanted, noteworthy
: 146832 (view as bug list)
Depends on:
Blocks: 204488
  Show dependency tree
 
Reported: 2006-06-14 08:11 EDT by Nicolas Mailhot CLA
Modified: 2008-04-24 00:44 EDT (History)
6 users (show)

See Also:
thatnitind: review+


Attachments
testcase (1.67 KB, application/xsd+xml)
2006-06-14 08:21 EDT, Nicolas Mailhot CLA
no flags Details
Allow Toggling of Full XSD Conformance for XSD Validation (271.04 KB, patch)
2007-09-22 23:13 EDT, David Carver CLA
no flags Details | Diff
Corrected Patch (271.04 KB, patch)
2007-09-22 23:17 EDT, David Carver CLA
no flags Details | Diff
Adds option for control Full Schema Validation (13.77 KB, patch)
2007-09-22 23:44 EDT, David Carver CLA
bjorn.freeman-benson: iplog+
Details | Diff
JUnit Test for Full Conformance Patch (5.99 KB, patch)
2007-09-28 12:08 EDT, David Carver CLA
bjorn.freeman-benson: iplog+
Details | Diff
Image of "Check Full Schema Conformance' fix (18.52 KB, image/png)
2007-11-12 19:37 EST, David Carver CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Mailhot CLA 2006-06-14 08:11:24 EDT
The attached testcase shows a construct which is blindly accepted by eclipse but rejected by other popular tools on the market.

Given eclipse track record at letting restriction errors pas I tend to trust the other tools more, but I didn't dissect the W3C spec to check which one of them is actually right
Comment 1 Nicolas Mailhot CLA 2006-06-14 08:21:21 EDT
Created attachment 44395 [details]
testcase
Comment 2 Nicolas Mailhot CLA 2006-06-14 08:33:51 EDT
Eclipse SDK Version: 3.2.0 Build id: I20060512-1600
WebTools 1.5 RC3
Windows 2000
Comment 3 Keith Chong CLA 2006-06-22 12:32:56 EDT
Lawrence, bring it up in the sample xsd editor and you'll see the error.
Comment 4 Lawrence Mandel CLA 2007-04-27 12:52:05 EDT
Valentin, please reassign if you're not the owner of the XSD validator.
Comment 5 Valentin Baciu CLA 2007-05-16 17:11:29 EDT
The WTP XSD validator is based on Xerces and sets this Xerces feature http://apache.org/xml/features/validation/schema-full-checking  explicitly to false (even though false is the default). See [1] for more information about the feature. If I set the feature to true, then the validator produces the following messages:

Severity and Description	Path	Resource	Location	Creation Time	Id
derivation-ok-restriction.5.4.2: Error for type 'RestrictedFoo'.  The particle of the type is not a valid restriction of the particle of the base.	147033	test2.xsd	line 35	1179349296187	48
rcase-Recurse.2: There is not a complete functional mapping between the particles.	147033	test2.xsd	line 35	1179349296187	47

Craig, I assume there was a specific reason why this was set to false. I'm thinking for 3.0 we can make this a preference, similar to honour-all-schemaLocations?

[1] http://xerces.apache.org/xerces-j/features.html#schema-full-checking
Comment 6 Craig Salter CLA 2007-05-17 00:15:47 EDT
We turned off 'full checking' since it caused serious perfomance degredation for some use cases (cc'ing Lawrence since he knows the full story).  

BTW, I've heard the Xerces team may have fixed this problem in version 2.9.0.  So Nicolas, perhaps you could do us the service of replacing the xerces jars included in WTP's xerces plugin with this  2.9.0 version and change the following code in the XSDValidator class (in the xsd.core plugin) 

     grammarPreparser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING, true);// false


Then you could verify if this issue is fixed with latest Xerces. Your help would be very appreciated!
Comment 7 Valentin Baciu CLA 2007-07-12 13:25:34 EDT
*** Bug 146832 has been marked as a duplicate of this bug. ***
Comment 8 David Carver CLA 2007-07-18 20:22:48 EDT
My personal preference on this issue, is to have a preference page that would allow the user to decide if full schema checking should be done.  If dealing with standard schemas for B2B checking, full schema checking should always be done.  Performance can be improved, by making sure the schemas are cached the first time they are loaded.
Comment 9 Valentin Baciu CLA 2007-09-14 14:05:02 EDT
This bug 185839 deals with a proposed upgrade to Xerces 2.9. I'm not entirely sure when that will happen though.

We already have a preference page for XML Schema files in org.eclipse.wst.xsd.ui. Currently it holds mostly editor specific settings plus the honour all schema locations validator preference as the lone validation preference. 

Ideally we would have a preference page with settings for the XSD validator to give the user a chance to tweak more settings but that may not happen for a while. 

So, if having this switch is really important (there have been a few other questions on this, see the dups) I guess we could add a new check box alongside the one for the honour all schema location  I would suggest leaving the setting to false by default until the upgrade to Xerces 2.9 happens and we verify that the performance gains are there.

Since the change is not very complicated I'll mark as help wanted. Are you willing to take a first crack at a patch David?
Comment 10 David Carver CLA 2007-09-14 14:09:45 EDT
(In reply to comment #9)
> So, if having this switch is really important (there have been a few other
> questions on this, see the dups) I guess we could add a new check box alongside
> the one for the honour all schema location  I would suggest leaving the setting
> to false by default until the upgrade to Xerces 2.9 happens and we verify that
> the performance gains are there.
> 
> Since the change is not very complicated I'll mark as help wanted. Are you
> willing to take a first crack at a patch David?

Mark it for Bug Day and I'll take a crack at it, as I do need to have full compliance checking enabled so that my users aren't getting false positives in validation checking.

Comment 11 David Carver CLA 2007-09-22 12:07:50 EDT
I'll add a check box and appropriate code to make this an optional setting.   I think the default value of this check box should be true.  The reasoning is that it will guarantee the greatest level of conformance across schema parsers.   If lax validation checking on an XSD is allowed by default, this can generate false positives that the implementor may not be expecting.

We should really check to make sure that Xerces 2.9.1 is going to be included as in addition to some performance and XSD issues that were introduced in 2.8.x and fixed in 2.9.x, 2.9.x is also undergoing testing of the W3C XML Schema test suite and has addressed some fringe issues already.

I should have a patch to post in a few days.


   
Comment 12 David Carver CLA 2007-09-22 12:15:44 EDT
Created bug 204361 for the request to upgrade Orbit's Xerces bundle to 2.9.1, so that additional XSD related issues can be addressed.
Comment 13 David Carver CLA 2007-09-22 23:13:44 EDT
Created attachment 79034 [details]
Allow Toggling of Full XSD Conformance for XSD Validation

The current implementation of the XSD Editor and Validators do not enforce full XSD Conformance checking.  This will bypass the Identity Constraint checking which can lead to false positives on the schema.  This patch addresses this issue by adding a check box to the XSD Preferences page so that this is user selectable.  It currently is set to true by default, but can be turned off if the user desires.
Comment 14 David Carver CLA 2007-09-22 23:15:31 EDT
Comment on attachment 79034 [details]
Allow Toggling of Full XSD Conformance for XSD Validation

Removed bad patch
Comment 15 David Carver CLA 2007-09-22 23:17:35 EDT
Created attachment 79035 [details]
Corrected Patch

Corrects previous patch.
Comment 16 David Carver CLA 2007-09-22 23:44:53 EDT
Created attachment 79037 [details]
Adds option for control Full Schema Validation

Corrected patch that adds the conformance preference and makes the XSD Validator look and use the conformance preference setting.
Comment 17 David Carver CLA 2007-09-24 10:07:46 EDT
Looking further into this...it appears that the WSDL editor when validating the inline XSD doesn't call the same validator as the XSD editor.  The issue here is that it means seperate settings are being used, and duplicate code appears to be maintained.   Some refactoring on this might be needed going forward to maintain consistency.

Comment 18 Valentin Baciu CLA 2007-09-24 13:29:47 EDT
Thanks David, I'll check out the patch.

As I said, until we can be certain that using a default of true does not significantly degrade performance I'd prefer we stick with a default of false. One way to check this is by running the XSD performance tests - which I believe you are familiar with.

Would you mind also maybe adding a new JUnit for this scenario to the org.eclipse.wst.xsd.validation.tests plug-in. I would probably suggest the BugFixes tests suite. There's an "honour all schema location" test in there so you can probably model a new test after that. Pick one or more scenarios that are only showing up when the new option is on and follow the bread crumbs :-).

Regarding the WSDL validator, you're right, it would be good if it was consistent. Refactoring is the ideal way to maintain consistency although we have to make sure there are no other valid reasons for the duplication.

Lawrence, are there any reasons why refactoring may not be recomended here? I'm thinking maybe you were trying to minimize dependencies between the XSD and WSDL validators?
Comment 19 Lawrence Mandel CLA 2007-09-24 14:02:58 EDT
The WSDL validator can run outside of Eclipse. Keeping it simple (few dependencies) and without Eclipse dependencies is key for this function. Also, there is some custom XML schema validation code required to handle inline schema validation although I expect that this could be factored out.
Comment 20 David Carver CLA 2007-09-24 15:08:32 EDT
(In reply to comment #19)
> The WSDL validator can run outside of Eclipse. Keeping it simple (few
> dependencies) and without Eclipse dependencies is key for this function. Also,
> there is some custom XML schema validation code required to handle inline
> schema validation although I expect that this could be factored out.
> 

Personally, I think the WSDL validator if it validates the XSDs should have a dependency on the XSD validator.  As it is now.. you could potentially be fixing bugs in multiple places, or in the case of the above patch potentially add a full schema conformance check to the WSDL validator (currently it also does lax schema checking instead of full conformance checking which leads to false positives that the WSDL and XSDs included are correct).

Again, I think Xerces 2.8.1 going forward addressed a lot of performance issues in the full schema checking arena.

I'll create a JUnit test to go along with the patch to test the validation scenario and compliance.   I might be able to find something from the W3C schema test suite that could be used as input to the tests.  The full conformance in xerces enables identity constraint and key constraint checking of the schema itself.

Comment 21 Nicolas Mailhot CLA 2007-09-24 15:24:03 EDT
From a user point of view, it is very distressing to have the same schemas behave differently when validated alone and when validated through and wsdl import. Please use a single validating path and make is as anal as necessary.

When tools disagree, especially when two parts of the same tool disagree, humans waste hours trying to sort which one is right.

Comment 22 Lawrence Mandel CLA 2007-09-24 15:59:23 EDT
Dave and Nicolas - Thanks for your comments. 

I agree that there should be one schema validator. I too have experienced inconsistencies in my tools and find it extremely irritating. The WSDL validator should make use of the XML schema validator for inline schema validation. As I mentioned in comment #19, there are other requirements on the WSDL validator and we need to ensure this change is done without breaking existing usage scenarios. I think this has entered into new bug territory. Would one of you care to open a bug to voice your frustration?
Comment 23 David Carver CLA 2007-09-24 17:01:35 EDT
Created bug 204488 to address the refactoring that should occur.
Comment 24 Valentin Baciu CLA 2007-09-27 15:48:24 EDT
David, I assume the patch you attached is for the 3.0 stream right? Have you made any progress with the unit test? Do you need any information/help from me?
Comment 25 David Carver CLA 2007-09-27 15:53:36 EDT
(In reply to comment #24)
> David, I assume the patch you attached is for the 3.0 stream right? Have you
> made any progress with the unit test? Do you need any information/help from me?
> 

Yes, patch is against the Head branch in CVS.  Haven't had a chance to get to the junit test, maybe tomorrow.  Been swamped with the job that pays the bills.
Comment 26 David Carver CLA 2007-09-28 12:08:39 EDT
Created attachment 79410 [details]
JUnit Test for Full Conformance Patch

Adds a Junit Test in the BugFixesTest.java for the Full XML Schema Conformance checking patch.   This test uses as input the sample file that is attached to this bug.
Comment 27 Valentin Baciu CLA 2007-09-28 12:33:51 EDT
Good stuff, Dave. We are in lock down mode to declare M2 so I am tentatively targetting this for early M3.
Comment 28 Valentin Baciu CLA 2007-10-29 10:15:47 EDT
Nitin, please review, commit and release for WTP 3.0. Thank you.
Comment 29 Nitin Dahyabhai CLA 2007-11-01 01:42:45 EDT
Released for M3 with some changes:
1) The checkboxes on the preference page are in a single column.
2) The GridData objects are built using the recommended SWT constants instead of GridData's, and using separate instances for the two checkboxes (as directed in the GridData javadoc).
3) Changed the label "Full XML Schema conformance check" to "Check full XML Schema conformance".

Thanks for the patches, David.
Comment 30 Amy Wu CLA 2007-11-12 15:47:39 EST
Hi Dave,

The fix for this bug sounds like a New & Noteworthy item (http://dev.eclipse.org/mhonarc/lists/wtp-dev/msg05699.html)

Would you be willing to write up a little blurb for this?  It should just be a sentence or two describing the new feature (in this case, the new preferences) and screenshot. Here's an example: http://www.eclipse.org/webtools/development/news/3.0M3/javaee.php

You can just add it as a comment here and attach a screenshot to this bug.  If you can't do this by the end of day tomorrow (Tuesday) or if I don't hear from you by then, that's fine, I'll just go ahead and do it myself.
Comment 31 David Carver CLA 2007-11-12 15:52:56 EST
Amy, I might be able to get to it tonight, pretty swamped today though.  If you don't get something from me, please go ahead and write it up.
Comment 32 David Carver CLA 2007-11-12 19:37:30 EST
Created attachment 82720 [details]
Image of "Check Full Schema Conformance' fix

Image showing new preference option for XSD validation.
Comment 33 David Carver CLA 2007-11-12 19:39:21 EST
Amy, hope this is what you wanted:

The XSD Preference page now has a new option to toggle whether XSDs are checked for full conformance to the XSD specification.   This will enforce tighter adherence to the XML schema specification.  This option is enabled by default.
Comment 34 Keith Chong CLA 2007-11-13 16:12:28 EST
Verified in build S-3.0M3-20071112224942.

Validation error appears in attached testcase (test2.xsd) when full conformance checking is enabled.  Error disappears if checking is disabled.
Comment 35 Amy Wu CLA 2007-11-13 17:09:06 EST
(In reply to comment #33)
> Amy, hope this is what you wanted:

Looks good, thanks Dave!
Comment 36 Valentin Baciu CLA 2007-11-15 14:37:29 EST
Closing.
Comment 37 David Williams CLA 2008-04-24 00:44:56 EDT
mass change to add 'contributed' keyword based on bugzilla query, please correct if that's not accurate (by marking patches as obsolete and removing the 'contributed' keyword.