Bug 277133 - XML Editor: schema validation&content assist only on IFileEditorInput instances
Summary: XML Editor: schema validation&content assist only on IFileEditorInput instances
Status: CLOSED INVALID
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Valentin Baciu CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2009-05-20 09:59 EDT by Luchesar Cekov CLA
Modified: 2009-11-02 15:35 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luchesar Cekov CLA 2009-05-20 09:59:21 EDT
Build ID: M20080911-1700

Steps To Reproduce:
1. Call IWorkbenchPage.openEditor(IEditorInput, "org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart", boolean) with IEditorInput different then IFileEditorInput
2. The editor is opened
3. Verify that: a) no validation against the schemas defined in the xml document is performed, b) there are error markers and assist only for the XML syntax, no errors markers for schema validation, c) no content assist against the schema types/attributes

4. Open the same thing with a IFileEditorInput and all the schema validation and content assist is working properly.



More information:
OS: Ubuntu Linux 9.4 386_64
WS: GTK
Versions:
org.eclipse.wst.xml.ui_1.0.410.v200809120143.jar
org.eclipse.wst.xsd.core_1.1.301.v200807240448.jar
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)

Hi WST Guys,
we have a RCP application that uses the WST XML editor. We want to have the nice schema content assist and validation as you type in the editor. We also have our own editor input.

Our implementation of the IEditorInput has all the standard API methods implemented acordig to the documentation of the interface. We open the XML editor with code similar to this code:

IWorkbenchPage.openEditor(IEditorInput, "org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart", boolean)

If we use our own IEditorInput implementation a) no validation against the schemas defined in the xml document is performed, b) there are error markers and assist only for the XML syntax, no errors markers for schema validation, c) no content assist against the schema types/attributes

If we open the same thing with a IFileEditorInput and all the schema validation and content assist is working properly.

After a bit of debugging I found that suspicious fragment of code in org.eclipse.wst.sse.ui.StructuredTextEditor:
protected void setDocumentProvider(IEditorInput input) {
	if (input instanceof IStructuredModel) {
		// largely untested
		setDocumentProvider(StructuredModelDocumentProvider.getInstance());
	}
	else if (input instanceof IStorageEditorInput && !(input instanceof IFileEditorInput)) {
		setDocumentProvider(StorageModelProvider.getInstance());
	}
	else {
		super.setDocumentProvider(input);
	}
}

If the editor input is not a IFileEditorInput it will enter the second if.
If the editro input is a IFileEditorInpu it will enter the third if.
This seems to originate the problem.

This looks like a bug as there is different behaviour of the XML editor based on the editor input type.
Is that behaviour intentional?

Thanks in advance,
Best regards,
Luchesar
Comment 1 Nitin Dahyabhai CLA 2009-05-20 13:48:04 EDT
What does your editor input's IStorage.getFullPath() return, for example?
Comment 2 Luchesar Cekov CLA 2009-05-21 05:29:11 EDT
It returns a relative path to the edited resource. This resource could be file or remote resource - any kind of URL. We have kind of an abstract wrapper for that resources. IStorage.getFullPath() will return the file part of the URL.

One example of a return value is: /ontologypartners/ontologies/mapping/CMB-mapping.xml

The package explorer or Navigator are not used to open them. There are proprietary views that uses IWorkbenchPage.openEditor() to open these resources.

Does it matter? The java doc says this could be anything.

* Returns the full path of this storage.  The returned value
* depends on the implementor/extender.  A storage need not
* have a path.
Comment 3 Nitin Dahyabhai CLA 2009-05-25 14:32:28 EDT
Could you attach or cite the parts of your input document that refer to the schemas you're using?
Comment 4 Luchesar Cekov CLA 2009-05-26 05:37:37 EDT
This is one example: The schema location is hard coded
<mapping xmlns="http://www.ontology.com/transformer/madrid/v1.0/schemas/mapping-schema-madrid.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ontology.com/transformer/madrid/v1.0/schemas/mapping-schema-madrid.xsd /home/lucho/mapping-schema-madrid.xsd">

<mapping>

Ot he schema location is contributed to the XMLCatalog extension point and the xml instance only refers it:
<mapping xmlns="http://www.ontology.com/transformer/madrid/v1.0/schemas/mappin>

<mapping>

In both cases the schema validation and content assist wont work if the editor input is not IFileEditorInput and will work if it is.
Comment 5 Luchesar Cekov CLA 2009-06-09 07:23:52 EDT
Hi SWT guys,

Is there any activity towards this bug?
Is it going to be fixed or it is a low priority for you?
Comment 6 Luchesar Cekov CLA 2009-08-14 10:24:55 EDT
I found the reason the markers are not shown.

It is a bit tricky but in general StructuredTextEditor requires IFileEditorInput and a IModelProvider document provider associated with it.

To use it with custom implementation of IEditorInput is very hacky at best and requires lots of work to be made correct. 
Comment 7 Valentin Baciu CLA 2009-11-02 15:35:52 EST
Closing.