Hi Lourens,

I have been able to recreate the issue you report testing against a v6 archive, we had been testing against a v5 archive which does not have this issue. This has been reported to development for resolution and I shall let you know when their is a fix ...

Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support



On 22 Sep 2009, at 10:50, Lourens van der Meij wrote:

Thanks for the program. I only changed the urlDB value of course.(and
ran it as dba)
My output is:
------ exec 1 query ------
============= < ROW > ============
VirtuosoExtendedString: [iri=1] ==> [http://test1]
VirtuosoExtendedString: [iri=1] ==> [pp]
     |class java.lang.String| ==> [test eng]
============= < ROW > ============
VirtuosoExtendedString: [iri=1] ==> [http://test2]
VirtuosoExtendedString: [iri=1] ==> [pp]
     |class java.lang.String| ==> [test net]
------ exec 2 query ------
============= < ROW > ============
     |class java.lang.String| ==> [!D - overbodig: 260 Ængwirden]
VirtuosoExtendedString: [iri=1] ==> [http://brinkman.kb.nl/btr/148622968 ]
...
.... cut out a couple of rows.
============= < ROW > ============
     |class java.lang.String| ==> ["Patroonherkenning in ruimere zin
wordt naar doelstelling en gebruikte methodes onderverdeeld in:
Beeldverwerking en patroonherkenning in beperktere zin. Beeldverwerking
in de ruimste zin omvat een aantal aspecten: beeldacquisitie,
beeldopslag, beeldweergave, beelverwerking en -bewerking in de engere zin"] VirtuosoExtendedString: [iri=1] ==> [http://brinkman.kb.nl/btr/096947381 ]

I hope you agree that the response should contain
VirtuosoRdfBox:[rdf=test eng; type=null;lang=en]
You do get that?

Thanks so far,
Lourens



Hugh Williams wrote:
Hi Lourens,

We are still unable to reproduce he issue you report. Below is a
sample program we used to try an created, please compile and run this
program yourself to see if it returns the xml:lang attributes required
on your system:

import java.math.BigDecimal;
import java.io.*;
import java.util.*;
import java.sql.*;
import virtuoso.jdbc3.*;

public class Test {


 public static void main(String argv[])
 {
try {

    String urlDB = "jdbc:virtuoso://pcc:1112/charset=UTF-8";

  Class.forName("virtuoso.jdbc3.Driver");
  Connection conn = DriverManager.getConnection(urlDB,"dba","dba");

  Statement st = conn.createStatement();
  DatabaseMetaData md = conn.getMetaData();
  PreparedStatement ps;

  st.execute("sparql clear graph <gr>");

  st.execute("sparql insert into graph <gr> { <http://test1
<http://test1/>> <pp> 'test eng'@en . <http://test2 <http://test2/>>
<pp>  'test net'@nl }");

System.out.println("------ exec 1 query ------");
  execQuery(st, "sparql SELECT * FROM <gr> WHERE {?s ?p ?o}");

System.out.println("------ exec 2 query ------");
  execQuery(st, "sparql select ?l ?u where {?u ?z
?l.filter(langmatches(lang(?l),'nl'))} limit 10");


  conn.close();
  } catch (Exception e) {
      System.out.println(e);
System.out.println ("===========================================================");
      e.printStackTrace();
  }
}


public static void execQuery(Statement st, String query) throws
SQLException
{
  ResultSet rs;
  ResultSetMetaData rsmd;

  rs = st.executeQuery(query);
  rsmd = rs.getMetaData();

  while(rs.next()) {
    Object o;

    System.out.println(" ============= < ROW > ============ ");
    for (int i = 1; i <= rsmd.getColumnCount(); i++) {
      String s = rs.getString(i);
      o = rs.getObject(i);
      if (rs.wasNull())
        System.out.println(i+" ==> NULL");
      else
      {
        if (o instanceof VirtuosoExtendedString)
          {
            VirtuosoExtendedString vs = (VirtuosoExtendedString)o;
            System.out.print("VirtuosoExtendedString:
[iri="+vs.iriType+"]");
          }
        else if (o instanceof VirtuosoRdfBox)
         {
            VirtuosoRdfBox rb = (VirtuosoRdfBox)o;
            System.out.print("VirtuosoRdfBox:[rdf="+rb+";
type="+rb.getType()+";lang="+rb.getLang()+"]");
         }
        else
         {
            System.out.print("      |");
            System.out.print(""+o.getClass()+"|");
         }
        System.out.println(" ==> ["+ o + "]");
      }
    }
  }
}

}

Comparing its out against running the same query "SELECT * FROM <gr>
WHERE {?s ?p ?o}" against the SPARQL endpoint directly ...

Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support



On 19 Sep 2009, at 13:02, Lourens van der Meij wrote:

Thanks for the quick response.

For clarification:
The documentation states:
1)"If the RDF literal object have language or datatype specified then
virtuoso.jdbc3.VirtuosoRdfBox will be returned."
 Which doesn't seem to be happening, a java String is returned from
getObject
2)I have no problems with the sparql internals, the right things are
returned, sparql notices the xml:lang,
as seen in my test query:   filter(langmatches(lang(?l),"nl")).
3)But, the literals returned are returned as java Strings, even though
they have an xml:lang tag.
4)Both localhost:8890/sparql and isql give the correct things back,
but neither shows xml:lang info.

========
DETAILS for isql:
- isql returns the same results as the jdbc3 connection:
sparql select ?l ?u where {?u skos:prefLabel ?l.
filter(langmatches(lang(?l),"nl"))} limit 10;

l                                             u
VARCHAR                           VARCHAR
----------------------------
"Populaire" genres en vormen   http://www.oclc.org/nl/kar/Mp
...

That is ok, although I would have preferred getting
"\"Populaire\" genres en vormen"@"nl"
or something like that.

But especially from jdbc, I need the language tags of the returned
Literals.

I tested this also on a LINUX MACHINE with virtuoso installed from
virtuoso-opensource-6.0.0-tp1.tar.gz,
the same happens there.

Kind regards,

Lourens van der Meij

Hugh Williams wrote:
Hi Lourens,

The sample code looks correct and should retrieve the correct results
if the data is loaded correctly into Virtuoso. Thus can you confirm
the same query returns the correct results when executed via the
Virtuoso isql command line program and the SPARQL endpoint
(http://hostname:port/sparql) ...

Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support



On 18 Sep 2009, at 17:30, Lourens van der Meij wrote:

I tried getting RDF results of a query through JAVA. I used the
jdbc example occurring in the Virtuoso documentation, but Literals with
xml:lang specification return as java String.

The drivers I tested:
* recent virtjdbc3.jar (ftp'd just now)
OpenLink Virtuoso(TM) Driver for JDBC(TM) Version 3.x [Build 3.35]
* The virtjdbc3.jar that came with the 6.0 windows binary installation:
OpenLink Virtuoso(TM) Driver for JDBC(TM) Version 3.x [Build
3.27/06.00.3039]

The virtuoso version is 6.0.0-pre2.3118-threads as of Apr 23 2009
(downloaded from virtuoso site)

My query is:
"sparql SELECT ?l ?u where {?u skos:prefLabel
?l.FILTER(langmatches(lang(?l),\"nl\"))} LIMIT 10";

I get results:
"Populaire" genres en vormen
<http://www.oclc.org/nl/kar/Mp>

I did have to specify:-Djdbc.drivers=virtuoso.jdbc3.Driver in java as
otherwise
the driver was not found. The
Object o = ((VirtuosoResultSet)rs).getObject(i);
returns a java String for Literals, apparently even if the literal has
an xml:lang attribute.

Am I missing something?
Any advice? Should I use the higher level interfaces to java?

=================
The code:
import java.sql.*;
import virtuoso.jdbc3.*;

public class TestVirtuosoRDFBare {
 public static void main(String[] args) throws SQLException {
     String connectionURL =
"jdbc:virtuoso://localhost:1111/UID=demo/PWD=demo";
     Connection connection =
DriverManager.getConnection(connectionURL);
     Statement stmt = connection.createStatement();
     String query = "sparql SELECT ?l ?u where {?u skos:prefLabel
?l.FILTER(langmatches(lang(?l),\"nl\"))} LIMIT 10";
     boolean more = stmt.execute(query);
     ResultSetMetaData data = stmt.getResultSet().getMetaData();
     while (more) {
         ResultSet rs = stmt.getResultSet();
         while(rs.next()){
             for(int i = 1;i <= data.getColumnCount();i++) {
                 String s = rs.getString(i);
                 Object o = ((VirtuosoResultSet)rs).getObject(i);
if (o instanceof VirtuosoExtendedString) // String
representing an IRI
                 {
                     VirtuosoExtendedString vs =
(VirtuosoExtendedString) o;
                     if (vs.iriType == VirtuosoExtendedString.IRI)
                         System.out.println ("<" + vs.str +">");
                     else if (vs.iriType ==
VirtuosoExtendedString.BNODE)
                         System.out.println ("<" + vs.str +">");
                 }
                 else if (o instanceof VirtuosoRdfBox) // Typed
literal
                 {
                     VirtuosoRdfBox rb = (VirtuosoRdfBox) o;
                     System.out.println (rb.rb_box + " lang=" +
rb.getLang() + " type=" + rb.getType());

                 }
                 else if(stmt.getResultSet().wasNull())
                     System.out.println("NULL");
                 else {
                     System.out.println(s);
                 }
             }
         }
         more = stmt.getMoreResults();
     }
     connection.close();
 }
}


------------------------------------------------------------------------------


Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart
your
developing skills, take BlackBerry mobile applications to market and
stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register
now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
<mailto:Virtuoso-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/virtuoso-users



------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and
stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register
now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users



------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users


Reply via email to