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