Suggestions on RDF Authoring (Pragmatic Approach)

In this article several aspects of RDF writing are discussed to make these data more useful for different purposes. This is deemed necessary, since many authors produce RDF that is wrong syntactically, improperly using certain namespaces, or RDF that generates facts that the authors most probably did not mean.

Levels of (in)correct RDF

Well formed XML

Accordingly to the RDF-MS specification, RDF should be written accordingly to XML syntax. This means, e.g. adding the first line, e.g.:

<?xml version="1.0" encoding="ISO-8859-1"?>

If you think this is redundant, consider the encoding declaration. Even a single non-ASCII character, e.g. "ü" can make your RDF incomprehensible to the XML parser tool that will analyze your RDF. The approach of the RDF Crawler for files with missing first line, is to assume that it is unicode, e.g. UTF-8. If it contains octets in the range 128-255 from some other encoding, most likely this will result in an error.

Be careful about all entities being defined in XML context (regardless of their meaning in HTML). For example, "&uuml;", if not properly defined as an XML entity will cause a syntax error.

You probably know everything about putting quotation marks around attributes, properly opening and closing XML tags, escaping special characters "<", ">", etc. and similar issues. If this causes problems, refer to the XML specification, see http://www.w3.org/TR/2000/REC-xml-20001006

Behavior of RDF Crawler: Every piece of "RDF like stuff", which is not well formed XML, will cause it either to be lost (if we cannot distinguish it from the rest of the document), or will result in an SAXParser exception. Crawler recognizes RDF either by getting MIME type "text/rdf" for the document, or when seeing two tags: <rdf:RDF> and </rdf:RDF>. Here "rdf" is any namespace prefix (also an empty one) for the namespace
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
Such namespace declaration should be located either above these tags (in case of MIME type "text/xml"), or within the opening tag <rdf:RDF> itself (e.g. for "text/rdf" and "text/html" and many more document types).

RDF-specific Syntax

List of bad RDF samples

Abuse of Namespaces other than RDF or RDFS

RDF Samples

RDF Parsing

Recommendations for RDF Authoring

As the XML standard was introduced in , it could seem that most questions for authoring various markup documents are already solved. Experiences of writing RDF convinced me that there are still many issues which have to be resolved.

Embedded RDF vs. Standalone RDF

Comments, exposed text, IDs

DTD Grammar of RDF

Normalization of literals

Other Issues of XML Syntax

First line; encodings; multiple languages

Collections

Property values as resources from namespaces

RDF API GENIDs

Separate Entities and their Names

Example

`You are sad,' the Knight said in an anxious tone: `let me sing you a song to comfort you.'

`Is it very long?' Alice asked, for she had heard a good deal of poetry that day.

`It's long,' said the Knight, `but very, very beautiful. Everybody that hears me sing it -- either it brings the tears into their eyes, or else -- '

`Or else what?' said Alice, for the Knight had made a sudden pause.

`Or else it doesn't, you know. The name of the song is called "Haddocks' Eyes."'

`Oh, that's the name of the song, is it?' Alice said, trying to feel interested.

`No, you don't understand,' the Knight said, looking a little vexed. `That's what the name is called. The name really is "The Aged Aged Man."'

`Then I ought to have said "That's what the song is called"?' Alice corrected herself.

`No, you oughtn't: that's quite another thing! The song is called "Ways and Means": but that's only what it's called, you know!'

`Well, what is the song, then?' said Alice, who was by this time completely bewildered.

`I was coming to that,' the Knight said. `The song really is "A-sitting On A Gate": and the tune's my own invention.'

Appendix: RDF Schemas

Here is a list of RDF links which are typically used in namespaces of other RDF files; mostly these are ontologies and meta-ontologies as well as RDF and RDFS specifications themselves. Some of these RDF cannot be parsed by RDF API. In the table below we have collected links to all these schemas in three columns:

Original schema Local copy Corrected local copy
http://www.w3.org/1999/02/22-rdf-syntax-ns http://aifbceto:8100/schemas/rdf-syntax-ns.rdf same
http://www.w3.org/2000/01/rdf-schema http://aifbceto:8100/schemas/rdf-schema.txt http://aifbceto:8100/schemas/rdf-schema.rdf
http://www.daml.org/2000/10/daml-ont http://aifbceto:8100/schemas/daml-ont.txt http://aifbceto:8100/schemas/daml-ont.rdf
http://purl.org/dc/elements/1.1/ http://aifbceto:8100/schemas/rec-dces-19990702.htm http://aifbceto:8100/schemas/dc-elements-1.1.rdf
http://www.semanticweb.org/ontologies/swrc-onto-2000-09-10.daml http://aifbceto:8100/schemas/swrc-onto-2000-09-10.daml same
This mapping in RDF format: map.rdf