I'm trying to define an .xsd file that will restrict a .xml document to contain certain information. This is the .xsd.
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/MicroscopyExperiment"
xmlns:tns="http://www.example.org/MicroscopyExperiment">
<element name="MicroscopyExperiment">
<complexType>
<sequence>
<element name="goal" type="string" minOccurs="1" maxOccurs="1"/>
<element name="cellType" type="string"/>
<element name="cellDensity" type="string"/>
<element name="injury" type="string"/>
<element name="drug" type="string"/>
<element name="media" type="string"/>
<element name="timing" type="string"/>
<element name="coating" type="string"/>
<element name="plateList">
<complexType>
<sequence>
<element name="plate"
type="tns:plateType"
maxOccurs="unbounded"
minOccurs="1"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
<complexType name="plateType">
<sequence>
<element name="goalDiff" type="string"/>
<element name="cellTypeDiff" type="string"/>
<element name="cellDensityDiff" type="string"/>
<element name="injuryDiff" type="string"/>
<element name="drugDiff" type="string"/>
<element name="mediaDiff" type="string"/>
<element name="timingDiff" type="string"/>
<element name="coatingDiff" type="string"/>
</sequence>
</complexType>
</schema>
This .xsd file validates fine in Eclipse Neon.1a Release (4.6.1).
Then I created a first .xml file to validate against this schema. This is the .xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<MicroscopyExperiment
xmlns:tns="http://www.example.org/MicroscopyExperiment"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/MicroscopyExperiment MicroscopyExperiment.xsd">
</MicroscopyExperiment>
This also validates just fine in Eclipse. I don't get any of the error messages about being unable to find the .xsd file that have been driving me crazy all day. The problem is that the .xml shouldn't validate. I set both minOccurs and maxOccurs for the goal element to be 1, to require that it occur once and only once. However, there is no goal in the .xml file right now so that should fail to validate.
Any tips would be much appreciated.
Regards,
Dessie