W3C home > Mailing lists > Public > w3c-rdfcore-wg@w3.org > December 2001

PL: how a perl programmer might do datatypes in RDF

From: Dan Connolly <connolly@w3.org>
Date: Mon, 03 Dec 2001 17:51:40 -0600
Message-ID: <3C0C100C.245969A7@w3.org>
To: w3c-rdfcore-wg@w3.org
In question-and-answer format:

Q: how do I write integers and dates in RDF?

A: the obvious way:



Q: er... when I write <age>10</age>, is 10 a string or a number?

A: yes. ;-)

learn to think like a perl programmer:

@prefix ed: <http://www.w3.org/2000/08/eb58#>.
@prefix dc: <http://purl.org/dc/elements/1.1/>.
Scalars aren't necessarily one thing or another. There's no place to
     declare a scalar variable to be of type "string", type "number",
     "reference", or anything else. Because of the automatic conversion
     scalars, operations that return scalars don't need to care (and in
     cannot care) whether their caller is looking for a string, a
number, or a

is ed:excerpt of [
  = <http://www.perldoc.com/perl5.6/pod/perldata.html>;
  dc:title "perldata";
  dc:date "Sun, 09 Sep 2001 13:06:57 GMT" ].

Q: but I thought strings and integers were disjoint; that's
what the XML Schema spec says.

A: hmm... so it does:
  "Note that a consequence of the above is that, given ·value space·  A
         and ·value space·  B where A and B are not related by
·restriction· or
         ·union·, for every pair of values a from A and b from B, a !=

	-- http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#equal

well, (a) I don't see how that follows "as a consequence of the above";
(b) I don't see why the spec makes this constraint; it doesn't seem
to exploit it. (c) if they really mean that the value spaces
of the datatype string and integer don't intersect, then our
literal-value/scalar space is a different space. I don't expect
they'll mind, as long as we're clear on the difference. We do owe
them a chance to review this departure from their design, I suppose.

Q: how do I declare that my property takes integer or date values?

A: the obvious way, using rdfs:range and the URIs provided
in the XML Schema datatypes spec:

	my:age rdfs:range <http://www.w3.org/2001/XMLSchema#int>.
	dc:date rdfs:range dt:date.


Q: what's the class-extension of .../XMLSchema#int? numbers or numerals?
i.e. is it the lexical space or the value space?

A: You can look at them as numerals if you like. 010 and 10
are distinguishable, after all; you can string-compare them.
It's definitely the lexical space that shows up in RDF/xml documents;
but we already knew that. Formally,
I'd say literal values. To a perl programmer, I'd say: scalars.

Q: how can I tell if the value of a property is a string or an integer?
	How can I query for real integers, not just

A: you can't. Do you really need to?
A lot of perl programmers get a lot of stuff done without doing so.

Q: how does this impact the model theory of 25 Sep?

A: it doesn't, really; all we need to specify is that Unicode
character sequences (as expressed with RDF propertyElement content
and N-triples terms) map 1-1 to literal values (aka scalars).

Q: what about the other pros and cons from the mental
Does it require literals as subjects?

A: I'm not certain. It does seem to suggest that
	"10" rdf:type dt:integer.
if that's what you mean.

Q: requires DTs to be 'proper'?

A: no. almost on the contrary; it's pretty promiscuous ;-)

Q: requires user conform to idiom?

A: no; that is: no idiom other than the obvious one that
	folks have already chosen.

Q: requires literals to be typed?

A: no; on the contrary; pretty much lumps all literal types together

Q: cannot express 'clashing' types

A: ??? not sure what this means.

Q: fully general?

A: except for an inability to distinguish "10" from 10, yes, seems to

Q: conforms to current usage?

A: yes.

Q: allows free type merging?

A: dunno what this means.

Q: compatible with DAML

A: hmm... I suppose so.

Q: Does each RDF document ential itself? in particular,
simple ones like this one?
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  <rdf:Description rdf:about="http://www.w3.org/">
    <dc:title>World Wide Web Consortium</dc:title> 

A: yes; of course.

Q: how would you write the bus/bell example from Sergey's draft?

	:bus_1 :isEmpty "true".
	:bell_2 :isRinging "1".

in full glory:

<rdf:RDF xmlns="http://www-db.stanford.edu/~melnik/rdf/datatyping/#"



Q: how about the Jenny/Robbie example?

<rdf:RDF xmlns="http://www-db.stanford.edu/~melnik/rdf/datatyping/#"



I'm leaving out the octal bit. I suppose I could do it ala

	weightInKG [ coerce:fromOctal "14" ].

or some such, but I haven't bothered here.

Dan Connolly, W3C http://www.w3.org/People/Connolly/
Received on Monday, 3 December 2001 18:51:42 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:53:53 UTC