Hi Dave, Is there any workaround for this problem (calling internal API)? Is there any other way to ID a statement with 'rdf:Id'? Regards, Srimanth
On Sun, Dec 25, 2011 at 12:46 PM, Dave Reynolds <[email protected]>wrote: > On 25/12/2011 04:59, Srimanth Gunturi wrote: > >> Hi Dave, >> Thanks for the response. >> 'prettyTypes' property did not help. >> > > Oh well. > > > In turtle the model is identical. >> > > Fine, so there is indeed no bug. > > > However the ordering of the statements >> change. >> > > The order is irrelevant. > > > I think this has some significance, as in >> the com.hp.hpl.jena.xmloutput.**impl.Unparser when it tries to figure out >> which are the top level subjects - it comes up with different outputs >> based on the order in which it iterates the statements. This in-turn >> happens due the different URL values passed in. >> > > Yes, what Pretty Types is supposed to do is bias the choice of top levels. > > Dave > > Regards, >> Srimanth >> >> >> ==============================**============== >> public class JenaReifiedProblem { >> private static final String someBase = "http://someserver/myapp"; >> public static void main(String[] args) { >> generate1("http://localhost:**8080 <http://localhost:8080>"); >> System.out.println("---------"**); >> generate1("http://localhost:**8080/app <http://localhost:8080/app>"); >> System.out.println("---------"**); >> } >> public static void generate1(String serverURL) { >> Model model = ModelFactory.**createDefaultModel(); >> model.setNsPrefix("dcterms", DCTerms.NS); >> Resource agent = model.createResource(**serverURL+"/agent1", >> DCTerms.Agent); >> Resource fileFormat = >> model.createResource("http://**formatsite.org/fileformat<http://formatsite.org/fileformat> >> ", >> DCTerms.FileFormat); >> fileFormat.addProperty(**DCTerms.title, "TXT"); >> agent.addProperty(DCTerms.**format, fileFormat); >> agent.addProperty(DCTerms.**relation, >> model.createResource(**serverURL+"/agent2")); >> ReifiedStatement rs = >> agent.getProperty(DCTerms.**relation).**createReifiedStatement(** >> someBase+"#relationship"); >> rs.addProperty(DCTerms.title, "My releationship"); >> model.getWriter("RDF/XML-**ABBREV").setProperty("**prettyTypes", new >> Resource[]{DCTerms.Agent}); >> model.write(System.out, "RDF/XML-ABBREV", someBase); >> //model.write(System.out, "N-TRIPLE", someBase); >> >> } >> } >> ==============================**=================== >> >> Turtle output: >> ==============================**=================== >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#type<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#Statement<http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement>> >> . >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#object<http://www.w3.org/1999/02/22-rdf-syntax-ns#object> >> > >> <http://localhost:8080/agent2> . >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#predicate<http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> >> > >> <http://purl.org/dc/terms/**relation <http://purl.org/dc/terms/relation>> >> . >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#subject<http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> >> > >> <http://localhost:8080/agent1> . >> <http://localhost:8080/agent1> >> <http://purl.org/dc/terms/**relation<http://purl.org/dc/terms/relation> >> > >> <http://localhost:8080/agent2> . >> <http://localhost:8080/agent1> >> <http://purl.org/dc/terms/**format<http://purl.org/dc/terms/format> >> > >> <http://formatsite.org/**fileformat <http://formatsite.org/fileformat>> . >> <http://localhost:8080/agent1> >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#type<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> >> > >> <http://purl.org/dc/terms/**Agent <http://purl.org/dc/terms/Agent>> . >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship>> >> <http://purl.org/dc/terms/**title <http://purl.org/dc/terms/title>> >> "My releationship" . >> <http://formatsite.org/**fileformat <http://formatsite.org/fileformat>> < >> http://purl.org/dc/terms/**title <http://purl.org/dc/terms/title>> "TXT" >> . >> <http://formatsite.org/**fileformat <http://formatsite.org/fileformat>> >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#type<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> >> > >> <http://purl.org/dc/terms/**FileFormat<http://purl.org/dc/terms/FileFormat>> >> . >> --------- >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#type<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#Statement<http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement>> >> . >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#object<http://www.w3.org/1999/02/22-rdf-syntax-ns#object> >> > >> <http://localhost:8080/app/**agent2 <http://localhost:8080/app/agent2>> . >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#predicate<http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> >> > >> <http://purl.org/dc/terms/**relation <http://purl.org/dc/terms/relation>> >> . >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship> >> > >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#subject<http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> >> > >> <http://localhost:8080/app/**agent1 <http://localhost:8080/app/agent1>> . >> <http://someserver/myapp#**relationship<http://someserver/myapp#relationship>> >> <http://purl.org/dc/terms/**title <http://purl.org/dc/terms/title>> >> "My releationship" . >> <http://localhost:8080/app/**agent1 <http://localhost:8080/app/agent1>> < >> http://purl.org/dc/terms/**relation <http://purl.org/dc/terms/relation>> >> <http://localhost:8080/app/**agent2 <http://localhost:8080/app/agent2>> . >> <http://localhost:8080/app/**agent1 <http://localhost:8080/app/agent1>> < >> http://purl.org/dc/terms/**format <http://purl.org/dc/terms/format>> >> <http://formatsite.org/**fileformat <http://formatsite.org/fileformat>> . >> <http://localhost:8080/app/**agent1 <http://localhost:8080/app/agent1>> >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#type<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> >> > >> <http://purl.org/dc/terms/**Agent <http://purl.org/dc/terms/Agent>> . >> <http://formatsite.org/**fileformat <http://formatsite.org/fileformat>> < >> http://purl.org/dc/terms/**title <http://purl.org/dc/terms/title>> "TXT" >> . >> <http://formatsite.org/**fileformat <http://formatsite.org/fileformat>> >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#type<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> >> > >> <http://purl.org/dc/terms/**FileFormat<http://purl.org/dc/terms/FileFormat>> >> . >> --------- >> ==============================**=================== >> >> >> On Sat, Dec 24, 2011 at 8:24 AM, Dave Reynolds >> <[email protected] >> <mailto:dave.e.reynolds@gmail.**com<[email protected]>>> >> wrote: >> >> On 23/12/2011 07:30, Srimanth Gunturi wrote: >> >> Hello, >> I have a model which contains a reified statement. Depending on >> what URLs I >> use for resources, I get different outputs. >> >> I would be thankful if someone could explain if this behavior is >> valid or a >> bug. >> >> >> Just looking at the outputs they both look correct. In the first >> case the writer has chosen an order which allowed it to use the >> "rdf:ID" shortcut on the reified statement, in the second case it >> has used the full syntax. >> >> The way to double check would be to convert both outputs to Turtle, >> which doesn't have a shortcut syntactic form for reification, and >> compare those outputs. >> >> You can tune the serialization a little if you need to, for example >> setting to dcterms:Agent to be a "pretty type" would encourage the >> first form of output. See [1]. >> >> Dave >> >> [1] >> http://incubator.apache.org/__**jena/documentation/io/iohowto.** >> __html#advanced_rdfxml_output<http://incubator.apache.org/__jena/documentation/io/iohowto.__html#advanced_rdfxml_output> >> >> <http://incubator.apache.org/**jena/documentation/io/iohowto.** >> html#advanced_rdfxml_output<http://incubator.apache.org/jena/documentation/io/iohowto.html#advanced_rdfxml_output> >> > >> >> >> Thanks. >> >> >> Sample code: >> ********************************__************** >> >> public class JenaReifiedProblem { >> private static final String someBase = "http://someserver/myapp"; >> public static void main(String[] args) { >> generate1("http://localhost:__**8080 <http://localhost:8080>"); >> System.out.println("---------"**__); >> generate1("http://localhost:__**8080/app >> <http://localhost:8080/app>"); >> System.out.println("---------"**__); >> >> } >> public static void generate1(String serverURL) { >> Model model = ModelFactory.__**createDefaultModel(); >> model.setNsPrefix("dcterms", DCTerms.NS); >> Resource agent = model.createResource(__**serverURL+"/agent1", >> DCTerms.Agent); >> Resource fileFormat = >> model.createResource("http://_**_formatsite.org/fileformat >> <http://formatsite.org/**fileformat<http://formatsite.org/fileformat> >> >", >> DCTerms.FileFormat); >> fileFormat.addProperty(__**DCTerms.title, "TXT"); >> agent.addProperty(DCTerms.__**format, fileFormat); >> agent.addProperty(DCTerms.__**relation, >> model.createResource(__**serverURL+"/agent2")); >> ReifiedStatement rs = >> agent.getProperty(DCTerms.__**relation).__** >> createReifiedStatement(__**someBase+"#relationship"); >> >> rs.addProperty(DCTerms.title, "My releationship"); >> model.write(System.out, "RDF/XML-ABBREV", someBase); >> } >> } >> ********************************__************** >> >> Output: >> ********************************__************** >> <rdf:RDF >> xmlns:dcterms="http://purl.__**org/dc/terms/ >> <http://purl.org/dc/terms/>" >> >> xmlns:rdf="http://www.w3.org/_**_1999/02/22-rdf-syntax-ns#<http://www.w3.org/__1999/02/22-rdf-syntax-ns#> >> >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#> >> >"> >> <dcterms:Agent rdf:about="http://localhost:__**8080/agent1 >> >> <http://localhost:8080/agent1>**"> >> <dcterms:relation rdf:ID="relationship" rdf:resource=" >> http://localhost:8080/agent2"/**__> >> <dcterms:format> >> <dcterms:FileFormat >> rdf:about="http://formatsite._**_org/fileformat >> <http://formatsite.org/**fileformat<http://formatsite.org/fileformat> >> >"> >> <dcterms:title>TXT</dcterms:__**title> >> >> </dcterms:FileFormat> >> </dcterms:format> >> </dcterms:Agent> >> <rdf:Statement rdf:about="#relationship"> >> <dcterms:title>My releationship</dcterms:title> >> </rdf:Statement> >> </rdf:RDF> >> --------- >> <rdf:RDF >> xmlns:dcterms="http://purl.__**org/dc/terms/ >> <http://purl.org/dc/terms/>" >> >> xmlns:rdf="http://www.w3.org/_**_1999/02/22-rdf-syntax-ns#<http://www.w3.org/__1999/02/22-rdf-syntax-ns#> >> >> <http://www.w3.org/1999/02/22-**rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#> >> >"> >> <dcterms:FileFormat >> rdf:about="http://formatsite._**_org/fileformat >> <http://formatsite.org/**fileformat<http://formatsite.org/fileformat> >> >"> >> <dcterms:title>TXT</dcterms:__**title> >> >> </dcterms:FileFormat> >> <rdf:Statement rdf:ID="relationship"> >> <rdf:subject> >> <dcterms:Agent rdf:about="http://localhost:__**8080/app/agent1 >> >> <http://localhost:8080/app/**agent1<http://localhost:8080/app/agent1> >> >"> >> <dcterms:relation >> rdf:resource="http://__**localhost:8080/app/agent2 >> <http://localhost:8080/app/**agent2<http://localhost:8080/app/agent2> >> >"/> >> <dcterms:format >> rdf:resource="http://__formats**ite.org/fileformat<http://formatsite.org/fileformat> >> >> <http://formatsite.org/**fileformat<http://formatsite.org/fileformat> >> >"/> >> </dcterms:Agent> >> </rdf:subject> >> <rdf:predicate >> rdf:resource="http://purl.org/**__dc/terms/relation<http://purl.org/__dc/terms/relation> >> >> <http://purl.org/dc/terms/**relation<http://purl.org/dc/terms/relation> >> >"/> >> <rdf:object rdf:resource="http://__**localhost:8080/app/agent2 >> >> <http://localhost:8080/app/**agent2<http://localhost:8080/app/agent2> >> >"/> >> <dcterms:title>My releationship</dcterms:title> >> </rdf:Statement> >> </rdf:RDF> >> --------- >> ********************************__************** >> >> >> >> >
