Re: Datatype interface for RELAX NG

From
James Clark <>
Date
2001-05-31T08:43:50+00:00
ID
03ff01c0e9aa$bd5c7880$92d033c1@mango
Thread
Re: Datatype interface for RELAX NG
> > void check(String literal, ContextProvider context) throws
> > DataTypeException;
> >
> > This is like accept, except that it throws an exception for a literal
that
> > is not a member of the datatype.
>
> Do you mind if I change its signature to
>
> DataTypeException diagnose( String literal, ContextProvide context )
>                 [ throws UnsupportedOperationException ]
>
> I don't want to write try...catch close everytime I need a diagnosis
> message.
>
> ?

Why not?  Many users will want an exception to be thrown in this case.

>
> > I don't think DataType.displayName is necessary.
>
> I want this method for formatting error messages.

What exactly would it return?  What, for example, would it return for
xsd:string?  If it's "string", doesn't the application already know this?
If it's something else, don't you need a Locale parameter as well?

>
> > accept => allows/accepts or contains
>
> Just out of curiosity...   Why "allows" and not "allow"?  And why "check",
> not "checks"?

It reads better:

  if A contains B, then check C

contains is part of an assertion, check is a command.  Compare:

  String.startsWith

and

  String.trim

James