SCA

SDO Type API examples

test_getTypes.c
Basic enumeration of all defined types
test_isSequencedType.c
Testing whether a type is sequenced

test_getTypes.c

#include "SDO.h"
#include "assert.h"


// Basic enumeration of all defined types
void test_getTypes() {
	SDOFACTORY df = dfAlloc("test");

	stypeDefine(df,
		"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n"
                "            targetNamespace=\"http://www.example.com\"\n"
                "            xmlns=\"http://www.example.com\">\n"
		"  <xsd:simpleType name=\"myType\">\n"
		"    <xsd:restriction base=\"xsd:string\"/>\n"
		"  </xsd:simpleType>\n"
		"</xsd:schema>\n");
	
	int found = 0;
	SDOLIST l = getTypes(df);
	for (int i = 0; i < getCountList(l); i++) {
		SDOTYPE t = getTypeList(l, i);
		if (!strcmp("myType", getTypeName(t))) {
			found = 1;
			break;
		}
	}

	assert(found);
}

test_isSequencedType.c

#include "SDO.h"
#include "assert.h"


// Testing whether a type is sequenced
void test_isSequencedType() {
	SDOFACTORY df = dfAlloc("test");

	stypeDefine(df,
		"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n"
                "            targetNamespace=\"http://www.example.com\"\n"
                "            xmlns=\"http://www.example.com\">\n"
		"  <xsd:complexType name=\"myType\">\n"
		"    <xsd:sequence>\n"
		"      <xsd:element name=\"elmt\" type=\"xsd:string\"/>\n"
		"    </xsd:sequence>\n"
		"  </xsd:complexType>\n"
		"</xsd:schema>\n");
	
	assert(isSequencedType(findType(df, "http://www.example.com", "myType")));
}