Re: Proposal for ISSUE-12, string literals

Alex, Steve,

On 2011-05-13, at 19:20, Alex Hall wrote:
> 3. There are probably countless instances of the following logic deployed in existing systems (I cut-and-pasted this directly from my own code):
> 
> public Literal(String lexicalValue, String language, URI datatype) {
>  ...
>  if (language != null && datatype != null) {
>    throw new IllegalArgumentException("An RDF literal may not have both a language and a datatype.");
>  }
>  ...
> }


Implementations *could* choose to *internally* represent "xsd:string" as "no datatype". If you have existing code, then this is perhaps the easiest way to go, as it only requires changes in the input part (turn xsd:string into null) and when asking for the datatype of a literal (if null, return xsd:string). Since "no datatype" in concrete syntaxes would be syntactic sugar for xsd:string, that all works out fine.

On 13 May 2011, at 22:37, Steve Harris wrote:
> More concerning is code like:
> 
> Literal(String lexicalValue, Resource lang_or_dt)
> {
> 	if (typeof(lang_or_dt) == Literal) {
> 		/* it has a language tag */
> 	} else if (typeof(lang_or_dt) == URI) {
> 		/* it has a datatype */ 
> 	} else {
> 		/* it has neither */
> 	}
> }
> 
> We have a lot of such code.

Well, yeah, that's a bit awkward, but again you could choose to make it an internal convention that typeof(lang_or_dt) != URI means the type is really xsd:string.

Best,
Richard

Received on Wednesday, 18 May 2011 18:05:46 UTC