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
<[email protected] <mailto:[email protected]>> 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
<[email protected] <mailto:[email protected]>
<mailto:dave.e.reynolds@gmail.__com
<mailto:[email protected]>>> wrote:
On 25/12/2011 04:59, Srimanth Gunturi wrote:
Hi Dave,
Thanks for the response.
'prettyTypes' property did not help.
Oh well.
In turtle the model is identical.
Fine, so there is indeed no bug.
However the ordering of the statements
change.
The order is irrelevant.
I think this has some significance, as in
the com.hp.hpl.jena.xmloutput.____impl.Unparser when it
tries to
figure out
which are the top level subjects - it comes up with
different
outputs
based on the order in which it iterates the statements.
This in-turn
happens due the different URL values passed in.
Yes, what Pretty Types is supposed to do is bias the choice
of top
levels.
Dave
Regards,
Srimanth
==============================____==============
public class JenaReifiedProblem {
private static final String someBase =
"http://someserver/myapp";
public static void main(String[] args) {
generate1("http://localhost:____8080
<http://localhost:8080>");
System.out.println("---------"____);
generate1("http://localhost:____8080/app
<http://localhost:8080/app>");
System.out.println("---------"____);
}
public static void generate1(String serverURL) {
Model model = ModelFactory.____createDefaultModel();
model.setNsPrefix("dcterms", DCTerms.NS);
Resource agent =
model.createResource(____serverURL+"/agent1",
DCTerms.Agent);
Resource fileFormat =
model.createResource("http://____formatsite.org/fileformat
<http://formatsite.org/fileformat>
<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
<[email protected] <mailto:[email protected]>
<mailto:dave.e.reynolds@gmail.__com
<mailto:[email protected]>>
<mailto:dave.e.reynolds@gmail.
<mailto:dave.e.reynolds@gmail.>____com
<mailto:dave.e.reynolds@gmail.__com
<mailto:[email protected]>>>> wrote:
On 23/12/2011 07:30, Srimanth Gunturi wrote:
Hello,
I have a model which contains a reified statement.
Depending on
what URLs I
use for resources, I get different outputs.
I would be thankful if someone could explain if this
behavior is
valid or a
bug.
Just looking at the outputs they both look correct.
In the first
case the writer has chosen an order which allowed it
to use the
"rdf:ID" shortcut on the reified statement, in the second case it
has used the full syntax.
The way to double check would be to convert both
outputs to
Turtle,
which doesn't have a shortcut syntactic form for
reification, and
compare those outputs.
You can tune the serialization a little if you need
to, for
example
setting to dcterms:Agent to be a "pretty type" would
encourage the
first form of output. See [1].
Dave
[1]
http://incubator.apache.org/______jena/documentation/io/__iohowto.____html#advanced___rdfxml_output
<http://incubator.apache.org/____jena/documentation/io/iohowto.____html#advanced_rdfxml_output>
<http://incubator.apache.org/____jena/documentation/io/__iohowto.__html#advanced___rdfxml_output
<http://incubator.apache.org/__jena/documentation/io/iohowto.__html#advanced_rdfxml_output>>
<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>
---------
******************************______**************