XML Schema / Validation Query - Missing Elements -
if have xml schema dictates element has default value, , have xml file following schema omits element still valid?
i.e. if element missing validator ok element missing take default value defined in schema , xml valid?
so maybe like:
<xs:element name="test" type="xs:boolean" default="false"/>
then xml file misses out 'example' element together, valid?
the reason ask because i've seen many schemas elements using attribute: minoccurs="0"
infers if elements missing still validate. question validate if minoccurs
not specified there default value specified instead?
thanks.
minoccurs
, default
refer 2 different concepts. question needs more context answered completely. minoccurs
refers number of times element can occur child of another. default
refers string value (sometimes typed - e.g. here boolean). use of default
on element invalid
.
here default attributes (from w3schools)
default attributes
attributes may have default value specified.
a default value automatically assigned attribute when no other value specified.
in following example default value "en":
<xs:attribute name="lang" type="xs:string" default="en"/>
and minoccurs
<xs:element name="person"> <xs:complextype> <xs:sequence> <xs:element name="full_name" type="xs:string"/> <xs:element name="child_name" type="xs:string" maxoccurs="10" minoccurs="0"/> </xs:sequence> </xs:complextype> </xs:element>
the example above indicates "child_name" element can occur minimum of 0 times , maximum of ten times in "person" element.
default
refers string value in attribute. minoccurs
means can omit element.
Comments
Post a Comment