XSD data types

When you run a query through Registry Services, you can use the XML schema definition data types to define values with implicit and explicit declaration.

Purpose

Registry Services data types are based on XML Schema Part 2: Datatypes Second Edition. The page contains all data types format specification.

Registry Services tries to infer the real type from the Resource Shape in case of implicit type declaration, and it uses OSLC typed value qualifiers in case of explicit type declaration.

In case of implicit type declaration, if the property is included in the Resource Shape, Registry Services considers the same data type from the Resource Shape. Otherwise, Registry Services considers this data type as String.

In case of explicit data type declaration, if the type is valid according to OSLC specification, Registry Services considers the property type as the user specified. Otherwise, it returns an error that states that the property is not valid.

On data output, for example, the Registration Record retrieval, Registry Services always use the canonical representation of any data type.

On data input, for example, the Registration Record creation, Registry Services accepts various data types specification. It also infers the type when none is provided.

Parameters

xsd:anyURI
The URI data type is represented by default as any well-formed URI text surrounded with angle brackets.
This example represents a query search for an xsd:anyURI relationship value, with an explicit type declaration:
oslc.where=crtv:relationship="http://localhost:8080/oslc/devices/12312"^^xsd:anyUri
This example represents the default query search for an xsd:anyURI relationship value:
oslc.where=crtv:relationship=<http://localhost:8080/oslc/devices/12312>
Both xsd:anyUri and oslc:Resource represent URL data type and can be used interchangeably in data type specifications.
For example, the http://test/1 can be also represented as http://test/1"^^xsd:anyUri or http://test/1"^^oslc:Resource. Registry Services accepts any of those values in oslc.where queries.
xsd:string
The string data type is represented by default as any text surrounded by double quotation marks. Because there are other data types represented the same way, the Registry Services infers the data type value that is based on the Resource Shape definitions.
If the property is not defined in a Resource Shape definition, the type defaults to xsd:string.
This example represents a valid query with the xsd:string parameter value:
oslc.where=crtv:manufacturer="IBM"^^xsd:string
xsd:dateTime
The datetime data type contains the timezone specification. Although the Registry Services accepts different timezone specifications for xsd:dateTime data type, it stores the xsd:dateTime values in a normalized timezone format of 0/GMT/Zulu. With this storage, any records that are returned by a query operation, for example, have normalized values.
The Registry Services supports only dates from 1 AD.
You can specify the timezone value as Z (UTC) or (+|-)hh:mm. If you do not specify the timezone, Registry Services considers it as undetermined.
See XML Schema Part 2: Datatypes Second Edition.
This example represents a valid query with the xsd:dateTime parameter value:
oslc:where=dcterms:modified>"2012-03-07T08:00:01Z" and dcterms:modified<="2012-03-07T11:59:59Z"
xsd:boolean
The xsd:boolean data type accepts two values, true and false, but depending on whether it is on input or output data, these values representations can change.
On input (on queries), boolean values can be:
  • String literals without quotation marks. For example, oslc.where=crtv:boolValue=true
  • Quoted strings. For example, oslc.where=crtv:boolValue="false"
  • Quoted numeric values. For example, oslc.where=crtv:boolValue="1"
On output, boolean values are always returned as canonical values. String literals without quotation marks, for example, true or false.
These examples represent acceptable queries with the xsd:boolean parameter values:
oslc.where=ssc:booleanAttribute="true"^^xsd:boolean
oslc.where=ssc:booleanAttribute=true
oslc.where=ssc:booleanAttribute="false"
oslc.where=ssc:booleanAttribute="1"
Note: Although they are different data types, xsd:integer, xsd:float, xsd:double, and xsd:decimal all represent numeric values and can be referred as numeric data types. All numeric values are convertible among each other only in queries.

For example, in a query for the 2.0 value, which is an xsd:decimal value, Registry Services queries for all the data types whose value is 2.0. In this query, Registry Services considers integer, float, double or decimal data type.

In queries for quoted string values with a data type that is not explicitly specified, Registry Services infers the type according to the Resource Shape.

xsd:integer
The integer data type accepts any decimal literal value, in which the decimal point is omitted from the lexical representation.
These examples represent acceptable queries with xsd:integer values:
oslc.where=ssc:integerAttribute="1234"^^xsd:integer
oslc.where=ssc:integerAttribute="1234"
oslc.where=ssc:integerAttribute=1234
xsd:float
The float data type accepts a mantissa value optionally followed by an exponent value that is separated by e or E characters, where mantissa is any valid decimal number and exponent is a valid unsigned integer number.
This data type also supports these special values: not-a-number that represented as NaN, and positive and negative infinity that is represented as INF and -INF.
The Registry Services application always uses a canonical representation when an xsd:float data type value is used in this application output.
This canonical representation is either a valid finite number with a mantissa and an exponent or it is a not-a-number, a positive infinity, or a negative infinity number.
In canonical representation, a mantissa is a decimal number that always omits the plus sign for non negative values. It also contains a single non-zero digit to the left of the decimal point and at least a single decimal digit to the right of the decimal point, unless the whole value is zero.
If this data type value is zero, its canonical representation is 0.0E0.
An exponent is an unsigned integer value without leading zeros.
Although the plus sign is omitted, the Registry Services application accepts values such as +1E+3.
The valid values for xsd:float are
  • From -3.4028234663852886e+38 to -1.1754943508222875e-38
  • 0
  • From 1.1754943508222875e-38 to 3.4028234663852886e+38
These examples represent acceptable queries with xsd:float values:
oslc.where=crtv:someproperty="1234"^^xsd:float
oslc.where=crtv:someproperty="1234"
oslc.where=crtv:someproperty="12.345E-1234"^^xsd:float
oslc.where=crtv:someproperty="12.345"^^xsd:float
This table provides the values that are returned when you use the comparison operators from the first column in a query with the argument values from the first line:
Table 1. Behavior of special values and comparison operators
  INF -INF NaN number
< -INF, number empty HTTP 400 (Bad Request) -INF, number
> empty INF, number HTTP 400 (Bad Request) INF, number
<= INF, number, -INF -INF NaN -INF, number
>= INF -INF, number, INF NaN INF, number
The < and > operators return the HTTP 400 (Bad Request) status code for the NaN argument. However, you can use the equal operator with NaN, which makes it possible for you to use the <= and >= operators with NaN.
In a query for a quoted string value with a data type that is not explicitly specified, Registry Services infers the type according to the Resource Shape.
xsd:double
The double data type accepts the same values as the float data type. The only difference is the increased value range and precision.
The Registry Services application represents this data type as a 64-bit floating point.
The valid values for xsd:double are
  • From -1.7976931348623158e+308 to -2.2250738585072014e-308
  • 0
  • From 2.2250738585072014e-308 to 1.7976931348623158e+308
These examples represent acceptable queries with xsd:double values:
oslc.where=crtv:someproperty="1234"^^xsd:double
oslc.where=crtv:someproperty="1234"
oslc.where=crtv:someproperty="12.345E-1234"^^xsd:double
oslc.where=crtv:someproperty="12.345"^^xsd:double
For more information about special values and operators, see the Behavior of special values and comparison operators table and its description.
xsd:decimal
The decimal data type accepts any decimal value in which the decimal point indicator is a period. This data type supports a finite length sequence of decimal digits.
You can omit any zeros after the decimal point indicator. For example, you can specify the 2 value instead of 2.0.
These examples represent acceptable queries with xsd:decimal values:
oslc.where=crtv:someproperty="1234"^^xsd:decimal
oslc.where=crtv:someproperty"1234"
oslc.where=crtv:someproperty=2.5
oslc.where=crtv:someproperty="12.345"^^xsd:decimal
The Registry Services application always uses a canonical representation when an xsd:decimal data type value is used in this application output.
This canonical representation always has a decimal point, omits the plus sign for non-negative values, and does not contain leading and trailing zeros. For example, the -2 value is a canonical representation of -2.0.
rdf:XMLLiteral
The literal data type can have the same representation as the string data type. You can also compare any string data type property with an XML Literal property.
The Registry Services does not validate the rdf:XMLLiteral data type values during a query request.
These examples represent acceptable queries with rdf:XMLLiteral values:
oslc.where=dcterms:title="<b>title</b>"
oslc.where=dcterms:title="<b>title</b>"^^xsd:string
oslc.where=dcterms:title="1 < 2"^^rdf:XMLLiteral
oslc.where=oslc:shortTitle="<b>title</b>"^^rdf:XMLLiteral
However, the Registry Services application validates the Registration Records property types against the Resource Shape. One of the valid data types for properties is the rdf:XMLLiteral.
You can register an XML literal-typed property by using the rdf:parseType="Literal" attribute or by escaping all special characters, as you can see in these examples:
<dcterms:title rdf:parseType="Literal"><div><b>TITLE</b></div></dcterms:title>
<dcterms:title><div&gt;TITLE</div&gt;</dcterms:title>
For example, if you register this property: <oslc:shortTitle >This is a <b&gt;title</b&gt; </oslc:shortTitle>, the Registry Services returns: <oslc:shortTitle rdf:parseType="Literal">This is a <b>title</b> </oslc:shortTitle>.
Registry Services validates that values supplied in HTTP POST and PUT requests conform to the supported value types.
Other valid data types the Registry Services supports for properties validation are xsd:string, xsd:boolean, xsd:integer, and xsd:dateTime.