W3C home > Mailing lists > Public > w3c-rdfcore-wg@w3.org > July 2003

take 2: primer text for parseType="Literal"

From: Brian McBride <bwm@hplb.hpl.hp.com>
Date: 24 Jul 2003 14:31:59 +0100
To: rdf core <w3c-rdfcore-wg@w3.org>, Martin Duerst <duerst@w3.org>, i18n <w3c-i18n-ig@w3.org>
Message-Id: <1059053518.2327.78.camel@dhcp-91-136.hpl.hp.com>

4.5 parseType="Literal"

The RDF/XML syntax is designed to make it easy for the values of
properties to be fragments of XML.  Whilst this feature may be used with
arbritary fragments of XML, it was designed specifically
to enable the values of properties to be rich text represented as
XML markup.

For example, A publisher might maintain RDF meta data that includes the
titles of books and articles.  Whilst such titles are often just simple
strings of characters, this is not always the case.  The titles of books
on mathematics may contain mathematical formulae, that could be
represented using MathML [@@REF].  Titles may include markup, for
example for bidirectional rendering, for Ruby annotations or special
glyph variants.

For example  [@@complete namespaces etc]:

  <rdf:Description>
    <dc:title rdf:parseType="Literal">  <!-- @@spelling? -->
      <span xml:lang="en">
        The <em>&lt;br /&gt;</em> Element Considered Harmful.
      </span>
    </dc:title>
  </rdf:Description>

describes a graph containing one triple:

  _:a <dc:title> " \
      <span xml:lang="en" xmlns:dc="@@"> \ 
        The <em>&lt;br /&gt;</em> Element Considered Harmful. \
      </span>"^^rdf:XMLLiteral .  # @@ needs checking

The rdf:parseType="Literal" attribute in the RDF/XML indicates that all
the XML within the <dc:title> element is an XML fragment that is the
value of the dc:title property.

The value of the property is a typed literal, whose datatype,
rdf:XMLLiteral, is defined by RDF, specifically to represent fragments
of XML.  The XML fragment is canonicalized according to the XML
Exclusive Canonicalization recommendation [@@ref].  This causes
declarations of used namespaces to be added to the fragment, the
escaping of reserved characters such as '<', '>' and '&', and possibly,
the re-ordering of attributes.  Contextual attributes, such as xml:lang
and xml:base are not inherited from the RDF/XML document, and, if
required, must, as shown in the example, be explicitly specified in the
XML fragment.

This example illustrates that care must be taken designing RDF data.  It
might appear at first, that titles are simple strings best represented
as plain literals, and only later might it be discovered that some
titles contain markup.  In cases where the value of a property may
sometimes contain markup and sometimes not, then either
rdf:parseType="Literal" should be used throughout, or software must
handle both plain literals and rdf:XMLLiteral's.
Received on Thursday, 24 July 2003 09:33:46 EDT

This archive was generated by hypermail pre-2.1.9 : Wednesday, 3 September 2003 09:58:48 EDT