W3C home > Mailing lists > Public > semantic-web@w3.org > January 2010

Re: Turtle null prefix and namespaces

From: Peter Ansell <ansell.peter@gmail.com>
Date: Tue, 19 Jan 2010 06:49:31 +1000
Message-ID: <a1be7e0e1001181249t23397d9bh3259b3dbc66abfd2@mail.gmail.com>
To: Richard Light <richard@light.demon.co.uk>
Cc: semantic-web@w3c.org
2010/1/18 Richard Light <richard@light.demon.co.uk>:
>
> Hi,
>
> In writing a Turtle parser which serializes to RDF/XML, I'm hitting issues
> where RDF/XML can't represent some Turtle constructs.  No surprises there,
> but I would welcome guidance on one specific issue.
>
> The null prefix construct (qname where the prefixname is empty), e.g.:
>
> @prefix : <http://example.org/>  .
> ...
> :a1 :b1 :c1 .
>
> has the air of a default namespace about it.  The temptation is to put:
>
> <rdf:RDF xmlns="http://example.org/" ...
>
> at the head of the output, output the triple as:
>
> <rdf:Description rdf:about="a1"><a2 rdf:resource="a3"/></rdf:Description>
>
> and consider the job done.  Am I right in concluding that this is a snare
> and a delusion, and that the null prefix should simply be expanded each time
> it is encountered, and NOT treated as a namespace of any sort?
>
> My reason for drawing this conclusion is that declaring
>
> <rdf:RDF xmlns="http://example.org/" ...
>
> would cause this namespace to be incorrectly applied to all relative URIs in
> the document, not just those which have been declared as having a null
> prefix.
>
> If true, this means that the null prefix cannot be treated in the same way
> as non-null prefixes, which you can declare as namespaces in the RDF/XML
> representation.  (This is rather significant, since predicates are
> represented as element names in RDF/XML, and so cannot be full URIs.)
>
> Richard
> --
> Richard Light
>
>

Why can't you make up a namespace prefix in the RDF/XML document that
hasn't been used in the turtle document or the RDF/XML document and
apply it to all of the null prefixed items that you get out of turtle?
The fact that the prefix represents a namespace in Turtle has no
bearing on the RDF model in general, you are just lucky that the
RDF/XML document has support for namespaces.

What is the advantage of doing a straight translation without
representing the triples in memory as abstract RDF by the way? Have
you tried translating the turtle document to NTriples first?

Would the following do what you want?

<rdf:Description rdf:about="http://example.org/a1"><a2
xmlns="http://example.org/"
rdf:resource="http://example.org/a3"/></rdf:Description>

Cheers,

Peter
Received on Monday, 18 January 2010 20:51:03 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:48:05 UTC