test_setList_opencontent.c
#include "SDO.h"
#include "string.h"
#include "assert.h"
// Using open content properties (XML Schema wildcards)
void test_setList_opencontent() {
SDOFACTORY df = dfAlloc("setList_opencontent");
stypeDefine(df,
"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n"
" targetNamespace=\"http://www.example.com\"\n"
" xmlns:t=\"http://www.example.com\">\n"
" <xsd:complexType name=\"setListOpencontent\">\n"
" <xsd:sequence>\n"
" <xsd:any maxOccurs=\"unbounded\"/>\n"
" </xsd:sequence>\n"
" </xsd:complexType>\n"
"</xsd:schema>\n");
DATAOBJECT d = doAlloc(df, "http://www.example.com", "setListOpencontent");
SDOPROPERTY p = defineOpenContentProperty(df, 0, "prop", 0);
SDOLIST l = getList(d, p);
appendStringList(l, "first value");
appendStringList(l, "second value");
setList(d, p, l);
SDOLIST l2 = getList(d, p);
assert(getCountList(l2) == 2);
for (int i = 0; i < getCountList(l2); i++) {
char *s = getStringList(l2, i);
if (i == 0) {
assert(!strcmp("first value", s));
}
else if (i == 1) {
assert(!strcmp("second value", s));
}
else {
assert(0);
}
}
}