Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 241504

Summary: XSD Validator does not validate correct the xsd files
Product: [WebTools] WTP Source Editing Reporter: Iliyan Dimov <iliyan.dimov>
Component: wst.xsdAssignee: Keith Chong <keith.chong.ca>
Status: CLOSED WORKSFORME QA Contact: Keith Chong <keith.chong.ca>
Severity: normal    
Priority: P2 CC: valentinbaciu
Version: unspecifiedKeywords: helpwanted
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Xsd file
none
wsdl file that imports xsd file none

Description Iliyan Dimov CLA 2008-07-21 04:39:52 EDT
Created attachment 107899 [details]
Xsd file

Build ID: M20080221-1800

Steps To Reproduce:
1. Import or create an XSD (See attachments).
2. Include inside the XSD file the import clause(s) :

<schema>
<import namespace="http://www.w3.org/2002/06/soap-encoding"/>
<complexType> ...
</complexType>
...

</schema>
 
3. Right Click on XSD file > Validate.
   The Validation goes successfully and there are any warning markers (!) in XSD Editor. 
   This is not the expected behaviour, because the XML Catalog page does not contains 
   path to the XSD file for the given namespace : "http://www.w3.org/2002/06/soap-encoding".

Optional Steps:  

4. Open preference page from Web and XML > XML Catalog and add the xsd file  
   for the "http://www.w3.org/2002/06/soap-encoding" namespace (take it from the URL : 
   http://www.w3.org/2002/06/soap-encoding, save it inside workspace as soap_encoding.xsd).
 
5. Right Click on XSD file > Validate 
   The validation says no problem.

6. Rename the soap_encoding.xsd file to soap_encoding_.xsd file. 
   By doing this, the XML catalog will not be able to find the xsd file during the validation. 
   Now when you (Right Click on XSD file > Validate) there will be a warning marker 
   on the open xsd file, close to the place where the file is imported.

7. The problems is that XSD Validator shows warnings only for the xsd namespaces that are inside 
   XML Catalog. For all other it silently ignores thems (instead of showing warningn marker). The XSD editor works just fine for 
   "import" elements that contains @schemaLocation attribute. 


More information:
If you open the wsdl file (see attachments) you will see that it refers to the xsd file (see attachment). 
When you Right Click on wsdl file > Validate you will see that it shows an error saying that XSD is not valid. 
It turns out that wsdl validator validates xsd inside the wsdl better that the xsd validator.
Comment 1 Iliyan Dimov CLA 2008-07-21 04:41:13 EDT
Created attachment 107900 [details]
wsdl file that imports xsd file
Comment 2 Valentin Baciu CLA 2008-09-30 11:39:43 EDT
The soap encoding import appears to be unused; that is no component refers to components from the soap encoding namespace. We may have to look into the feasibility of providing better user feedback when either the import is unused or the actual schema it points to cannot be resolved.

It seems to me this would be best addressed in WTP 3.1. Iliyan, do you require a fix for this for WTP 3.0.*?

I have marked as helpwanted.
Comment 3 Iliyan Dimov CLA 2008-10-01 03:46:44 EDT
I require a fix for both WTP 3.0.* and WTP 3.1. Its because SAP adopts every version of the Eclipse. It it important for us the bug to be fixed in all versions.
Comment 4 Valentin Baciu CLA 2008-10-01 10:48:30 EDT
OK Iliyan, we will consider it for both 3.1 and 3.0.*. 

As always, patches are welcome and appreciated.
Comment 5 Valentin Baciu CLA 2009-01-26 15:37:19 EST
Iliyan, I think the XML Schema validator works as designed. The way I understand it. the schemaLocation is just a hint and an XSD processor can choose to ignore it. The attribute itself is not required. The behaviour of not putting out any warning when there is no schema location or when the referenced schema cannot be loaded should be fine in principle. Failure to resolve the imported schema is not an error in itself, but of course it can cause downstream errors. In this case that import is not really used.

The XSD validator will always honour a schema location attribute if present. Using the XML catalog to map a namespace URI to a location is similar to specifying a schemaLocation attribute in the file. When the catalog points to an existent location all is good. When the catalog points to an bad location, then the validator will report a warning, because the validator will attempt to de-reference the location.

I would argue that it is the WSDL validator that behaves differently and not necessarily for the better. In bug 179072 I have found that the WSDL validator will always report errors for any inline schema problems, even when those are really warnings. In this case, the WSDL validator reports an error when a warning should be sufficient. I would argue that really nothing should be reported in this case by the WSDL validator. The difference in behaviour is likely due to the fact that the WSDL validator does not really reuse the XSD validator, but instead has a separate logic for inline schema validation; see bug 204488.

I am going to mark this as working as designed and hopefully we'll fix the WSDL validator sometime in the near future. Please add yourself as cc to those other bugs.
Comment 6 Valentin Baciu CLA 2009-06-11 15:07:39 EDT
Closing.