RDF Datatyping Examples -- inline datatype elements

Here are some encoding examples based on the latest datatyping WD

http://www-nrc.nokia.com/sw/rdf-datatyping.html

as well as the proposed NTriples syntax for typed literals in

http://lists.w3.org/Archives/Public/w3c-rdfcore-wg/2002Aug/0184.html

and using inline datatype elements as outlined in 

http://lists.w3.org/Archives/Public/w3c-rdfcore-wg/2002Aug/0182.html

(I use qnames rather than URIrefs in the NTriples for now...)

The advantage to the inlined datatype elements is that one can use
an XML Schema validator to validate datatyped literals, both locally
and globally typed, without modification of the RDF/XML.

--

RDF/XML:

   <rdf:Description rdf:about="#Jenny">
      <ex:age>10</ex:age>
   </rdf:Description>

NTriples:

   Jenny ex:age "10" .

--

RDF/XML:

   <rdf:Description rdf:about="#Jenny" xml:lang="en">
      <ex:age>10</ex:age>
   </rdf:Description>

NTriples:

   Jenny ex:age "10"-en .

--

RDF/XML:

   <rdf:Description rdf:about="#Jenny">
      <ex:age><xsd:integer>10</xsd:integer></ex:age>
   </rdf:Description>

NTriples:

   Jenny ex:age xsd:integer,"10" .

--

RDF/XML:

   <rdf:Description rdf:about="#Jenny" xml:lang="en">
      <ex:age><xsd:integer>10</xsd:integer></ex:age>
   </rdf:Description>

NTriples:

   Jenny ex:age xsd:integer,"10"-en .

--

RDF/XML:

   <rdf:Description rdf:about="#Book">
      <ex:title>10</ex:title>
   </rdf:Description>

NTriples:

   Book ex:title "10" .

--

RDF/XML:

   <rdf:Description rdf:about="#Book" xml:lang="en">
      <ex:title>10</ex:title>
   </rdf:Description>

NTriples:

   Book ex:title "10"-en .

--

RDF/XML:

   <rdf:Description rdf:about="#Book">
      <ex:title><xsd:string>10</xsd:string></ex:title>
   </rdf:Description>

NTriples:

   Book ex:title xsd:string,"10" .

--

RDF/XML:

   <rdf:Description rdf:about="#Book" xml:lang="en">
      <ex:title><xsd:string>10</xsd:string></ex:title>
   </rdf:Description>

NTriples:

   Book ex:title xsd:string,"10"-en .

--

[NOTE: Here's where inline datatype elements get problematic. Ideally,
datatyping should work consistently for any literal, non-XML or XML,
as per the rdf:type attribute syntax. But with XML literals, having
a datatype wrapper is not an option. The approach I've taken here is
to treat every XML literal which has a root element as being a typed
literal. I.e., one explicitly and locally types every XML literal
which has a root element and is not simply mixed content. Having the
datatype made explicit in the node label exposes the datatype to
generic RDF engines that can work with datatyped literals, rather
than leaving the complex datatype hidden (to RDF) in the XML literal.]

RDF/XML:

   <rdf:Description rdf:about="#Book">
      <ex:title rdf:parseType="Literal"><xhtml:h1>10</xhtml:h1></ex:title>
   </rdf:Description>

NTriples:

   Book ex:title xhtml:h1,xml"<xhtml:h1>10</xhtml:h1>" .

--

RDF/XML:

   <rdf:Description rdf:about="#Book" xml:lang="en">
      <ex:title rdf:parseType="Literal"><xhtml:h1>10</xhtml:h1></ex:title>
   </rdf:Description>

NTriples:

   Book ex:title xhtml:h1,xml"<xhtml:h1>10</xhtml:h1>"-en .

--

[NOTE: Here, because the XML literal is mixed content with no root element,
it is not typed, nor is it possible (or logical) to assert a type locally
for it.]

RDF/XML:

   <rdf:Description rdf:about="#Book">
      <ex:title rdf:parseType="Literal">The <xhtml:b>Tao</xhtml:b> of Foo</ex:title>
   </rdf:Description>

NTriples:

   Book ex:title xml"The <xhtml:b>Tao</xhtml:b> of Foo" .

--
               
Patrick Stickler              Phone: +358 50 483 9453
Senior Research Scientist     Fax:   +358 7180 35409
Nokia Research Center         Email: patrick.stickler@nokia.com
 

Received on Thursday, 22 August 2002 15:02:55 UTC