9 Replies Latest reply on May 25, 2011 3:10 PM by alwu-Oracle

    Sparql Queries with Blank nodes

    844414
      Hi,

      I am able to get the exact blank node information if I use oracle sql query

      select a.triple.get_triple() from rdf_data a where a.triple.get_property='<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>' and a.triple.get_obj_value()='<http://www.w3.org/1999/02/22-rdf-syntax-ns#List>'

      Result for above query :
      SDO_RDF_TRIPLE('_:m9mg666826138', '<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>', '<http://www.w3.org/1999/02/22-rdf-syntax-ns#List>')


      If I use the sparql service to query

      SELECT *
      WHERE
      { ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List>}


      it returns blank node values as _:b0 instead of _:m9mg666826138. Why is this so? If I want to get exact blank node information using sparql query, How shall I do the sparql query?

      Please let me know.

      Regards
      Siddu
        • 1. Re: Sparql Queries with Blank nodes
          alwu-Oracle
          Hi,

          Which version of Jena and Jena Adapter are you using?

          Thanks,

          Zhe Wu
          • 2. Re: Sparql Queries with Blank nodes
            844414
            Hi Zhe Wu,

            Following jena and jena adpter I am using

            1. jena-2.6.3
            2. Jena Adapter for Oracle Database 11g Release 2 (11.2.0.2 )

            Regards
            Siddu
            • 3. Re: Sparql Queries with Blank nodes
              alwu-Oracle
              Hi,

              ARQ has a flag that controls the mapping of blank node labels.
              You can set ARQ.outputGraphBNodelLabels to true.

              To do that, put this line of code at the beginning of your program flow.

              ARQ.set(ARQ.outputGraphBNodeLabels, true);

              Please let me know if it helps.

              Zhe
              • 4. Re: Sparql Queries with Blank nodes
                844414
                Hi,

                Thanks for the information.

                Currently I am not using Jena API's or Java programs for sparql queries. There will be "Oracle SPARQL Service Endpoint using Joseki " service running at one end, I am using ruby's rdf.rb sparql client for sparql queries. So how do I set this ARQ.set(ARQ.outputGraphBNodeLabels, true)?

                Regards
                Siddu
                • 5. Re: Sparql Queries with Blank nodes
                  alwu-Oracle
                  Hi,

                  Hmmm. It is tricky but doable.

                  Basically, we can tweak the XMLOutputResultSet code in the Jena 2.6.3 code base to turn off the bNode mapping. I can send you a compiled class if you want. That way, you can update your Jena library with the new class and restart your Joseki server.

                  Thanks,

                  Zhe Wu
                  • 6. Re: Sparql Queries with Blank nodes
                    844414
                    Hi,

                    It would be a great favor if you can send the compiled class.

                    Thanks
                    Siddu
                    • 7. Re: Sparql Queries with Blank nodes
                      alwu-Oracle
                      Hi,

                      Please email me at alan dot wu at oracle dot com.

                      Thanks,

                      Zhe
                      • 8. Re: Sparql Queries with Blank nodes
                        844414
                        Hi Zhe,

                        I installed oracle under windows xp, so I modified the startWebLogic.cmd instead of startWebLogic.sh. Then I downloaded the new class file and added to the folder which you specified and rejarred then copied to web-inf\lib

                        Then I restarted the server,

                        I got the following error when I try to execute the sparql query in the Oracle SPARQL Service Endpoint using Joseki.

                        java.lang.NoClassDefFoundError: com/hp/hpl/jena/sparql/util/IndentedWriter

                             at com.hp.hpl.jena.sparql.resultset.XMLOutputResultSet.(XMLOutputResultSet.java:45)
                             at com.hp.hpl.jena.sparql.resultset.XMLOutput.format(XMLOutput.java:35)
                             at com.hp.hpl.jena.query.ResultSetFormatter.outputAsXML(ResultSetFormatter.java:430)

                             at org.joseki.http.ResponseHttp$1.output(ResponseHttp.java:288)
                             at org.joseki.http.ResponseHttp.output(ResponseHttp.java:476)
                             at org.joseki.http.ResponseHttp.doResponseResult(ResponseHttp.java:283)
                             at org.joseki.http.ResponseHttp.doResponseResultSet(ResponseHttp.java:174)

                             at org.joseki.Response.sendResponse(Response.java:87)
                             at org.joseki.Dispatcher.dispatch(Dispatcher.java:60)
                             at org.joseki.http.Servlet.doCommon(Servlet.java:177)
                             at org.joseki.http.Servlet.doGet(Servlet.java:138)

                             at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
                             at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
                             at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)

                             at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
                             at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
                             at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)

                             at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3594)
                             at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                             at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)

                             at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
                             at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
                             at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)

                             at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
                             at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
                        Caused by: java.lang.ClassNotFoundException: com.hp.hpl.jena.sparql.util.IndentedWriter

                             at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
                             at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
                             at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)

                             at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
                             at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
                             at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
                             at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:37)


                             at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)



                        I look forward to your suggestions,

                        Thanks
                        Siddu
                        • 9. Re: Sparql Queries with Blank nodes
                          alwu-Oracle
                          Hi,

                          Sorry just found out that version I sent you was compiled with arq 2.8.3.

                          There is a dependency change from arq 2.8.3 to arq 2.8.5. Basically,
                          IndentedWriter is moved.

                          // import com.hp.hpl.jena.sparql.util.IndentedWriter;
                          import org.openjena.atlas.io.IndentedWriter ;

                          A new class is on its way.

                          Thanks,

                          Zhe