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

Thanks.


Sample code:
********************************************
public class JenaReifiedProblem {
private static final String someBase = "http://someserver/myapp";;
  public static void main(String[] args) {
generate1("http://localhost:8080";);
  System.out.println("---------");
generate1("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";,
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/";
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
   <dcterms:Agent rdf:about="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";>
         <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/";
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
   <dcterms:FileFormat rdf:about="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";>
         <dcterms:relation rdf:resource="http://localhost:8080/app/agent2"/>
         <dcterms:format rdf:resource="http://formatsite.org/fileformat"/>
       </dcterms:Agent>
     </rdf:subject>
     <rdf:predicate rdf:resource="http://purl.org/dc/terms/relation"/>
     <rdf:object rdf:resource="http://localhost:8080/app/agent2"/>
     <dcterms:title>My releationship</dcterms:title>
   </rdf:Statement>
</rdf:RDF>
---------
********************************************


Reply via email to