The fixed attribute only sets the content if the element actually appears in the XML.
If it is omitted, no content is set.
If the fixed attribute is set and the element is empty, the element's value is automatically set to the fixed value.
File: Schema.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.java2java.com"
xmlns="http://www.java2java.com"
elementFormDefault="qualified">
<xsd:element name="status" type="xsd:string" fixed="endangered" />
</xsd:schema>
File: Data.xml
<?xml version="1.0"?>
<status xmlns="http://www.java2java.com">endangered</status>
|