XML Schema / Validation Query

Soldato
Joined
7 Apr 2004
Posts
4,212
Hey,

If you have an XML schema which dictates an element has a default value, and then you have an XML file following that schema which completely omits that element is it still valid?

i.e if the element is missing does the validator just say ok the element is missing so we take the default value defined in the schema and the XML is valid?

So maybe something like

Code:
<xs:element name="example" type="xs:boolean" default="false"/>

Then an XML file that misses out the 'example' element all together, is that valid?

The reason I ask is because the schema im working with has many elements using the attribute: minOccurs="0" which infers that if those elements are missing then it will still validate. My question is will it validate if minOccurs is not specified but there is a default value specified instead.

I would make a validation test case but I haven't got the software/data on me at the moment :(

Thanks.
 
Back
Top Bottom