views:

210

answers:

1

Hi,

I am creating attributes for a complex-type element. I created an attribute, which itself is of complex type. When I tried compiling my code, it threw an error saying could not find simple-type attribute corresponding to the attribute of complex-type. Can't we create attributes of complex-type?..I also looked at w3c schools, but it does not elaborate much on attributes for complex-type elements.

Thanks!

+1  A: 

You cannot have complex types as attributes - only basic types like string, int and so forth. You can restrict your values (e.g. define a maximum length for a string, or a value range for an int), but you CANNOT use a complex type as an attribute in XSD.

For reference, check the MSDN Library:

The name of a built-in data type or a simple type defined in this schema (or another schema indicated by the specified namespace). The type must be a QName. The type can include a namespace prefix. The type attribute can only be present when the content does not contain a simpleType element.

The built-in data types are all simple types (string, int, etc.).

Marc

marc_s