Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sapphire-dev] New topic in forum Sapphire, called Binding for List of Strings, by Andreas Weise

Title: Eclipse Community Forums
Subject: Binding for List of Strings Author: Andreas Weise Date: Sat, 04 January 2014 17:49
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 diving 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:
<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
[ Reply ][ Quote ][ View Topic/Message ][ Unsubscribe from this forum ]

Back to the top