TOC PREV NEXT INDEX


Any Type


Types defined in the XSD as anyType are generated as a structure which stores attributes and textual content. In C, which uses the OSXSDAnyType struct, the textual content is represented by an OSXMLSTRING, and the attributes are stored in an OSRTDList of OSAnyAttr*. C++ uses the OSXSDAnyTypeClass, which stores the textual content in an OSXMLSTRING, and the attributes in an OSRTObjListClass of OSAnyAttrClass*.

The general mapping is as follows:
XSD type:
<xsd:complexType name="TypeName">
 
   <restriction base="xsd:anyType"/>
 
</xsd:simpleType>
 
 
Generated C code:
typedef OSXSDAnyType TypeName;
 
 
Generated C++ code:
class TypeName : public OSXSDAnyTypeClass {
 
   ...
 
} ;
 

For C, a variable of this type can be populated as follows:
	TypeName anyTypeVal;
 
	OSAnyAttr* pAnyAttr;
 
	anyTypeVal.value.cdata = FALSE;
 
	anyTypeVal.value.value = (const OSUTF8CHAR*) "<content>a</content>";
 
	pAnyAttr = rtxMemAllocType (pctxt, OSAnyAttr);
 
	pAnyAttr->name = (const OSUTF8CHAR*) "attrname";
 
	pAnyAttr->value = (const OSUTF8CHAR*) "attrvalue";
 
	rtxDListAppend (pctxt, &anyTypeVal.attrs, (void*) pAnyAttr);	
 

In the case of C++, a variable of this type can be populated as follows:
	TypeName anyTypeVal;
 
	OSRTObjListClass* pList = anyTypeVal.getAttrListPtr();
 
	OSAnyAttrClass* pAttr = new OSAnyAttrClass ("attrname", "attrvalue");
 
	anyTypeVal.setValue ("<content>a</content>");
 
	pList->appendCopy (pAttr);	
 

 
This will set the cdata member to false as above, do a deep-copy of the text into the object, and do a deep-copy of the attribute into the object.

Copyright © Objective Systems 2002-2008
This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included.

Objective Systems, Inc.

55 Dowlin Forge Road
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com

TOC PREV NEXT INDEX