xsd:any

The xsd:any element is a wildcard placeholder that allows an occurence of any element definition to occur at a given location. It is similar to the ASN.1 open type and can be modeled as such; however, ASN1C uses a special type for these items (OSXSDAny) that allows for either binary or xml textual data to be stored. This allows items to be stored in binary form if binary encoding rules are being used and XML text form if XML text encoding is used.

The definition of the OSXSDAny type is as follows:

   typedef enum { OSXSDAny_binary, OSXSDAny_xmlText } OSXSDAnyAlt;
   typedef struct OSXSDAny {
      OSXSDAnyAlt t;
      union {
         OSOpenType* binary;
         const OSUTF8CHAR* xmlText;
      } u;
   } OSXSDAny;

The t value is set to either OSXSDAny_binary or OSXSDAny_xmlText to identify the content type. If binary decoding is being done (BER, DER, CER, or PER), the decoder will populate the binary alternative element; if XML decoding is being done, the xmlText field is populated. It is possible to perform XML-to-binary transcoding of a multi-part message (for example, a SOAP message) by decoding each part and then reencoding in binary form and switching the content type within this structure.

An example of a sequence with a single wildcard element is as follows:

   <xsd:complexType name="MyType">
      <xsd:sequence>
         <xsd:element name="ElementOne" type="xsd:string"/>
         <xsd:element name="ElementTwo" type="xsd:int"/>
         <xsd:any processContents="lax"/>
      </xsd:sequence>
   </xsd:complexType>

The generated C type definition is as follows:

   typedef struct EXTERN MyType {
      const OSUTF8CHAR* elementOne;
      OSINT32 elementTwo;
      OSXSDAny elem;
   } MyType;

As per the X.694 standard, the element was given the standard element name elem.