xs:assert and user-defined error messages
Added by Anonymous almost 16 years ago
Legacy ID: #5819117 Legacy Poster: Jesper Tverskov (jesper_tverskov)
Testing xs:assert in Saxon SA at the command line I couldn't help but notice how nice it would be if we could have user-defined error messages. Why not allow something like the following: <xs:assert test="some checksum validation of ISBN number"> <xs:annotation> <xs:appinfo> <saxon:error>Your number is not a valid ISBN number</saxon:error> </xs:appinfo> </xs:annotation> </xs:assert> It would be even better if something similar could get into the spec, let us say: <xs:appinfo> <xs:error>Your number is not a valid ISBN number.</xs:error> </xs:appinfo> Bu why not implement such an option in Saxon to show the way? Cheers, Jesper Tverskov
Replies (1)
RE: xs:assert and user-defined error messages - Added by Anonymous almost 16 years ago
Legacy ID: #5819277 Legacy Poster: Michael Kay (mhkay)
There is in fact some push behind getting something like this into the spec, and I was waiting to see what came of it before doing my own thing. To be honest, I would like to do more than a simple fixed error message. I would like to see something like <xs:assert test="some checksum validation of ISBN number"> <xs:annotation> <xs:appinfo> <saxon:error>Book {./title} has an invalid ISBN number {./@isbn}</saxon:error> </xs:appinfo> </xs:annotation> </xs:assert> Also, I don't think that assertions, just because of their Schematron heritage, should necessarily get special treatment here - I think the same facilities are needed for other error conditions, such as not satisfying a pattern or an enumeration.
Please register to reply