Any Element

An element in a sequence can be declared using the xsd:any keyword to indicate that an element of any type can be present in that position. An example of this type of construct is as follows:

      <xsd:complexType name="SeqWithAny">
         <xsd:sequence>
            <xsd:element name="a" type="xsd:string"/>
            <xsd:any processContents="lax"/>
          </xsd:sequence>
       </xsd:complexType>

In this case, the element a is followed by another element with any name and of any type. The processContents="lax" attribute tells a schema processor to do lax validation processing on the element in this position – something that is of no concern to the XBinder compiler.

The generated C type definition for this type is as follows:

       typedef struct SeqWithAny {
          OSXMLSTRING a;
          OSXMLSTRING _any;
       } SeqWithAny;

C++ is similar except that the standard class pattern is used:

       class SeqWithAny : public OSRTBaseType {
       public:
           OSXMLStringClass a;
           OSXMLStringClass _any;
       ...
       } ;

In this case, the compiler has inserted an OSXMLSTRING typed element to represent the any field. This contains a UTF-8 character string containing the complete XML text string value.

An example code snippet that could be used to populate a C variable of this type for encoding is as follows:

       const OSUTF8CHAR* anyData = (const OSUTF8CHAR*)
              "<anyData>this is test data</anyData>";
       SeqWithAny testSeq;

       testSeq.a.value = (const OSUTF8CHAR*)"test string";
       testSeq._any.value = anyData;
       ...