Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » XML files with missing namespace/schema
XML files with missing namespace/schema [message #879460] Thu, 31 May 2012 09:14 Go to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
Hi everyone,

I have a particular sapphire model that declares the following for the XML info:
@XmlNamespace( prefix = "", uri = "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" )
@XmlSchema( namespace = "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd", location = "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" )
@XmlBinding( path = "portlet-app" )


If an existing XML file has all of these values set properly there is no problem. However, if there is a file that looks like this:
<portlet-app>
</portlet-app>


Sapphire is unable to open this model and the editor just shows edit part. The problem is that in my multi-page editor (masterdetails and source) the user can't even edit in the source or continue.

Debugging the code I see why it can't open the file as it doesn't know how to operate without the schema information. Is there a way to let sapphire model know that if the binding-path matches but the namespace and schema locations are null the defaults could be used in their absence?

Another question would be if there would be a way to let the model fail as it is now and it only disable the masterdetails page and not kill the whole editor in the case of a multi-page editor (SapphireEditorForXml).

Appreciate any thoughts on this matter.
Re: XML files with missing namespace/schema [message #879668 is a reply to message #879460] Thu, 31 May 2012 15:58 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Quote:
Sapphire is unable to open this model and the editor just shows edit part. The problem is that in my multi-page editor (masterdetails and source) the user can't even edit in the source or continue.


The editor should definitely not fail to open. I tried your scenario with contacts sample:

<contacts>
</contacts>


The editor opens. I can see source and contacts pages. Performing any edit operation on the form page pops up a yes/no dialog:

"This file appears to be malformed. Do you want a fresh start?"

If user selects yes, the editor buffer contents are replaced with the correct root element. If user selects no, they can correct the problem in the source view.

This is all working as intended.

Quote:
Is there a way to let sapphire model know that if the binding-path matches but the namespace and schema locations are null the defaults could be used in their absence?


You should be able to achieve something similar via @CustomXmlRootBinding. Once root element is established with either a namespace or no namespace, the rest of the XML binding can be declarative as Sapphire infers namespace from parent element unless explicitly specified. Note that if there is no namespace and schema, Sapphire will not be able to order elements correctly, so edits performed in this state may violate schema's ordering constraints.

- Konstantin

[Updated on: Thu, 31 May 2012 15:58]

Report message to a moderator

Re: XML files with missing namespace/schema [message #882757 is a reply to message #879668] Thu, 07 June 2012 06:04 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
Hey Konstantin,

Thanks for trying this with contacts. I see the same behavior but for my model I wasn't seeing this behavior. After tracing through the creation of the model for both contacts database and my own portlet model, I see the problem. In my portlet model there was a @InitialValue(...) on one of the properties. So during the elementImpl instantiation when the initial value is getting processed it can't parse the xml file correctly and fails with a "Corrupted XML resource" exception.

So it turns out that when this portlet model was authored, I didn't understand sapphire as well as I do now and I know that @DefaultValue is the proper annotation to use, initial value is not what I want here. When I switched to @DefaultValue(...), then I don't see this issue anymore and I see the same behavior as with this contacts database.

[Updated on: Thu, 07 June 2012 06:06]

Report message to a moderator

Re: XML files with missing namespace/schema [message #885188 is a reply to message #879668] Tue, 12 June 2012 15:16 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Using @InitialValue annotation should not be disrupting other functionality. Could you open a bug for this?
Re: XML files with missing namespace/schema [message #885427 is a reply to message #885188] Wed, 13 June 2012 01:18 Go to previous message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
Done, thanks. https://bugs.eclipse.org/bugs/show_bug.cgi?id=382453
Previous Topic:Aligning Sapphire 0.5 release with Juno
Next Topic:Problem while exporting a plugin
Goto Forum:
  


Current Time: Tue Apr 23 05:30:51 GMT 2024

Powered by FUDForum. Page generated in 0.03815 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top