Ben,
thanks for your reply. Now the problem still remains that Digester
doesn't mind taking, say, "2003-aa-04" for a valid "xs:date" element. I
need to somehow tell Digester to use a schema while parsing. Any idea
how? Digester.setSchema(String) didn't work for me.
KarolR
Ben Walding wrote:
> For errors to be thrown you need to set the errorhandler on the digester
>
> d.setErrorHandler(new ErrorHandler() {
> public void warning(SAXParseException exception) throws
> SAXException {
> //System.out.println("Warning: " + exception.toString());
> throw new DataForgeRuntimeException(exception);
> }
>
> public void error(SAXParseException exception) throws
> SAXException {
> //System.out.println("Error: " + exception.toString());
> throw new DataForgeRuntimeException(exception);
> }
>
> public void fatalError(SAXParseException exception) throws
> SAXException {
> System.out.println("Fatal: " + exception.toString());
> }
> });
>
>
>
> Karol Rückschloss wrote:
>
>> Hello,
>>
>> I have used Digester for the last couple of weeks but never validated
>> against a schema before.
>>
>> Now I'm in a situation where I want to make Digester respect a schema
>> during the parsing. More specific, there are date fields in the XML
>> documents that I'm parsing with Digester.
>> ...
>> <startDate>2003-28-04</startDate>
>> ...
>> What I tried to do is to
>> digester.setSchema(...);
>> digester.setValidating(true);
>>
>> However, even if I put an invalid date in the <startDate/>, Digester is
>> still happy about it. I would actually want an exception to be thrown.
>> The setSchema(String) call doesn't seem to have any effect. Am I doing
>> something wrong?
>>
>> Another point with the dates. It would be excellent if Digester could
>> recognize elements with type="xs:date" and accept a CallMethodRule,
>> such as
>> digester.addCallMethod(
>> "root/startDate",
>> "setStartDate",
>> 0,
>> new Class[] { Date.class });
>> Currently, this throws an ugly exception during the parsing because
>> Digester doesn't realize that 2003-28-04 is a date...
>>
>> Any help will be mostly appreciated.
>>
>> KarolR
>>
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
|