I use xerces to valid a xml instance against schema:
parser.setFeature("http://xml.org/sax/features/namespaces", true);
parser.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
schemaLocation);
parser.setFeature("http://apache.org/xml/features/validation/schema", true);
parser.parse(new InputSource(xml));
Here is my xml instance:
<?xml version="1.0"?>
<eml:eml packageId="tao.12926.1" system="knb" xmlns:eml="eml://ecoinformatics.org/eml-2.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="eml://ecoinformatics.org/eml-2.1.0 eml.xsd">
<dataset>
.......
</dataset>
</eml:eml>
This xml is considered valid.
However, if i added prefix "eml" to element "dataset":
<?xml version="1.0"?>
<eml:eml packageId="tao.12926.1" system="knb" xmlns:eml="eml://ecoinformatics.org/eml-2.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="eml://ecoinformatics.org/eml-2.1.0 eml.xsd">
<eml:dataset>
.......
</eml:dataset>
</eml:eml>
It give me an error: cvc-complex-type.2.4.a: Invalid content starting with element 'eml:dataset'. The content must match '((("":access){0-1},(((("":dataset)|("":citation))|("":software))|("":protocol))),("":additionalMetadata){0-UNBOUNDED})'.
I couldn't understand this. "dataset" has the default the namespace during our schema definition. "dataset" just a abridged version of "eml:dataset". Why xerces doesn't like ?
Would you please give me some clue?
Thanks!