Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Advise for the use of Sapphire with present schema file
Advise for the use of Sapphire with present schema file [message #1060124] Thu, 23 May 2013 08:05 Go to next message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
Hey,

I'm suppose to build an editor for some a xml file that also has a corresponding schema file. I started with some multi page editor and was looking for some problem on StackOverflow, as I found Sapphire. I had a look on the examples, that basically consist of some Java interfaces (responsible for the model that implies the mapping to the xml files) and some xml files that do the arrangement of the UI elements (I hope, I got this right). I'm impressed and it really seams to speed up UI development!

As the creation of my visual editor would take at least two/three weeks, I would like to try Sapphire on this task. How should I start? I already have a schema file for the xml content. The schema is complicated and consists of a long hierarchy. An example for the xml hierarchy would be A -> B -> C. To make this process more convenient, I would like to hide some of the xml hierarchy, e.g. skip B and let the user provide directly A -> C. Is this possible?

I have read the introduction and also tried the examples. Is there a way I could automate the creation of the interfaces/annotations from my schema files? Or do I have to start from scratch?

Thank you!

Kon
Re: Advise for the use of Sapphire with present schema file [message #1060238 is a reply to message #1060124] Thu, 23 May 2013 16:14 Go to previous messageGo to next message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
I'm trying to implement the following xml structure:

<a>
  <b>
    <c>information</c>
  </b>
  <b>
    <c>information2</c>
  </b>
  <b>
    <c>information3</c>
  </b>
</a>


I don't want to show the b element to the user since it does not contain any information - it basically wraps c. The UI show look this:

<a>
  <c>information</c>
  <c>information2</c>
  <c>information3</c>
  </b>
</a>


Unfortunately, I can't change this structure. I investigated the examples and found the @CustomXmlValueBinding examples, that works nice for vales e.g. some phone number. I also found @CustomXmlElementBinding, but I could find any example for it. I might be wrong but can I use @CustomXmlElementBinding to skip the b element while reading the xml file and and it on write? Thank you!
Re: Advise for the use of Sapphire with present schema file [message #1060242 is a reply to message #1060124] Thu, 23 May 2013 16:24 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Quote:
basically consist of some Java interfaces (responsible for the model that implies the mapping to the xml files) and some xml files that do the arrangement of the UI elements (I hope, I got this right).


Yep. You got it right.

Quote:
To make this process more convenient, I would like to hide some of the xml hierarchy, e.g. skip B and let the user provide directly A -> C. Is this possible?


Sure. The various XML binding annotations support path notation, so you could for instance say @XmlBinding( path = "Name/First" ) and @XmlBinding( path = "Name/Last" ) in your model if an explicit Name element in your model and UI would not be useful.

Quote:
Is there a way I could automate the creation of the interfaces/annotations from my schema files?


Sapphire does not provide a tool for generating a model from an XML schema, since XML schema is a specification of syntax rather than semantics. Automatically generating a model from an XML schema would result in a bloated model that would not produce a good UI. No automation can look at XML Schema and differentiate elements that are relevant to the semantics of the data from those that serve as syntactic sugar.

The quality of the model directly corresponds to the quality of Sapphire UI. I recommend an iterative approach. Add a property at a time to the model and sdef file after you've understood its semantics from XML Schema, docs, relevant experts, etc.

- Konstantin

[Updated on: Thu, 23 May 2013 16:25]

Report message to a moderator

Re: Advise for the use of Sapphire with present schema file [message #1060243 is a reply to message #1060242] Thu, 23 May 2013 16:31 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
You should not need to write a custom binding for this scenario. Use @XmlListBinding to map child elements to "b" element. Then inside child model element use @XmlBinding( path = "c" ) on the value property.
Re: Advise for the use of Sapphire with present schema file [message #1060397 is a reply to message #1060243] Fri, 24 May 2013 13:24 Go to previous message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
Thank you Smile
Previous Topic:How to create File from Model?
Next Topic:Heterogeneous list with no common property
Goto Forum:
  


Current Time: Tue Mar 19 08:06:57 GMT 2024

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

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

Back to the top