Literal lang code issue

Apr 8, 2014 at 1:01 PM
In RemoteDataobjectStore.cs
private IEnumerable<Triple> GetTriplesForDataObject(string identity)
 if (langCode != null)
                        triple.LangCode = langCode;
For some reason I get as a result langCode = "" so instead of
if(langCode != null)
it could be changed to
if (!string.IsNullOrWhiteSpace(langCode))
Apr 9, 2014 at 8:30 AM
Also in SparqlUpdatableStore
private void AppendTriplePattern(Triple triple, StringBuilder builder)
if (!string.IsNullOrWhiteSpace(triple.LangCode))
And Triple.cs
public override string ToString()
            if (IsLiteral)
                return string.Format("<{0}> <{1}> {2}^^{3}{4}", Subject, Predicate, Object, DataType, LangCode == null ? "":"@"+LangCode);
            return string.Format("<{0}> <{1}> <{2}>", Subject, Predicate, Object);
Apr 10, 2014 at 9:33 PM

Did you trace through where the empty string for langCode is coming from ? Is it happening because of the way Virtuoso encodes its SPARQL results set or is there some parser issue in the SPARQL stack. I think if the triple has no @ on the end of the object, then langCode really should be null, not an empty string, and that this is the real problem...


Apr 11, 2014 at 7:27 AM
I assume it's SparqlResultDataObjectHelper,

I've changes in 3 places in that file where LangCode is written:
eg: LangCode = string.IsNullOrWhiteSpace(lit.Language) ? null : lit.Language
Apr 11, 2014 at 8:33 PM
Likely the empty string comes from dotNetRDF's stack, the current API does (and always has) used String.Empty for no language code rather than null

On the 1.9 branch I have finally thrown this out and use null for no language tag instead