package getset; //import static com.hp.hpl.jena.assembler.JA.OntModel; import com.hp.hpl.jena.ontology.Individual; import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.query.Query; import 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.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.util.FileManager; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JComboBox; import javax.swing.JOptionPane;
public class set extends javax.swing.JFrame { private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { OntModel model=ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); InputStream in2 =FileManager.get().open("E://ML.owl"); String ds=jComboBox1.getSelectedItem().toString(); if (in2==null) { throw new IllegalArgumentException( "File: " + " not found"); } model.read(in2,""); String str= "PREFIX rdf:< http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+ "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "+ "PREFIX ont:< http://www.semanticweb.org/ontologies/2018/2/untitled-ontology-845#> "+ "select * " + " WHERE { " + "?x ont:ML ?m." + "?x ont:dataset ?d ." + "?x ont:accuracy ?a . " + "Filter (?d ='"+ds+"') . " + "}" ; Query query = QueryFactory.create(str); QueryExecution qexec = QueryExecutionFactory.create(query, model) ; ResultSet results = qexec.execSelect() ; while (results.hasNext()) { QuerySolution binding = results.nextSolution(); Resource subj = (Resource) binding.get("x"); String str2=subj.asResource().getLocalName(); //HERE THE ERROR IS MENTIONED jTextArea1.append("******* THE PUBLICATION: " + " " + str2 + " "); } // TODO add your handling code here: } On Sun, May 27, 2018 at 4:10 PM, ajs6f <aj...@apache.org> wrote: > The fact that the code worked once in one execution environment proves > nothing about its correctness. > > Please do as you have been repeatedly advised and show your code and at > least an appropriate sample of your data and give full details about the > two ways you are trying to execute your program. Otherwise there is little > point in trying to help you. > > ajs6f > > > On May 27, 2018, at 10:02 AM, javed khan <javedbtk...@gmail.com> wrote: > > > > Hello Lorenz, the problem is not in the code because it works fine on > > another computer. When I open the same file on other system (both have > same > > version of java ), it just highlight the error everywhere asLiteral() and > > asResource() is mentioned. When I run the code , it gives me the error > > mentioned above "content is not allowed in prolog" which is usually > caused > > by whitespace etc. > > > > On Sun, May 27, 2018 at 11:54 AM, Lorenz Buehmann < > > buehm...@informatik.uni-leipzig.de> wrote: > > > >> sorry to say that, but **this** is almost **no information** to help you > >> ... > >> > >> 1) previously you said, that you're getting compiler errors but didn't > >> show any code ... > >> > >> 2) no you're showing RDF format errors. again,, you're not showing us > >> the relevant information which in fact is the data > >> > >> > >> On 27.05.2018 03:15, javed khan wrote: > >>> Thanks for your reply > >>> > >>> I use almost the same versions of Java, Netbeans and Protege as my > >> previous > >>> system. > >>> > >>> The error is: > >>> > >>> ERROR [main] (RDFDefaultErrorHandler.java:44) - > >>> file:///C:/Users/Utente/Downloads/LAPTOP/getset/(line 1 column 1): > >> Content > >>> is not allowed in prolog. > >>> Exception in thread "main" org.xml.sax.SAXParseException; systemId: > >>> file:///C:/Users/Utente/Downloads/LAPTOP/getset/; lineNumber: 1; > >>> columnNumber: 1; Content is not allowed in prolog. > >>> > >>> On Sun, May 27, 2018 at 2:05 AM, Bruno P. Kinoshita < > >>> brunodepau...@yahoo.com.br.invalid> wrote: > >>> > >>>> Very likely something in your environment, especially given it's > working > >>>> on the other laptop. > >>>> I think it won't be easy for others to spot what's wrong, without > >> looking > >>>> at the code, and without knowing more about your environment. > >>>> Might be easier for yourself to compare the two environments and try > to > >>>> isolate what's different, especially Java version, and IDE > >> configuration. > >>>> CheersBruno > >>>> > >>>> From: javed khan <javedbtk...@gmail.com> > >>>> To: users@jena.apache.org > >>>> Sent: Sunday, 27 May 2018 11:12 AM > >>>> Subject: Error in Jena code, when switch to another computer > >>>> > >>>> Hello > >>>> > >>>> I have created an application using Jena and Java swings. It was > working > >>>> fine. I switched to another laptop and opened the same file on new > >> laptop > >>>> (I re-installed Netbeans), but it gives me error everywhere > asLiteral() > >> and > >>>> asResource() are used. The asLiteral() and asResource() are used in > >>>> multiple places but everywhere it is highlighted as error. > >>>> > >>>> Could you please highlight the issue ? What could be the problem? > >>>> > >>>> Regards > >>>> > >>>> > >>>> > >>>> > >> > >> > >