This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29587 - [XP31] Numeric literals with leading or trailing decimal point
Summary: [XP31] Numeric literals with leading or trailing decimal point
Status: RESOLVED INVALID
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XPath 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-23 07:28 UTC by Michael Kay
Modified: 2016-04-23 07:42 UTC (History)
0 users

See Also:


Attachments

Description Michael Kay 2016-04-23 07:28:45 UTC
The XPath/XQuery grammar allows numeric literals to have a leading or trailing decimal point, for example

2. + .5

is a valid query that returns 2.5

XPath/XQuery defines the semantics of a numeric literal by reference to the rules for casting from string to number.

The rules for casting from string to number are defined in terms of the XSD-defined mapping from lexical space to value space.

But in XSD, the lexical space for xs:decimal, xs:double, and xs:float does not allow a leading or trailing decimal point.

For example, XPath defines decimal-literal with the pattern

("." [0-9]+) | ([0-9]+ "." [0-9]*)

while XSD 1.1 defines the lexical space of xs:decimal as

(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)
Comment 1 Michael Kay 2016-04-23 07:42:44 UTC
Bug withdrawn. I drew the wrong conclusions from an error I was seeing. JSON does not allow a leading or trailing "." in a number, but XSD does. The xml-to-json() function therefore should accept <j:number>.1</j:number> and must convert it to the JSON output "0.1".