relaxng / jing-trang

Schema validation and conversion based on RELAX NG
http://www.thaiopensource.com/relaxng/
Other
227 stars 69 forks source link

More clear messages when validating integer values #268

Open raducoravu opened 2 years ago

raducoravu commented 2 years ago

Started based on a discussion on the Oxygen XML Users List which contains more details: https://www.oxygenxml.com/pipermail/oxygen-user/2022-September/006869.html

You have this XML:

<?xml-model href="n.rnc" type="application/relax-ng-compact-syntax"?>
<stuff>1.0</stuff>

and this RNC file:

start = stuff
stuff = element stuff { xsd:integer {minInclusive = "1" maxInclusive = "1"}
}

The validation message for this case states:

      character content of element "stuff" invalid; must be a decimal number without any significant digits after the decimal point

but there are no significant digits after the decimal point.

djbpitt commented 2 years ago

The issue with values like "1.0" and "1." is the decimal point, and not the digits after it. The error message for "1." says that an integer is required, but because the error message does not say anything about value space vs lexical space, a user might not understand that it is the lexical expression (specifically, the decimal point) that raises the error here.

In both cases a more helpful error message might be that xsd:integer values cannot include a decimal point.