You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Srimanth Gunturi <sr...@gmail.com> on 2011/12/23 08:30:44 UTC

Different outputs when using Statement.createReifiedStatement()

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.
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>
---------
********************************************

Re: Different outputs when using Statement.createReifiedStatement()

Posted by Dave Reynolds <da...@gmail.com>.
On 26/12/2011 17:08, Srimanth Gunturi wrote:
> Hi Dave,
> I agree there is technically no problem with either representations.
> However we need to document in our specification (in ABBREV xml) with
> examples which one it will be. Currently it could be either depending on
> which server at runtime. There could be non-Jena, or simple XML parsers
> which could not parse the other output. We just want to consistentently
> specify the first format (which is valid).

Parsing RDF/XML with a normal XML parser with none of the RDF logic is 
always going to be fragile.

If that's your goal then I recommend using the non-ABBREV writer as I 
mentioned before and avoiding all special case RDF/XML serialization 
rules, including reification.

> I tried the RDFSyntax.sectionReification() with no improvement - still
> get different outputs for URL changes. Maybe I am doing this wrong?
> RDFWriter abbrevWriter = model.getWriter("RDF/XML-ABBREV");
> abbrevWriter.setProperty("blockRules", new
> Resource[]{RDFSyntax.sectionReification});
> //abbrevWriter.setProperty("prettyTypes", new Resource[]{DCTerms.Agent});
> model.write(System.out, "RDF/XML-ABBREV", someBase);

You have to use the abbrevWriter you created to do the writing:

     abbrevWriter.write(model, System.out, someBase);

> Regarding 'rdf:Id' - since Statement.createReifiedstatement() generates
> either format depending on URL, we are thinking of not using it but
> rather somehow attaching 'rdf:Id' to the statement.

Sorry, I don't follow that.

Statement.createReifiedStatement creates the reified statement itself, 
i.e. the set of four triples that make up the reification. This is a 
model manipulation not a syntax manipulation. It has nothing to do with 
the syntax that the writer uses for writing it out.

Dave

> Doing this will
> allow us to generate a top level rdf:Description about this rdf:Id (like
> example 20 in http://www.w3.org/TR/rdf-primer/#reification).


> I have opened https://issues.apache.org/jira/browse/JENA-183 to track
> this further.
>
> Thank you for your time,
> Regards,
> Srimanth.
>
>
>
>
>
> On Mon, Dec 26, 2011 at 6:15 AM, Dave Reynolds
> <dave.e.reynolds@gmail.com <ma...@gmail.com>> wrote:
>
>     On 26/12/2011 06:48, Srimanth Gunturi wrote:
>
>         Hi Dave,
>
>         Is there any workaround for this problem (calling internal API)?
>
>
>     What problem? I thought we had agreed both outputs correctly
>     represents the RDF statements - which is the only guarantee the
>     writer offers. They are "just" syntactic variants of each other.
>
>     As noted in my response on Sourceforge you could always use the
>     non-ABBREV writer which will make things look more consistent -
>     consistently ugly maybe :) but more consistent.
>
>     You can also, as explained in the IO HOW TO [1], switch off
>     particular serialization rules. So you could switch off
>     RDFSyntax.sectionReification to avoid the syntactic short cut
>     kicking in, if that's the way round you want.
>
>     Note that the correct location for tracking jena issues and
>     suggestions is the Apache Jira [2].
>
>
>         Is there any other way to ID a statement with 'rdf:Id'?
>
>
>     Don't follow. In both your example outputs the statement is
>     identified by rdf:Id. In the first one it is done by the reification
>     syntactic short cut:
>
>
>     <dcterms:relation rdf:ID="relationship" rdf:resource="
>     http://localhost:8080/agent2"> ...
>
>     In the second one there is an explicit reification:
>
>     <rdf:Statement rdf:ID="relationship"> ...
>
>     Is there a reason you need to force one form over the other?  As
>     noted above you could turn off the first form and so only get the
>     second form if that is helpful.
>
>     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>
>     [2]
>     http://incubator.apache.org/__jena/help_and_support/bugs___and_suggestions.html
>     <http://incubator.apache.org/jena/help_and_support/bugs_and_suggestions.html>
>
>         Regards,
>         Srimanth
>
>
>         On Sun, Dec 25, 2011 at 12:46 PM, Dave Reynolds
>         <dave.e.reynolds@gmail.com <ma...@gmail.com>
>         <mailto:dave.e.reynolds@gmail.__com
>         <ma...@gmail.com>>> 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>
>         <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://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#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://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://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://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://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://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://purl.org/dc/terms/__relation
>         <http://purl.org/dc/terms/relation>>> .
>         <http://someserver/myapp#____relationship
>         <http://someserver/myapp#__relationship>
>         <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://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://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://purl.org/dc/terms/__format
>         <http://purl.org/dc/terms/format>>>
>         <http://formatsite.org/____fileformat
>         <http://formatsite.org/__fileformat>
>
>         <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://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://purl.org/dc/terms/__Agent
>         <http://purl.org/dc/terms/Agent>>> .
>         <http://someserver/myapp#____relationship
>         <http://someserver/myapp#__relationship>
>         <http://someserver/myapp#__relationship
>         <http://someserver/myapp#relationship>>>
>         <http://purl.org/dc/terms/____title
>         <http://purl.org/dc/terms/__title>
>         <http://purl.org/dc/terms/__title <http://purl.org/dc/terms/title>>>
>         "My releationship" .
>         <http://formatsite.org/____fileformat
>         <http://formatsite.org/__fileformat>
>         <http://formatsite.org/__fileformat
>         <http://formatsite.org/fileformat>>>
>         <http://purl.org/dc/terms/____title
>         <http://purl.org/dc/terms/__title>
>         <http://purl.org/dc/terms/__title
>         <http://purl.org/dc/terms/title>>> "TXT" .
>         <http://formatsite.org/____fileformat
>         <http://formatsite.org/__fileformat>
>         <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://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://purl.org/dc/terms/__FileFormat
>         <http://purl.org/dc/terms/FileFormat>>> .
>                 ---------
>         <http://someserver/myapp#____relationship
>         <http://someserver/myapp#__relationship>
>         <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#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://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://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://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://localhost:8080/app/__agent2
>         <http://localhost:8080/app/agent2>>> .
>         <http://someserver/myapp#____relationship
>         <http://someserver/myapp#__relationship>
>         <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://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://purl.org/dc/terms/__relation
>         <http://purl.org/dc/terms/relation>>> .
>         <http://someserver/myapp#____relationship
>         <http://someserver/myapp#__relationship>
>         <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://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://localhost:8080/app/__agent1
>         <http://localhost:8080/app/agent1>>> .
>         <http://someserver/myapp#____relationship
>         <http://someserver/myapp#__relationship>
>         <http://someserver/myapp#__relationship
>         <http://someserver/myapp#relationship>>>
>         <http://purl.org/dc/terms/____title
>         <http://purl.org/dc/terms/__title>
>         <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://localhost:8080/app/__agent1
>         <http://localhost:8080/app/agent1>>>
>         <http://purl.org/dc/terms/____relation
>         <http://purl.org/dc/terms/__relation>
>         <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/__agent2
>         <http://localhost:8080/app/agent2>>> .
>         <http://localhost:8080/app/____agent1
>         <http://localhost:8080/app/__agent1>
>         <http://localhost:8080/app/__agent1
>         <http://localhost:8080/app/agent1>>>
>         <http://purl.org/dc/terms/____format
>         <http://purl.org/dc/terms/__format>
>         <http://purl.org/dc/terms/__format
>         <http://purl.org/dc/terms/format>>>
>         <http://formatsite.org/____fileformat
>         <http://formatsite.org/__fileformat>
>         <http://formatsite.org/__fileformat
>         <http://formatsite.org/fileformat>>> .
>         <http://localhost:8080/app/____agent1
>         <http://localhost:8080/app/__agent1>
>         <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://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://purl.org/dc/terms/__Agent
>         <http://purl.org/dc/terms/Agent>>> .
>         <http://formatsite.org/____fileformat
>         <http://formatsite.org/__fileformat>
>         <http://formatsite.org/__fileformat
>         <http://formatsite.org/fileformat>>>
>         <http://purl.org/dc/terms/____title
>         <http://purl.org/dc/terms/__title>
>         <http://purl.org/dc/terms/__title
>         <http://purl.org/dc/terms/title>>> "TXT" .
>         <http://formatsite.org/____fileformat
>         <http://formatsite.org/__fileformat>
>         <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://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://purl.org/dc/terms/__FileFormat
>         <http://purl.org/dc/terms/FileFormat>>> .
>                 ---------
>                 ==============================____===================
>
>
>
>                 On Sat, Dec 24, 2011 at 8:24 AM, Dave Reynolds
>         <dave.e.reynolds@gmail.com <ma...@gmail.com>
>         <mailto:dave.e.reynolds@gmail.__com
>         <ma...@gmail.com>>
>         <mailto:dave.e.reynolds@gmail.
>         <ma...@gmail.>____com
>
>         <mailto:dave.e.reynolds@gmail.__com
>         <ma...@gmail.com>>>> 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>>
>
>
>         <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
>         <http://formatsite.org/fileformat>>
>         <http://formatsite.org/____fileformat
>         <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#>>
>         <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>
>         <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#>>
>         <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>
>         <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>
>
>         <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>
>
>         <http://localhost:8080/app/__agent2
>         <http://localhost:8080/app/agent2>>>"/>
>         <dcterms:format
>                 rdf:resource="http://__formats____ite.org/fileformat
>         <http://formats__ite.org/fileformat>
>         <http://formatsite.org/__fileformat
>         <http://formatsite.org/fileformat>>
>
>         <http://formatsite.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>>
>         <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>
>
>         <http://localhost:8080/app/__agent2
>         <http://localhost:8080/app/agent2>>>"/>
>         <dcterms:title>My releationship</dcterms:title>
>         </rdf:Statement>
>         </rdf:RDF>
>                         ---------
>                         ******************************______**************
>
>
>
>
>
>
>


Re: Different outputs when using Statement.createReifiedStatement()

Posted by Srimanth Gunturi <sr...@gmail.com>.
Hi Dave,
I agree there is technically no problem with either representations.
However we need to document in our specification (in ABBREV xml) with
examples which one it will be. Currently it could be either depending on
which server at runtime. There could be non-Jena, or simple XML parsers
which could not parse the other output. We just want to consistentently
specify the first format (which is valid).

I tried the RDFSyntax.sectionReification() with no improvement - still get
different outputs for URL changes. Maybe I am doing this wrong?
RDFWriter abbrevWriter = model.getWriter("RDF/XML-ABBREV");
 abbrevWriter.setProperty("blockRules", new
Resource[]{RDFSyntax.sectionReification});
//abbrevWriter.setProperty("prettyTypes", new Resource[]{DCTerms.Agent});
 model.write(System.out, "RDF/XML-ABBREV", someBase);


Regarding 'rdf:Id' - since Statement.createReifiedstatement() generates
either format depending on URL, we are thinking of not using it but rather
somehow attaching 'rdf:Id' to the statement. Doing this will allow us to
generate a top level rdf:Description about this rdf:Id (like example 20 in
http://www.w3.org/TR/rdf-primer/#reification).

I have opened https://issues.apache.org/jira/browse/JENA-183 to track this
further.

Thank you for your time,
Regards,
Srimanth.





On Mon, Dec 26, 2011 at 6:15 AM, Dave Reynolds <da...@gmail.com>wrote:

> On 26/12/2011 06:48, Srimanth Gunturi wrote:
>
>> Hi Dave,
>>
>> Is there any workaround for this problem (calling internal API)?
>>
>
> What problem? I thought we had agreed both outputs correctly represents
> the RDF statements - which is the only guarantee the writer offers. They
> are "just" syntactic variants of each other.
>
> As noted in my response on Sourceforge you could always use the non-ABBREV
> writer which will make things look more consistent - consistently ugly
> maybe :) but more consistent.
>
> You can also, as explained in the IO HOW TO [1], switch off particular
> serialization rules. So you could switch off RDFSyntax.sectionReification
> to avoid the syntactic short cut kicking in, if that's the way round you
> want.
>
> Note that the correct location for tracking jena issues and suggestions is
> the Apache Jira [2].
>
>
>  Is there any other way to ID a statement with 'rdf:Id'?
>>
>
> Don't follow. In both your example outputs the statement is identified by
> rdf:Id. In the first one it is done by the reification syntactic short cut:
>
>
>  <dcterms:relation rdf:ID="relationship" rdf:resource="
>         http://localhost:8080/agent2"> ...
>
> In the second one there is an explicit reification:
>
>   <rdf:Statement rdf:ID="relationship"> ...
>
> Is there a reason you need to force one form over the other?  As noted
> above you could turn off the first form and so only get the second form if
> that is helpful.
>
> 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>
> [2] http://incubator.apache.org/**jena/help_and_support/bugs_**
> and_suggestions.html<http://incubator.apache.org/jena/help_and_support/bugs_and_suggestions.html>
>
>  Regards,
>> Srimanth
>>
>>
>> On Sun, Dec 25, 2011 at 12:46 PM, Dave Reynolds
>> <dave.e.reynolds@gmail.com <ma...@gmail.com>>>
>> 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<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://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#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://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://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://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://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://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://purl.org/dc/terms/**relation<http://purl.org/dc/terms/relation>>>
>> .
>>        <http://someserver/myapp#__**relationship<http://someserver/myapp#__relationship>
>>        <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://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://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://purl.org/dc/terms/**format<http://purl.org/dc/terms/format>
>> >>
>>        <http://formatsite.org/__**fileformat<http://formatsite.org/__fileformat>
>>
>>        <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://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://purl.org/dc/terms/**Agent <http://purl.org/dc/terms/Agent>>>
>> .
>>        <http://someserver/myapp#__**relationship<http://someserver/myapp#__relationship>
>>        <http://someserver/myapp#**relationship<http://someserver/myapp#relationship>
>> >>
>>        <http://purl.org/dc/terms/__**title<http://purl.org/dc/terms/__title><
>> http://purl.org/dc/terms/**title <http://purl.org/dc/terms/title>>>
>>        "My releationship" .
>>        <http://formatsite.org/__**fileformat<http://formatsite.org/__fileformat>
>>        <http://formatsite.org/**fileformat<http://formatsite.org/fileformat>
>> >>
>>        <http://purl.org/dc/terms/__**title<http://purl.org/dc/terms/__title>
>>        <http://purl.org/dc/terms/**title <http://purl.org/dc/terms/title>>>
>> "TXT" .
>>        <http://formatsite.org/__**fileformat<http://formatsite.org/__fileformat>
>>        <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://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://purl.org/dc/terms/**FileFormat<http://purl.org/dc/terms/FileFormat>>>
>> .
>>        ---------
>>        <http://someserver/myapp#__**relationship<http://someserver/myapp#__relationship>
>>        <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#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://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://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://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://localhost:8080/app/**agent2<http://localhost:8080/app/agent2>>>
>> .
>>        <http://someserver/myapp#__**relationship<http://someserver/myapp#__relationship>
>>        <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://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://purl.org/dc/terms/**relation<http://purl.org/dc/terms/relation>>>
>> .
>>        <http://someserver/myapp#__**relationship<http://someserver/myapp#__relationship>
>>        <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://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://localhost:8080/app/**agent1<http://localhost:8080/app/agent1>>>
>> .
>>        <http://someserver/myapp#__**relationship<http://someserver/myapp#__relationship>
>>        <http://someserver/myapp#**relationship<http://someserver/myapp#relationship>
>> >>
>>        <http://purl.org/dc/terms/__**title<http://purl.org/dc/terms/__title><
>> 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://localhost:8080/app/**agent1<http://localhost:8080/app/agent1>
>> >>
>>        <http://purl.org/dc/terms/__**relation<http://purl.org/dc/terms/__relation>
>>        <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/**agent2<http://localhost:8080/app/agent2>>>
>> .
>>        <http://localhost:8080/app/__**agent1<http://localhost:8080/app/__agent1>
>>        <http://localhost:8080/app/**agent1<http://localhost:8080/app/agent1>
>> >>
>>        <http://purl.org/dc/terms/__**format<http://purl.org/dc/terms/__format>
>>        <http://purl.org/dc/terms/**format<http://purl.org/dc/terms/format>
>> >>
>>        <http://formatsite.org/__**fileformat<http://formatsite.org/__fileformat>
>>        <http://formatsite.org/**fileformat<http://formatsite.org/fileformat>>>
>> .
>>        <http://localhost:8080/app/__**agent1<http://localhost:8080/app/__agent1>
>>        <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://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://purl.org/dc/terms/**Agent <http://purl.org/dc/terms/Agent>>>
>> .
>>        <http://formatsite.org/__**fileformat<http://formatsite.org/__fileformat>
>>        <http://formatsite.org/**fileformat<http://formatsite.org/fileformat>
>> >>
>>        <http://purl.org/dc/terms/__**title<http://purl.org/dc/terms/__title>
>>        <http://purl.org/dc/terms/**title <http://purl.org/dc/terms/title>>>
>> "TXT" .
>>        <http://formatsite.org/__**fileformat<http://formatsite.org/__fileformat>
>>        <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://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://purl.org/dc/terms/**FileFormat<http://purl.org/dc/terms/FileFormat>>>
>> .
>>        ---------
>>        ==============================**__===================
>>
>>
>>
>>        On Sat, Dec 24, 2011 at 8:24 AM, Dave Reynolds
>>        <dave.e.reynolds@gmail.com <ma...@gmail.com>
>> >
>>        <mailto:dave.e.reynolds@gmail.**__com
>>
>>        <mailto:dave.e.reynolds@gmail.**com <da...@gmail.com>>>>
>> 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>
>> >
>>
>>
>>        <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>
>> >
>>        <http://formatsite.org/__**fileformat<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#>
>> >
>>        <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>
>>        <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#>
>> >
>>        <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>
>>        <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>
>>
>>        <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>
>>
>>        <http://localhost:8080/app/**agent2<http://localhost:8080/app/agent2>
>> >>"/>
>>        <dcterms:format
>>        rdf:resource="http://__formats**__ite.org/fileformat<http://formats__ite.org/fileformat>
>>        <http://formatsite.org/**fileformat<http://formatsite.org/fileformat>
>> >
>>
>>        <http://formatsite.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>
>> >
>>        <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>
>>
>>        <http://localhost:8080/app/**agent2<http://localhost:8080/app/agent2>
>> >>"/>
>>        <dcterms:title>My releationship</dcterms:title>
>>        </rdf:Statement>
>>        </rdf:RDF>
>>                ---------
>>                ********************************____**************
>>
>>
>>
>>
>>
>>
>

Re: Different outputs when using Statement.createReifiedStatement()

Posted by Dave Reynolds <da...@gmail.com>.
On 26/12/2011 06:48, Srimanth Gunturi wrote:
> Hi Dave,
> Is there any workaround for this problem (calling internal API)?

What problem? I thought we had agreed both outputs correctly represents 
the RDF statements - which is the only guarantee the writer offers. They 
are "just" syntactic variants of each other.

As noted in my response on Sourceforge you could always use the 
non-ABBREV writer which will make things look more consistent - 
consistently ugly maybe :) but more consistent.

You can also, as explained in the IO HOW TO [1], switch off particular 
serialization rules. So you could switch off 
RDFSyntax.sectionReification to avoid the syntactic short cut kicking 
in, if that's the way round you want.

Note that the correct location for tracking jena issues and suggestions 
is the Apache Jira [2].

> Is there any other way to ID a statement with 'rdf:Id'?

Don't follow. In both your example outputs the statement is identified 
by rdf:Id. In the first one it is done by the reification syntactic 
short cut:

   <dcterms:relation rdf:ID="relationship" rdf:resource="
          http://localhost:8080/agent2"> ...

In the second one there is an explicit reification:

    <rdf:Statement rdf:ID="relationship"> ...

Is there a reason you need to force one form over the other?  As noted 
above you could turn off the first form and so only get the second form 
if that is helpful.

Dave

[1] 
http://incubator.apache.org/jena/documentation/io/iohowto.html#advanced_rdfxml_output
[2] 
http://incubator.apache.org/jena/help_and_support/bugs_and_suggestions.html

> Regards,
> Srimanth
>
>
> On Sun, Dec 25, 2011 at 12:46 PM, Dave Reynolds
> <dave.e.reynolds@gmail.com <ma...@gmail.com>> 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
>         <dave.e.reynolds@gmail.com <ma...@gmail.com>
>         <mailto:dave.e.reynolds@gmail.__com
>         <ma...@gmail.com>>> 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
>         <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>
>                 ---------
>                 ******************************____**************
>
>
>
>
>


Re: Different outputs when using Statement.createReifiedStatement()

Posted by Srimanth Gunturi <sr...@gmail.com>.
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
<da...@gmail.com>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
>> <dave.e.reynolds@gmail.com <ma...@gmail.com>>>
>> 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>
>>        ---------
>>        ********************************__**************
>>
>>
>>
>>
>

Re: Different outputs when using Statement.createReifiedStatement()

Posted by Srimanth Gunturi <sr...@gmail.com>.
https://sourceforge.net/tracker/?func=detail&aid=3465531&group_id=40417&atid=430288

Thanks for looking into this.
Regards,
Srimanth





On Sun, Dec 25, 2011 at 12:46 PM, Dave Reynolds
<da...@gmail.com>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
>> <dave.e.reynolds@gmail.com <ma...@gmail.com>>>
>> 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>
>>        ---------
>>        ********************************__**************
>>
>>
>>
>>
>

Re: Different outputs when using Statement.createReifiedStatement()

Posted by Dave Reynolds <da...@gmail.com>.
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>
> ---------
> ********************************************
>