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.