Re: How to Stringify RDFTriple and BlankNode

I agree with Toby, I think using the NTriple syntax is indeed the best idea. Why inventing something new? 

The NTriple syntax also defines the representation for a blank node which is, surprise suprise, "_:asdfasfas" where the "asdfasfas" string is, as Toby says, 'unstable' (the only feature of the string is that two different BNodes will have two different values). I do not see any reason why giving the developers an extra hook to serialize bnodes... 

Ivan

On Apr 23, 2010, at 12:33 , Toby Inkster wrote:

>> What would you expect to be the result of the following print statements:
>> 
>> 1. var bn = new BlankNode()
>>   print(bn.toString())
> 
> Something like:
> 
>    _:fsdfsdgfdrg
> 
> Where everything after "_:" is a string that cannot be relied upon to be
> stable.
> 
>> 2. subject = new URI("http://www.example.com#foo");
>>   var triple1 = new RDFTriple(subject, rdfa.rdfs.label, new
>> PlainLiteral("a,b c; g"));
>>   print(triple1.toString());
> 
> Definately:
> 
>    http://www.example.com#foo
> 
> And not:
> 
>    <http://www.example.com#foo>
> 
> toString is called by the Javascript engine automatically when an object
> is coerced into a string, so needs to return the most useful
> representation of the object. Returning without the angled brackets allows
> it to be used like this:
> 
>   for (each triple blah blah)
>   {
>     if (triple.subject == document.location.href)
>     {
>       do something;
>     }
>   }
> 
>> 3. subject = new URI("http://www.example.com#foo");
>>   var triple1 = new RDFTriple(subject, rdfa.rdfs.label, new
>> PlainLiteral("http://www.example.com#foo"));
>>   print(triple1.toString());
>> 
>> In an early release of the JS Prototype of the RDFa DOM API, I used
>> TURTLE syntax in general.
>> This would solve the problem but seems to be too much RDF in this API.
> 
> I'd expect an N-Triples representation of the triple with some
> canonicalised whitespace agreed on. Say, a single space character between
> each of the subject, predicate, object and full stop; and no trailing
> whitespace or new line characters.
> 
> That makes it possible to easily check a triple against a known value:
> 
>  if (triple == '<http://example.com/joe#me>
> <http://xmlns.com/foaf/0.1/name> "Joe" .')
>  {
>    do something;
>  }
> 
> -Toby
> 


----
Ivan Herman, W3C Semantic Web Activity Lead
Home: http://www.w3.org/People/Ivan/
mobile: +31-641044153
PGP Key: http://www.ivan-herman.net/pgpkey.html
FOAF: http://www.ivan-herman.net/foaf.rdf

Received on Friday, 23 April 2010 13:34:05 UTC