mulgara - semantic store

skip navigation

SHOW SITE NAV
fixed
fluid
straight

Datatyping Models

Datatyping models represent the property of orderedness that literals like dates and numbers possess. They are used to constrain results to be above, below, or between specified dates or numbers.

Datatyping models are generally read-only. You do not insert statements into them as you do with standard or full-text models. Conceptually, they contain every true statement about their datatype, such as 1 is less than 2 and Christmas Day is after Christmas Eve.

 

Creating Datatyping Models

Use the create command with an optional type argument of <http://mulgara.org/mulgara#XMLSchemaModel> in addition to the model name.

For example, to create the datatyping model #xsd:

create <rmi://mysite.com/server1#xsd> <http://mulgara.org/mulgara#XMLSchemaModel>;

Note - Generally, there is no need to create more than one datatyping model per Mulgara server.

 

Loading Datatyping Models

As well as having a value, typed literals (such as the number 7.5, as opposed to the untyped text "7.5") also have a datatype, which is identified by a URI.

The primitive datatypes supported by Mulgara are listed in the following table.

Datatype

Description

string

Character strings. For example, John

boolean

The mathematical concept of binary-valued logic. For example, true or false

decimal

Arbitrary precision decimal numbers. For example, 1.23

float

Single precision floating point numbers. For example, 1.23E4

double

Double precision floating point numbers. For example, 1.23E4

dateTime

A point in time specified to one second accuracy. For example, 2004-12-24T23:59:59 (one second to Christmas Day 2004, UTC)

date

A point in time specified to one day accuracy. For example, 2004-12-24 (Christmas Eve 2004)

gYearMonth

A specific gregorian month in a specific gregorian year. For example, 2004-12 (December 2004)

gYear

A gregorian calendar year. For example, 2004

gMonthDay

A day of the year. For example, 12-25 (Christmas Day)

gDay

A day of the month. For example, 25 (25th day of the month)

gMonth

A month of the year. For example, 12 (12th month of the year)

hexBinary

Arbitrary hex-encoded binary data

base64Binary

Arbitrary Base64-encoded binary data

The primitive datatypes currently not supported by Mulgara are listed the following table.

Datatype

Description

duration

A duration of time

anyURI

A Uniform Resource Identifier Reference (URI)

QName

Qualified XML names

NOTATION

The NOTATION attribute type

The derived datatypes currently supported by Mulgara are listed the following table.

Datatype

Description

integer

Derived from decimal with no fractional digits

nonPositiveInteger

Derived from integer with a maximum value of 0

negativeInteger

Derived from nonPositiveInteger with a maximum value of -1

long

Derived from integer with a maximum value of 9223372036854775807 and a minimum value of -9223372036854775807

int

Derived from long with a maximum value of 2147483647 and a minimum value of -2147483648

short

Derived from int with a maximum value of 32767 and a minimum value of -32767

byte

Derived from short with a maximum value of 127 and a minimum value of -128

nonNegativeInteger

Derived from integer with a minimum value of 0

unsignedLong

Derived from nonNegativeInteger with a maximum value of 18446744073709551615

unsignedInt

Derived from unsignedLong with a maximum value of 4294967295

unsignedShort

Derived from unsignedInt with a maximum value of 65535

unsignedByte

Derived from unsignedShort with a maximum value of 255

positiveInteger

Derived from nonNegativeInteger with a minimum value of 1

The derived datatypes currently not supported by Mulgara are listed the following table.

Datatype

Description

normalizedString

Derived from string without carriage return, line feed or tab characters

token

Derived from normalizedString without leading or trailing spaces and no internal sequences of two or more spaces

language

Derived from token and is the set of all valid language identifiers

NMTOKEN

Derived from token and represents the NMTOKEN attribute type

NMTOKENS

Derived from NMTOKEN and represents the NMTOKENS attribute type

Name

Derived from token and represents XML Names

NCName

Derived from Name and represents XML non-colonized Names

ID

Derived from NCName and represents the ID attribute type

IDREF

Derived from ID and represents the IDREF attribute type

IDREFS

Derived from IDREF and represents the IDREFS attribute type

ENTITY

Derived from NCName and represents the ENTITY attribute type

ENTITIES

Derived from ENTITY and represents the ENTITIES attribute type

Note - The URI prefix for all of the datatypes listed above is http://www.w3.org/2001/XMLSchema#. For example http://www.w3.org/2001/XMLSchema#string. More information about these datatypes is in the W3C document XML Schema Part 2: Datatypes.

The syntax to express a typed literal is to separate a literal value and its type with a double-caret (^^).

For example, consider the statement that a text file was created on Christmas Eve 2004. This could be inserted into a model as follows:

insert <file:/nice.txt> <dc:date> '2004-12-24'^^<http://www.w3.org/2001/XMLSchema#date>
into <rmi://mysite.com/server1#model>;

Remember that the command alias <http://www.w3.org/2001/XMLSchema#> as xsd; allows you to write the insert command as follows:

insert <file:/nice.txt> <dc:date> '2004-12-24'^^<xsd:date>
into <rmi://mysite.com/server1#model>;

Alternatively, the following could be loaded from an RDF/XML file:

<rdf:RDF xmlns:dc = "http://purl.org/dc/elements/1.1/"
xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema#">
<rdf:Description rdf:about="file:/nice.txt">
<dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date"> 2004-12-24 </dc:date>
</rdf:Description>
</rdf:RDF>

Note - Datatyped statements are loaded into normal models, not datatyping models. Datatyping models cannot be written to, as this would be like trying to redefine the fixed nature of numbers or dates.

 

Querying Datatyping Models

Querying datatyping models is much the same as for normal Mulgara models. Datatyping models contain all statements with the following properties that happen to be true for the relevant datatype:

Note - The datatypes listed above assume a prior alias <http://www.w3.org/2001/XMLSchema#> as xsd; command was performed.

See the Loading Datatyping Models section for more information on the datatypes supported by Mulgara.

To use a datatyping model in a query, compose a constraint with one of the above properties and direct it at the XML Schema model with the in clause. For example, the following query lists all resources from the 19th century:

select $doc from <rmi://mysite.com/server1#model>
where $doc <dc:date> $date
and $date <mulgara:before> '2000-01-01' in <rmi://mysite.com/server1#xsd>
and $date <mulgara:after> '1899-12-31' in <rmi://mysite.com/server1#xsd>;

 

Limitations of Datatyping Models

Datatyping models have the following limitations:

Valid XHTML 1.0 TransitionalValid CSS 3.0!