Datatypes: J

somewhat delayed. I found it difficult to write, which probably means it
will be difficult to read. Which probably in turn means that it isn't much
good. Well such is life.

=====


I think I've beaten Jos & Jan to claiming the J node.

J for junk or J for jewel. Or maybe J for joke.


Overview
--------

J is inspired by Peter Patel-Schneider's observation that XML Schema
(parts 0, 1 & 2) does datatyping, and that RDF datatyping should be
compatible with it.

Example use case is:
  Currently when designing an XML schema/DTD/whatever it is possible
to do that with RDF in mind. This results in documents that while
conforming to the schema, and XML idiom, also conform to the RDF M&S
specs.
  For datatyping, this suggests that an XML document, that has an
XML schema (for all or part of it), has already declared the datatypes.
If the document also conforms with RDF syntax, then we should apply
the datatyping from the XML schema.

At the level of the abstract RDF syntax, the graph; this means that
unlike other proposals the graph is labelled with labels from the value
space rather than labels from the lexical space. In fact, the lexical
space is only found in documents, and not in the abstract data model.

XML schema instance attributes are treated specially and RDF processors
are required to recognise them.


Examples
--------

1: Explicit use of xsi:type for simple value
............................................

  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:eg="http://example.org/">
    <rdf:Description>
      <eg:shoeSize xsi:type="xsd:integer">10</eg:shoeSize>
    </rdf:Description>
  </rdf:RDF>


Graph
.....

  _:a -------->--------  (10)


Note: the node on the right is labelled with the integer 10, not the
string "10".
Hence using a different but compatible XML Schema type that maps the
string "10" to the same value, e.g. xsd:positiveInteger, results in
an identical graph.

N-Triples**
...........

 _:a <http://example.org/shoeSize> {xsd:decimal,"10.0"} .

In the modified N-Triples we need to give a type that converts the lexical
form in the file into the value in the graph. Since N-Triple is canonical
we use the primitive type from which the derived type inherits, and we
use the canonical form of the lexicalization.


2: Implicit/Explicit use of XML Schema for whole document
.........................................................

Haven't got this to work.


3: Explicit use of xsi:type for complex value
.............................................
e.g. complex numbers

We have a schema like

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.example.org/complexNumber"
        elementFormDefault="qualified"
        >

 <xsd:complexType name="ComplexNumber">
  <xsd:sequence>
   <xsd:element name="real"   type="xsd:decimal"/>
   <xsd:element name="imaginary" type="xsd:decimal"/>
  </xsd:sequence>
 </xsd:complexType>

</xsd:schema>

then we could have


  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:cplx="http://www.example.org/complexNumber#"
         xmlns:eg="http://example.org/">
    <rdf:Description>
      <eg:shoeSize >
          <rdf:Description xsi:type="cplx:complexNumber">
             <cplx:real>10</cplx:real>
             <cplx:imaginary>3</cplx:imaginary>
          </rdf:Description>
      </eg:shoeSize>
    </rdf:Description>
  </rdf:RDF>


This has corresponding graph


      showSize     real
  _:a --->---- [] --->----- (10)
                |
                | imaginary
                ----->----- (3)

where the labels on the right are real numbers not strings.



3: Implicit use of XML schema for complex value
...............................................

Lets suppose that exmaple.org defines both an RDF and an XML schema for
shoesize.

So the file retrieved from http://example.org/ is as follows
[[[[[

<!-- arbitrary container for both XML and RDF schema -->

<foo xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

<!-- XML Schema part -->
<xsd:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://example.org/"
        elementFormDefault="qualified"
        attributeFormDefault="qualified"
        xmlns:cplx="http://www.example.org/complexNumber#"
        >

 <xs:complexType name="shoeSize">
  <xs:complexContent>
   <xs:extension base="cpx:complexNumber">
<!-- This is trying to say that:
         a shoeSize has the XML form of a complex number
         except that it has an additional attribute
          rdf:parseType that must be present with value "Resource"
-->
    <xs:attribute ref="rdf:parseType" fixed="Resource" use="required"/>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>


</xsd:schema>

<rdf:RDF xmlns:rdfs="usual uri">
   <rdfs:Property rdf:ID="shoeSize" />
   <!-- We could have a range constraint to say that
        shoeSize's are complex numbers,
        but I am not sure how.
   -->
</rdf:RDF>
</foo>


]]]]]]]]

Given these schemata then:
[[[[
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:eg="http://example.org/#">
    <rdf:Description>
      <eg:shoeSize rdf:parseType="Resource">
             <cplx:real>10</cplx:real>
             <cplx:imaginary>3</cplx:imaginary>
      </eg:shoeSize>
    </rdf:Description>
  </rdf:RDF>
]]]]

corresponds to the same graph as before.
It XML Schema validates because the XML representation of eg:shoeSize
matches,
and eg:shoeSize is also linked in with the rdfs schema.

There is a bit of an issue with the trailing "#"-es.

I am not sure I find this convincing ....


Jeremy

Received on Friday, 7 December 2001 07:55:11 UTC