Project

Profile

Help

ValidationException

Added by Anonymous about 14 years ago

Legacy ID: #8067944 Legacy Poster: Ross B. (rossbrower)

I am receiving a validation exception due to a double being serialized in the form "2,3456" (thanks Germany), which seems to be causing an xpath to fail on that value, likely because it is doing a numeric comparison ">". I understand why this would be the case and I'm fine with the exception. My problem is that this exception is not within the namespace of the saxon library or in the base .net libraries. I found some documentation here: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validationexception.aspx Am I to assume that this is the exception that is being thrown? Using latest he version for .net.


Replies (5)

Please register to reply

RE: ValidationException - Added by Anonymous about 14 years ago

Legacy ID: #8067961 Legacy Poster: Michael Kay (mhkay)

This will be an instance of net.sf.saxon.type.ValidationException, which is a Java class mapped to a .NET type using the IKVMC compiler. Ideally when you use the Saxon.Api interfaces under .NET, all exceptions from the underlying code should be mapped to something like Saxon.Api.StaticError or Saxon.Api.DynamicError; however, I'm sure there are many cases where this is not happening (it's difficult to do it systematically because of the lack of strong exception handling in C#). If there are specific cases, however, then please show the code you are running and the results that you get, and I will try to improve it.

RE: ValidationException - Added by Anonymous about 14 years ago

Legacy ID: #8068031 Legacy Poster: Ross B. (rossbrower)

Ok fair enough. Here is an odd example: Xml: XPath: property[@name='PercentProcessorTime' and @value>90] Result: Error during processing: net.sf.saxon.trans.XPathException: Required item type of first operand of '>' is numeric. Cannot convert string "99,294351" to a double Xml: same Xpath: //property[@name='PercentProcessorTime' and @value>90] Result: Error during processing: ValidationException: Cannot convert string "99,294351" to a double

RE: ValidationException - Added by Anonymous about 14 years ago

Legacy ID: #8068045 Legacy Poster: Ross B. (rossbrower)

I could use reflection to inspect the type name of the exception but since it looks like there is not a specific exception to catch, I will catch all and just log it. Thanks. For anyone else encountering this issue with incorrect serialization in .net of numeric values you can use the following Convert.ToString(value, NumberFormatInfo.InvariantInfo). This will take any unusual number formatting and convert it to a standard format that should be compatible with xml types.

RE: ValidationException - Added by Anonymous about 14 years ago

Legacy ID: #8072117 Legacy Poster: Michael Kay (mhkay)

I assume you are using the XPath API (Saxon.Api.XPathSelector), though you haven't actually said. I've now added some error catching to the methods in this class so that they throw a Saxon.Api.DynamicError instead of the underlying Java exception; the error handling is also better documented.

RE: ValidationException - Added by Anonymous about 14 years ago

Legacy ID: #8076520 Legacy Poster: Ross B. (rossbrower)

Yes I was using XPathSelector as part of an editor I wrote for developing xpath/xquery/xsd/xslt. Thanks for the quick responses!

    (1-5/5)

    Please register to reply