Bug 197947 - "Honour all schema locations" doesn't affect XML validation
Summary: "Honour all schema locations" doesn't affect XML validation
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 2.0   Edit
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Valentin Baciu CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2007-07-26 07:43 EDT by Jesper Moller CLA
Modified: 2009-06-11 14:32 EDT (History)
2 users (show)

See Also:


Attachments
Example files to show the problem (1.44 KB, application/zip)
2007-07-26 07:51 EDT, Jesper Moller CLA
no flags Details
Patch for XML validation + preferences (10.24 KB, patch)
2007-07-26 08:20 EDT, Jesper Moller CLA
valentinbaciu: iplog+
Details | Diff
Updated patch against HEAD (10.47 KB, patch)
2009-02-20 10:07 EST, Jesper Moller CLA
valentinbaciu: iplog+
Details | Diff
Modified patch (91.18 KB, patch)
2009-02-25 09:18 EST, Valentin Baciu CLA
no flags Details | Diff
Updated patch (60.67 KB, patch)
2009-02-27 14:24 EST, Valentin Baciu CLA
no flags Details | Diff
Patch (75.34 KB, patch)
2009-03-01 22:32 EST, Valentin Baciu CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesper Moller CLA 2007-07-26 07:43:42 EDT
We are forced to work with schemas that directly or indirectly import schema files from different locations, which is made possible by fixes for the XSDs in bug 105387 and bug 137386.

However, the problem still exists for the XML validation itself, i.e. validating instances conforming to the affected schemas.

The problem is easy to reproduce by extracting the four files enclosed in the attachment:

A.xsd defines element A and imports B1.xsd and B2.xsd
B1.xsd defines element B1
B2.xsd defines element B2
A-instance.xml contains an A which contains a B1 and a B2.

The XML Schema Validation preference for "Honour all schema locations" must be ON, otherwise there will be validation errors in A.xsd.

However, an error is still found in A-instance.xml at the start of B2.
So there's an inconsistency between the XML and XSD settings.

I've looked at the code and it's not a straightforward fix, since it would be awkward for the XML validation code to refer to the XSD's preference values, no? And having "Honour all schema locations" always be on for XML validation would be confusing. But then, so would having two separate checkboxes, or even moving the checkbox to the XML page (since the XSD support relies on the XML support, but not nice versa)
Comment 1 Jesper Moller CLA 2007-07-26 07:51:11 EDT
Created attachment 74673 [details]
Example files to show the problem

Zip archive containing the three XML Schema files and the single XML instance document showing the problem:
Even with Window > Preferences... > Web and XML > XML Schema Files > Honour all schema files CHECKED, the XML instance still shows an error. And there's no similar checkbox for XML.
Comment 2 Jesper Moller CLA 2007-07-26 08:20:28 EDT
Created attachment 74674 [details]
Patch for XML validation + preferences

A patch which adds a "Honour all XML schema locations" checkbox to XML File preferences.

The checkbox is added below "Warn when no grammar is specified" on the "XML File" Preferences page.

There is no link to the equivalent setting on the XSD page.
Comment 3 Nitin Dahyabhai CLA 2007-07-26 18:08:44 EDT
Thank you for the patch, Jesper.

Valentin, it sounds like this should be added to the XML preferences, but should we also change the XML Schema preferences to use this value?
Comment 4 Valentin Baciu CLA 2008-02-28 08:23:00 EST
(In reply to comment #3)
> Thank you for the patch, Jesper.
> Valentin, it sounds like this should be added to the XML preferences, but
> should we also change the XML Schema preferences to use this value?

Hmm, I see the potential for reuse here but on the other hand I am wary of the coupling it introduces. I'll give it some thought for M6.

Comment 5 Valentin Baciu CLA 2008-03-27 14:55:30 EDT
Sorry, due to time constraints and other more pressing issues I have not been able to reflect on the best approach for this bug. Given that the UI and API freeze has passed I am going to move this out to Future. I chose Future because I don't know if the next release will be named 4.0 or something else.

Thank you again for your contribution, we'll definitely reconsider this for the next release.
Comment 6 Jesper Moller CLA 2009-02-18 08:26:43 EST
Have you given this more thought? I think the bug is still relevant: It is pretty confusing that the option exists for XSD but not for XML.

Regarding the preferences options, and improvements to the patch:

Since XSD support relies on XML, we could move the primary switch value to the XML preferences, change the XSD validation to look at the XML setting and it that's not set (for converted workspaces), revert to the XSD prefs setting.

As for UI, we could move the checkbox to the XML vaildation page, and then on the XSD page, set a text describing the current setting, like: "All schema locations are / are not honored when validating XML Schema Files, as set in XML Validation Preferences", using a link to XML Validation Preferences page.

Yes, it adds coupling, but IMHO it's intuitive and doable -- and backwards compatible.

Any chance for 3.1 M6?
Comment 7 Valentin Baciu CLA 2009-02-19 16:13:21 EST
Hi Jesper, does the patch still apply OK to 3.1 HEAD? If not, could you please provide an updated patch? I'll look it over.

In all honesty, it is a bit late, and depending on the patch size we may need IP approval. 

Nitin, do you think we can still get IP approval this late for 3.1? 
Comment 8 Nitin Dahyabhai CLA 2009-02-20 01:49:30 EST
We can try.
Comment 9 Jesper Moller CLA 2009-02-20 10:07:10 EST
Created attachment 126301 [details]
Updated patch against HEAD

This patch applies cleanly to 3.1 (HEAD) and is a lot smaller than the CQ limit.
Comment 10 Jesper Moller CLA 2009-02-24 04:08:09 EST
I somehow forgot that the CQ limit is actually 250 lines, but the patch is still only 217 lines, so the IP review should not be required, right?
Comment 11 David Carver CLA 2009-02-24 09:47:55 EST
(In reply to comment #10)
> I somehow forgot that the CQ limit is actually 250 lines, but the patch is
> still only 217 lines, so the IP review should not be required, right?
> 

Jesper you are correct, it shouldn't be required since it's under 250.
Comment 12 Valentin Baciu CLA 2009-02-25 09:18:12 EST
Created attachment 126719 [details]
Modified patch

I've started with Jesper's patch and refactored the XML and XSD preference pages to align it with the other XML and SSE-ish preferences (HTML, etc).

I moved the validation preferences to their own pages, moved the XSD editor preferences to their own page and provided links between some of them.

The patch is probably not complete nor fully tested but wanted to throw it out there and solicit feedback early.
Comment 13 Nitin Dahyabhai CLA 2009-02-25 13:52:06 EST
Update patch mostly looks good to me, but you've got what look like unrelated changes to XSDEditorContextIds in there, and I'm not sure whether the preference key itself needs to become real API or if we need to provide an API way to read the value.  Potentially it's a value that's required by every XML validator that gets created.  And I'm not sure the XSD Validation page's link text needs to remind people that this page is for the XML Schema Validator.
Comment 14 Valentin Baciu CLA 2009-02-27 12:58:13 EST
Thank you for the comments Nitin. 

The XSDEditorContextIds changes were just code clean-up changes to remove the public static final qualifiers for all constants, not needed in an interface. I'll leave them alone for now to avoid confusion.

Are you suggesting a one method plug-in level API or a new class? I could see a new class being useful here, given that we get new requests like the ones in bug 266392. We could have the XMLCorePlugin provide an instance of this class.

Regarding the link on the XSD validator preferences page, I tried to keep it consistent with the editor preferences for example. I can take first sentence out.

I'll post an updated patch once I hear back from you on the best API approach here.
Comment 15 Valentin Baciu CLA 2009-02-27 14:24:19 EST
Created attachment 127034 [details]
Updated patch

Implements some of the changes suggested by Nitin. I've also refactored the XInclude support, as it seems to me the setting was pushed too deep. There should be no observable behaviour change.

The API issue is still to be decided. Until we do that, I'd like to check this in to allow me to work on adding the two additional XInclude preferences.
Comment 16 Valentin Baciu CLA 2009-03-01 22:32:03 EST
Created attachment 127127 [details]
Patch

Minor UI changes (mnemonics) and adds two new XML validation unit tests: one for XInclude feature and one for the new honour all schema locations feature.
Comment 17 Valentin Baciu CLA 2009-03-01 22:36:25 EST
Last patch committed and released for WTP 3.1 builds > v200903020335 UTC.
Comment 18 Jesper Moller CLA 2009-03-02 04:13:02 EST
Thank you very much for taking the time to deal with this one - it will make WTP a better XML IDE. Now I'm only hoping for bug 112284... :-)

I've verified the commit, works fine, so I'm marking as FIXED.
Comment 19 Valentin Baciu CLA 2009-03-02 07:35:30 EST
Thank you for verifying Jesper. The reason I did not mark as fixed yet is because there are a few loose ends: the API Nitin suggested and the migration of old workspaces. I simply wanted to get the UI changes in as soon as possible.
Comment 20 Valentin Baciu CLA 2009-03-11 16:16:07 EDT
I gave this some more thought: I would think that the preference name becomes implicitly API given that it can be set for example through the product configuration preference. I will deal with the migration issue in M7.
Comment 21 Valentin Baciu CLA 2009-06-11 14:32:38 EDT
Closing.