Dear Zulema,
> I working whit Web service in java, axis and Xerces2,
> this web service get like paremeter an XML, the which
> use a schema whith restriction, but the validations no
> work, when i introduce a bad parameter.
> Note: The error of validation are write by catalina.out
Even though you now have given a rather complete description, I'm still
not sure what you mean...
If it is, I get 'Components from namespace are not referenceable', it is
because your schema has
<xs:element name="data1" type="xs:number"/>
use xs:number which does not seem to be an XML Schema data type, looking
at
http://www.w3.org/TR/xmlschema-2/type-hierarchy.gif
(but maybe I am looking at it wrong, if XML Spy suggested/ allowed
it....)
You should change the type to e.g. xs:integer. If you change that you
would also get validation errors for instance data like
<data2>12dd13</data2>
If it is, 'the validation errors are written to catalina.out, but I want
them to throw an exception', the default error handler of Xerces prints
validation error messages to the console. If you want them handled
differently you should set an error handler on the parser. E.g.
parser.setErrorHandler(new org.xml.sax.ErrorHandler() {
public void warning(SAXParseException exception)
throws SAXException {
// do nothing
}
public void error(SAXParseException exception)
throws SAXException {
// Do whatever you want here, I throw exception
// here to stop parsing
throw exception;
}
public void fatalError(SAXParseException exception)
throws SAXException {
throw exception;
}
});
If it is, 'it does not seem to be able to find 1.xsd (e.g. the message
on the console is "Cannot find the declaration of element 'data'"',
then you need to set an entity resolver. You must understand that when
you parse a String, Xerces has no idea where to find the file 1.xsd, it
needs a way to find it. See e.g.
http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/EntityResolver.html
Kind regards,
--Sander.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]