Re: Turtle null prefix and namespaces

2010/1/18 Richard Light <>:
> 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 : <>  .
> ...
> :a1 :b1 :c1 .
> has the air of a default namespace about it.  The temptation is to put:
> <rdf:RDF xmlns="" ...
> 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="" ...
> 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=""><a2



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