TOC PREV NEXT INDEX


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;
 
	...
 


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