You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2014/11/26 19:07:12 UTC

[jira] [Comment Edited] (JENA-818) Literal.sameValueAs isn't consistent or symmetric

    [ https://issues.apache.org/jira/browse/JENA-818?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14226544#comment-14226544 ] 

Andy Seaborne edited comment on JENA-818 at 11/26/14 6:06 PM:
--------------------------------------------------------------

Proposed fix:

# Strings are same-value if they have the same lexical form.
# Language strings are same-value if they have the same lexical form and language tags are equals-ignore-case.
# If both are legal literals by their respective datatype, devolve to the datatype of one of them.
# If one is well formed and one if not, then false.
# If both ill-formed, return the result of LiteralLabel.equals (i.e. are they the same RDF term?).

4 is really a short-cut on part of 5. if one is well formed, the other can't be the same value nor can it be equals as RDF terms.

It is at 5 where there is a change.

This applies to RDF 1.0 and RDF 1.1.


was (Author: andy.seaborne):
Proposed fix:

# Strings are same value if they have the same lexical form.
# Language strings match if same lexical form and language tags are equal-ignore-case.
# If both are legal literals by the datatype, devolve to the datatype of one of them.
# If one is well formed and one if not, then false.
# If both ill-formed, return the result of LiteralLabel.equals.

4 is really a short-cut on part of 5.
It is at 5 where there is a change.

This applies to RDF 1.0 and RDF 1.1.

> Literal.sameValueAs isn't consistent or symmetric
> -------------------------------------------------
>
>                 Key: JENA-818
>                 URL: https://issues.apache.org/jira/browse/JENA-818
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: Jena
>    Affects Versions: Jena 2.12.1
>            Reporter: Andy Seaborne
>            Assignee: Andy Seaborne
>
> Literal.sameValue can give some unexpected answers.  It only check the lexical form in some cases of ill-formed literals, ignoring the datatype.
> It should be conservative (return true if and only if the values are known to be the same) and symmetric.
> {noformat}
>    static void exec(String str1, String str2) {
>         Node n1 = SSE.parseNode(str1) ;
>         Node n2 = SSE.parseNode(str2) ;
>         System.out.printf("%-5s :: %-46s %s\n", n1.sameValueAs(n2),n1, n2) ;
>     }
>     public static void main(String[] args) {
>         exec("'1'^^xsd:integer", "'abc'^^<http://example/dt>") ;
>         exec("'abc'^^<http://example/dt>", "'1'^^xsd:integer") ;
>         System.out.println() ;
>         exec("'abc'^^xsd:integer", "'abc'^^<http://example/dt>") ;
>         exec("'abc'^^<http://example/dt>", "'abc'^^xsd:integer") ;
>         System.out.println() ;
>         exec("'1'^^xsd:integer", "'1'^^xsd:dateTime") ;
>         exec("'1'^^xsd:dateTime", "'1'^^xsd:integer") ;
>     }
> {noformat}
> gives:
> {noformat}
> false :: "1"^^http://www.w3.org/2001/XMLSchema#integer    "abc"^^http://example/dt
> false :: "abc"^^http://example/dt                         "1"^^http://www.w3.org/2001/XMLSchema#integer
> false :: "abc"^^http://www.w3.org/2001/XMLSchema#integer  "abc"^^http://example/dt
> true  :: "abc"^^http://example/dt                         "abc"^^http://www.w3.org/2001/XMLSchema#integer
> true  :: "1"^^http://www.w3.org/2001/XMLSchema#integer    "1"^^http://www.w3.org/2001/XMLSchema#dateTime
> false :: "1"^^http://www.w3.org/2001/XMLSchema#dateTime   "1"^^http://www.w3.org/2001/XMLSchema#integer
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)