W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2012

STRBEFORE() etc.

From: Steve Harris <steve.harris@garlik.com>
Date: Tue, 24 Apr 2012 10:29:57 +0100
Message-Id: <E877A153-AF2A-49E0-BB30-05D39FAB82FF@garlik.com>
To: SPARQL Working Group <public-rdf-dawg@w3.org>
Hi all,

[sorry if this is covered in the testcases, I still don't have a harness for them]

So I'm just looking at STRBEFORE(), http://www.w3.org/2009/sparql/docs/query-1.1/rq25.xml#func-strbefore

The text says:

“The function returns a literal of the same kind (simple literal, plain literal same language tag, xsd:string) as the first argument arg1.”

However - does this trump the statement in http://www.w3.org/TR/xpath-functions/#func-substring-before that under some circumstances fn:substring-before “returns the zero-length string”.

I suspect that the right behaviour is for the function to return "" under those conditions - both as it makes more sense logically, and to make error handing in queries simpler.

e.g.
   STRBEFORE("foo"@en-GB, "bar") → ""@en-GB
is somewhat misleading, and a little tricky to test for e.g. you'd have to use
   STR(STRBEFORE(?string, "\t")) = ""
 in order to catch non-matches

I /think/ what I'd want as a user is:

arg1		arg2		result		comment
-------------	------------	----------		-----------------------------------------------------
"foo"@fr		"o"			"f"@fr		"normal" case
"foo"@fr		"bar"		""			exception case
"foo"@fr		"foo"		""@fr		the empty lang-tagged string is before
"foo"@fr		""			""			exception case

i.e. the return values in the exception cases are as per fn:substring-before, and the "literal of the same kind" only applies to the non-excpetion cases.

But maybe that's confusing too?

FWIW, I've currently implemented "literal of the same kind" only, and have no end-user experience.

Thoughts?

Cheers,
   Steve

-- 
Steve Harris, CTO
Garlik, a part of Experian 
1-3 Halford Road, Richmond, TW10 6AW, UK
+44 20 8439 8203  http://www.garlik.com/
Registered in England and Wales 653331 VAT # 887 1335 93
Registered office: Landmark House, Experian Way, NG2 Business Park, Nottingham, Nottinghamshire, England NG80 1ZZ
Received on Tuesday, 24 April 2012 09:30:22 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:48 GMT