Reputation: 45
I imagine this is a simple question to answer but using the XSD line below, is the XML line below valid or not?
XSD
<xsd:element name="Something" type="xsd:int" use="required"/>
XML
<Something />
Upvotes: 1
Views: 255
Reputation: 5973
use="required" applies to attributes not elements. By default an element is required (minOccurs defaults to 1). If you want to change this set minOccurs/maxOccurs.
For example
<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid Studio 2017 (https://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="d">
<xs:complexType>
<xs:sequence>
<xs:element name="Item" type="xs:int" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="myAttribute" type="xs:int" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>
Upvotes: 1