Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-818

Literal.sameValueAs isn't consistent or symmetric

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Jena 2.12.1
    • Jena 2.13.0
    • Jena
    • None

    Description

      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.

         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") ;
          }
      

      gives:

      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
      

      Attachments

        Activity

          People

            andy Andy Seaborne
            andy Andy Seaborne
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: