Hello All,
I'm trying to do schema validation on an xml file. I set the following
features:
parser->setFeature(XMLUni::fgDOMNamespaces, true);
parser->setFeature(XMLUni::fgXercesSchema, true);
parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
schema_file = XMLString::transcode("message.xsd");
parser->setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocat
ion, schema_file);
parser->setFeature(XMLUni::fgDOMWhitespaceInElementContent, false);
// installing error handler
parser->setErrorHandler(&handler);
But somehow, when I run the program, it seems to be only doing
validation -- i.e. complains about malformatted or mismatched tags. But
it doesn't do full schema validation. For example, in one test case, I
misspell a tag:
<badtag>mytest</badtag>
In another test case, I put a string as a value to an attribute which
should be an integer specified in schema:
<exchange repeat="abcd">
where the definition for attribute "repeat" in xsd is:
<xs:attribute name="repeat" type="xs:positiveInteger" use="optional"
default="1"/>
It didn't give error in either case.
Here is the head of my xsd file:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="Message">
...
The xsd and xml files are correct as I feed both files to another
application written in xerces-j, and it printed errors.
Did I miss something in my C++ code? Could anyone shed some lights on
this problem?
Thanks,
Jane