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
https://lists.sourceforge.net/lists/listinfo/virtuoso-users



Reply via email to