I'm reviewing an XSD and looking for opportunities to make it less verbose.
I ran across lots of instances like this:
<xs:element name="MyElement" maxOccurs="1" minOccurs="1" nillable="false">
<xs:annotation>
<xs:documentation>Some documentation</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="MyType"/>
</xs:simpleType>
</xs:element>
Isn't that equivalent to:
<xs:element name="MyElement" type="MyType" maxOccurs="1" minOccurs="1" nillable="false">
<xs:annotation>
<xs:documentation>Some documentation</xs:documentation>
</xs:annotation>
</xs:element>
?
If it matters, here's the type:
<xs:simpleType name="MyType">
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
Yes, for all practical purposes (certainly for validation purposes) it's equivalent. There might be data-binding applications that would give different results in the two cases, I wouldn't know.
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.