Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Binding for List of Strings
Binding for List of Strings [message #1227563] Sat, 04 January 2014 22:49 Go to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
Hi,

we are trying to build a sapphire model for an xml schema having several lists containing primitive types. I couldn't figure out how to model that using ListProperty with XmlListBinding annotation.

Before I dive into a custom xml list binding class, I want to ensure that this is not supported out of the box yet.

A simple example:

XML Schema:
	
	<element name="Root">
		<complexType>
			<sequence>
				<element name="Languages">
					<complexType>
						<sequence maxOccurs="unbounded">
							<element name="Language" type="string"/>
						</sequence>
						<attribute name="DefaultLanguage"/>
					</complexType>
				</element>
			</sequence>
		</complexType>
	</element>


XML Sample:
<Root>
	<Languages DefaultLanguage="en">
		<Language>en</Language>
		<Language>de</Language>
	</Languages>
</Root>


Defining the following Sapphire Model for Root...
	/**
	 * default language
	 */
	@XmlBinding(path = "Languages/@DefaultLanguage")
	@Label(standard = "Default Language")
	@Required
	ValueProperty PROP_DEFAULTLANGUAGE = new ValueProperty(TYPE, "DefaultLanguage");

	Value<String> getDefaultLanguage();

	void setDefaultLanguage(String value);

	/**
	 * languages
	 */
	@Type(base = ILanguage.class)
	@Label(standard = "Languages")
	ListProperty PROP_LANGUAGES = new ListProperty(TYPE, "Languages");

	ElementList<ILanguage> getLanguages();

... and ILanguage ...
	/**
	 * language
	 */
	@Label(standard = "Language")
	@Required
	ValueProperty PROP_LANGUAGE = new ValueProperty(TYPE, "Language");

	Value<String> getLanguage();

	void setLanguage(String value);


... of course results in the following, which is not what I want as it contains a wrapping Language Element:
<Root>
    <Languages DefaultLanguage="123">
        <Language>
            <Language>de</Language>
        </Language>
    </Languages>
</Root>


I thought about writing a PrimitiveListBinding by using a similar approach like DelimitedListBinding. But is that really necessary?

Please consider that the ILanguage element might gets an addtional (derived) value property for providing a more end-user friendly representiation of the 'language' input: e.g. input contains 'en' and the second column shows 'English'.

Thanks once more.
Andreas

[Updated on: Sat, 04 January 2014 22:51]

Report message to a moderator

Re: Binding for List of Strings [message #1227617 is a reply to message #1227563] Sun, 05 January 2014 03:14 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 952
Registered: July 2009
Senior Member
If you add @XmlBinding( path = "" ) to the ILanguage.Language value property, you should get the behavior that you are after.

[Updated on: Sun, 05 January 2014 03:14]

Report message to a moderator

Re: Binding for List of Strings [message #1227698 is a reply to message #1227563] Sun, 05 January 2014 09:19 Go to previous message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
I knew it would be that easy. Thanks, works like a charm!
Previous Topic:Details on P2 Features Scope
Next Topic:Sapphire 0.8 is now Sapphire 8
Goto Forum:
  


Current Time: Tue Nov 25 23:40:27 GMT 2014

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

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