简体   繁体   中英

XML Schema: What does a restriction with only a base attribute mean?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM