views:

85

answers:

1

What would it mean to create something like the following?

<xsd:simpleType name="myField">
    <xsd:restriction base="xsd:boolean"/>
</xsd:simpleType>

Notice there are no actual elements within the restriction (no min or max length, no enumerations, etc). I feel like this is basically setting the type of myField to xsd:boolean.

However, I have both of the following in my wsdl:

(the example from above)

and

<xsd:element name="myOtherField" type="xsd:boolean"/>

When using JaxRPC or Apache Axis (to convert to a java object skeleton), the first gets converted into a Boolean (object), where as the latter example gets converted into a boolean (primitive). This tells me that the first example posted somehow signifies the element is optional, but I don't understand how.

I agree that the second example should become a primitive, but why is the first example a Boolean?

Updated: Made second node name generic

+1  A: 

The only reason I see for that is that elements have a default minimum of 1, so it makes sense that it is boolean.

On the other hand, simple types are commonly used in attributes and these are tipically optional. So it probably is a matter of where it's used.

Silver Phoenix
Up vote for providing additional detail why xsd:element would expand to a primitive. It is indeed because the default value for minoccurs under xsd:element is 1.The only question left to answer is some documentation that says simpleType or restriction type specified are implicitly optional. I have learned that they don't have minoccurs or maxoccurs attributes so I just need to find a documentation spot that sites they are by default optional.
Russ
The simpleType doesn't have a "cardinality" feature. That is implemented with the list type or facets inside restrictions. What I meant was something like: <attribute name="attr1" type="myField" use="optional"/>Attributes are optional by default. I just placed it to get the point across. If the type appears in attributes it would make sense that it is Boolean, but if it appears in elements, then I would guess it is a simplification of the program since simpleTypes are more commonly used in attributes.Try changing an attribute so that it has use="required" to see if that affects the type.
Silver Phoenix
Good call, what is actually happening is an xsd:element is declaring to be of type "myField". I was under the impression the simpleType was representing a node itself. Under the xsd:element there is a minoccurs="0". Guess that solves that problem. Thanks for the help Silver Phoenix. I apologize for the somewhat misleading question.
Russ