Nagore The code sample you sent is fairly unreadable and does not appear to be valid Java. The same goes for your RDF/XML data.
Since this list does not support attachments could you please upload the code to a hosting service list PasteBin or a GitHub Gist and reply to the thread with links to the code and data. Thanks, Rob On 05/12/2013 16:18, "Nagore Salaberria" <[email protected]> wrote: >Hello, > >First of all congratulations for the great work you have done with the >JENA >API .My name is Nagore and I'm developing my thesis and for that I need to >make a prototype that enables me to read my rdf files and SPARQL queries >performed on them . So I thought using Jena and when I drove to make my >first test, I ran into the following error: > >*Exception in thread " main" org.apache.jena.riot.RiotException : Invalid >byte 1 of 1 - byte UTF -8 sequence .* >*at org.apache.jena.riot.system.ErrorHandlerFactory $ >ErrorHandlerStd.fatal >( ErrorHandlerFactory.java : 136 )* >*org.apache.jena.riot.lang.LangRDFXML at $ ErrorHandlerBridge.fatalError ( >LangRDFXML.java : 243 )* >*at com.hp.hpl.jena.rdf.arp.impl.ARPSaxErrorHandler.fatalError ( >ARPSaxErrorHandler.java : 48 )* >*at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.warning ( XMLHandler.java : >209)* >*at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.fatalError ( XMLHandler.java : >239 )* >*org.apache.xerces.util.ErrorHandlerWrapper.fatalError at ( Unknown Source >)* >*org.apache.xerces.impl.XMLErrorReporter.reportError at ( Unknown Source >)* >*org.apache.xerces.impl.XMLErrorReporter.reportError at ( Unknown Source >)* >*org.apache.xerces.impl.XMLDocumentFragmentScannerImpl at $ >FragmentContentDispatcher.dispatch ( Unknown Source )* >*org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument at ( >Unknown Source )* >*org.apache.xerces.parsers.DTDConfiguration.parse at ( Unknown Source )* >*org.apache.xerces.parsers.DTDConfiguration.parse at ( Unknown Source )* >*at org.apache.xerces.parsers.XMLParser.parse ( Unknown Source )* >*at org.apache.xerces.parsers.AbstractSAXParser.parse ( Unknown Source )* >*at com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse ( RDFXMLParser.java : >151 )* >*at com.hp.hpl.jena.rdf.arp.ARP.load ( ARP.java : 119 )* >*at org.apache.jena.riot.lang.LangRDFXML.parse ( LangRDFXML.java : 142 )* >*org.apache.jena.riot.RDFParserRegistry at $ ReaderRIOTFactoryImpl $ >1.read >( RDFParserRegistry.java : 142 )* >*at org.apache.jena.riot.RDFDataMgr.process ( RDFDataMgr.java : 818)* >*at org.apache.jena.riot.RDFDataMgr.parse ( RDFDataMgr.java : 679 )* >*at org.apache.jena.riot.RDFDataMgr.read ( RDFDataMgr.java : 211 )* >*at org.apache.jena.riot.RDFDataMgr.read ( RDFDataMgr.java : 184 )* >*at org.apache.jena.riot.RDFDataMgr.read ( RDFDataMgr.java : 122 )* >*at org.apache.jena.riot.RDFDataMgr.read ( RDFDataMgr.java : 113 )* >*at org.apache.jena.riot.adapters.RDFReaderRIOT.read ( RDFReaderRIOT.java >: >77 )* >*at com.hp.hpl.jena.rdf.model.impl.ModelCom.read ( ModelCom.java : 247 )* >*at com.hp.hpl.jena.util.FileManager.readModelWorker ( FileManager.java : >395 )* >*at com.hp.hpl.jena.util.FileManager.loadModelWorker ( FileManager.java : >326 )* >*at com.hp.hpl.jena.util.FileManager.loadModel ( FileManager.java : 278 )* >*at tutorial.prueba.sparqlTest ( prueba.java : 38 )* >*at tutorial.prueba.main ( prueba.java : 30 )* > > >This would be my code: > > > >*package tutorial ;* > >*javax.management.Query import ;* >*org.apache.jena.iri.impl.Main import ;* >*import com.hp.hpl.jena * . ;* >*com.hp.hpl.jena.query.QueryExecution import ;* >*com.hp.hpl.jena.query.QueryExecutionFactory import ;* >*com.hp.hpl.jena.query.QueryFactory import ;* >*com.hp.hpl.jena.query.QuerySolution import ;* >*com.hp.hpl.jena.query.ResultSet import ;* >*com.hp.hpl.jena.rdf.model.Literal import ;* >*com.hp.hpl.jena.rdf.model.Model import ;* >*com.hp.hpl.jena.util.FileManager import ;* > > >*public class Test {* > > > > >*public static void main ( String args [ ] )* >*{* > >*sparqlTest ( ) ;* >*}* > > >*static void sparqlTest ()* >*{* > >*FileManager.get () addLocatorClassLoader ( Main.class.getClassLoader ()). >;* >*FileManager.get Model model = () loadModel ( " >http://localhost/loadtest.rdf <http://localhost/loadtest.rdf> .") ;* > >*String querys =* >*" PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns# ><http://www.w3.org/1999/02/22-rdf-syntax-ns#>> " +* >*" PREFIX gr: <htto://purl.org/goodrelations/v1# ><http://purl.org/goodrelations/v1#>> " +* >*"SELECT * WHERE { " +* >*"? p to gr: offering " +* >*" ? p gr : name x ? " +* >*" }";* > >*com.hp.hpl.jena.query.Query QueryFactory.create q = ( querys );* >*QueryExecution QueryExecutionFactory.create exe = ( q , model );* > >*try {* >*ResultSet result = exe.execSelect ();* >*while ( result.hasNext ())* >*{* > >*QuerySolution result.nextSolution sun = ();* >*Sol.getLiteral name = Literal ("x" );* >*System.out.println ();* >*}* >*finally { }* >*exe.close ( ) ;* >*}* >*}* > >*}* > > >and my rdf file : > >*<? xml version = "1.0 " encoding = "UTF -8 ">* >*< rdf : RDF xmlns: g = " http://purl.org/goodrelations/v1 ><http://purl.org/goodrelations/v1> #" xmlns: xsd = " >http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema> #" >xmlns: rdf = " http:/ / www.w3.org/1999/02/22-rdf-syntax-ns ><http://www.w3.org/1999/02/22-rdf-syntax-ns> # " >* > >*< g : offering* >*<gr:condition> available with different options < / g : condition>* > >*<gr:hasPriceSpecification>* >*<gr:UnitPriceSpecification>* >*<gr:hasCurrencyValue rdf:datatype="http://www.w3.org/2001/XMLSchema#float ><http://www.w3.org/2001/XMLSchema#float>"> € 279.66 < / gr: >hasCurrencyValue >* >*< / gr: UnitPriceSpecification >* >*< / gr: hasPriceSpecification >* >*< g : image / >* >*<gr:name> bicycle training roller Roller Elite AL13 < / gr: name>* >*< / gr: offering>* > >*< g : offering* >*<gr:condition> available with different options < / g : condition>* > >*<gr:hasPriceSpecification>* >*<gr:UnitPriceSpecification>* >*<gr:hasCurrencyValue rdf:datatype="http://www.w3.org/2001/XMLSchema#float ><http://www.w3.org/2001/XMLSchema#float>"> € 444.23 < / gr: >hasCurrencyValue >* >*< / gr: UnitPriceSpecification >* >*< / gr: hasPriceSpecification >* >*< g : image / >* >*<gr:name> bicycle training roller Arion Digital Elite Roller < / gr: >name>* >*< / gr: offering>* >*< / rdf : RDF >* > > > > >I hope your answer, > >Regards, > > > >-- >Nagore Salaberria<[email protected]>
