difference between lexical space and value space

xml

Solution

Value space is the range of values for a given type, while lexical space is the range of representations.

So, the double type, for example, has a value space that contains all the values one can represent with a 64-bit IEEE 754 floating number; viz. a certain set of numbers, along with ∞, -∞ and not-a-number.

It has a lexical space that includes various ways of representing the numbers covered, along with `INF`, `-INF` and `NaN`.

So, the string `INF` corresponds with the value ∞.

The string `12.5` corresponds with the value 12.5.

The strings `12.000`, `12`, `1.2E1`, `12.0E0` and `12.0` all correspond with the value 12.

As such, the mapping between the lexical space and the value space can be many-to-one for some value types.

With the string type, and any types that are based on it by restriction, the mapping is one-to-one.

Note that the lexical space refers to the string produced after processing the XML, so with an XML document containing the text `12`, we would have processed the entities to produce the string `12` in the lexical space of double (and corresponding to 12). Or in other words, while `12` is also a means of representing 12 along with the other examples I gave about, this is at a lower level than XML schemata are processed; at that level we consider it as the string `12` as `12` is just another way to represent that string in XML documents.

Problem

While reading W3C's document on XML Schema, I came across two terms 'value space', and 'lexical space' which seem to be very identical. This thread suggests that the value space is an abstract definition while the lexical space refers to the specific contents of that data type. As an analogy, would it be fair to say that the value space may be a regular expression, whereas the lexical space may be any string of characters that match that regular expression ?

Original source