Re: Re 2: RDF Interfaces - new draft

Ivan Herman wrote:
> I understand, sold:-)

yay :)

> On May 2, 2011, at 16:30 , Nathan wrote:
> 
>> Ivan Herman wrote:
>>> On May 2, 2011, at 16:04 , Nathan wrote:
>>>> Ivan Herman wrote:
>>>>> I have one more comment/question.
>>>>> In the RDFNode interface there is a separate toSring() and toNT() method. Is it really necessary to have these separately? In the case of the Triple interface toString() is defined as giving the NT representation of a triple, wouldn't it be more logical to say exactly the same for the individual Nodes, and drop the separate toNT() method?
>>>> We need to have a stringifier on there, we can either decorate the value with 'stringifier' (which entails implementations adding a toString method) or have a separate toString method (as we do now), either way the result of calling toString is quite different than calling toNT, and both are needed, /especially/ for named nodes and literals. I find I use both methods all the time (toNT a bit less), and toString is really indispensable.
>>> Please explain... when and why do you use one and the other?
>> Typically I use toNT when debugging and testing things, and use toString pretty much all the time when working with or presenting data, it's also the native stringifier called by most host environments (javascript, java, php etc) when using write/echo/log type functions.
>>
>> Here are some real examples which show the difference:
>>
>> a = createNamedNode('http://www.w3.org/2001/XMLSchema#double');
>> b = createLiteral("12345678987654321987654321", a );
>> c = createLiteral("hello world", "@en" );
>> d = createLiteral("false", createNamedNode('http://www.w3.org/2001/XMLSchema#boolean') );
>>
>> a.toString();	string: http://www.w3.org/2001/XMLSchema#double
>> a.toNT();	string: <http://www.w3.org/2001/XMLSchema#double>
>> a.valueOf();	string: http://www.w3.org/2001/XMLSchema#double
>>
>> b.toString();	string: 12345678987654321987654321
>> b.toNT();	string:
>> "12345678987654321987654321"^^<http://www.w3.org/2001/XMLSchema#double>
>> b.valueOf();	number: 1.2345678987654322e+25
>>
>> c.toString();	string: hello world
>> c.toNT();	string: "hello world"@en
>> c.valueOf();	string: hello world
>>
>> d.toString();	string: false
>> d.toNT();	string: "false"^^<http://www.w3.org/2001/XMLSchema#boolean>
>> d.valueOf();	bool: false
>>
>> So typically, when debugging and the like I use toNT, when working with data I use toString or valueOf, and when presenting I invariable use toString.
>>
>> Best,
>>
>> Nathan
>>
> 
> 
> ----
> 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 Monday, 2 May 2011 15:12:09 UTC