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
<[email protected] <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>",
        DCTerms.FileFormat);
        fileFormat.addProperty(__DCTerms.title, "TXT");
        agent.addProperty(DCTerms.__format, fileFormat);
        agent.addProperty(DCTerms.__relation,
        model.createResource(__serverURL+"/agent2"));
        ReifiedStatement rs =
        
agent.getProperty(DCTerms.__relation).__createReifiedStatement(__someBase+"#relationship");
        rs.addProperty(DCTerms.title, "My releationship");
        model.getWriter("RDF/XML-__ABBREV").setProperty("__prettyTypes", new
        Resource[]{DCTerms.Agent});
        model.write(System.out, "RDF/XML-ABBREV", someBase);
        //model.write(System.out, "N-TRIPLE", someBase);

        }
        }
        ==============================__===================

        Turtle output:
        ==============================__===================
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#type
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#Statement
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement>> .
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#object
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#object>>
        <http://localhost:8080/agent2> .
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#predicate
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate>>
        <http://purl.org/dc/terms/__relation
        <http://purl.org/dc/terms/relation>> .
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#subject
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject>>
        <http://localhost:8080/agent1> .
        <http://localhost:8080/agent1>
        <http://purl.org/dc/terms/__relation
        <http://purl.org/dc/terms/relation>>
        <http://localhost:8080/agent2> .
        <http://localhost:8080/agent1>
        <http://purl.org/dc/terms/__format
        <http://purl.org/dc/terms/format>>
        <http://formatsite.org/__fileformat
        <http://formatsite.org/fileformat>> .
        <http://localhost:8080/agent1>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#type
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>
        <http://purl.org/dc/terms/__Agent
        <http://purl.org/dc/terms/Agent>> .
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://purl.org/dc/terms/__title <http://purl.org/dc/terms/title>>
        "My releationship" .
        <http://formatsite.org/__fileformat
        <http://formatsite.org/fileformat>>
        <http://purl.org/dc/terms/__title
        <http://purl.org/dc/terms/title>> "TXT" .
        <http://formatsite.org/__fileformat
        <http://formatsite.org/fileformat>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#type
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>
        <http://purl.org/dc/terms/__FileFormat
        <http://purl.org/dc/terms/FileFormat>> .
        ---------
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#type
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#Statement
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement>> .
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#object
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#object>>
        <http://localhost:8080/app/__agent2
        <http://localhost:8080/app/agent2>> .
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#predicate
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate>>
        <http://purl.org/dc/terms/__relation
        <http://purl.org/dc/terms/relation>> .
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#subject
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject>>
        <http://localhost:8080/app/__agent1
        <http://localhost:8080/app/agent1>> .
        <http://someserver/myapp#__relationship
        <http://someserver/myapp#relationship>>
        <http://purl.org/dc/terms/__title <http://purl.org/dc/terms/title>>
        "My releationship" .
        <http://localhost:8080/app/__agent1
        <http://localhost:8080/app/agent1>>
        <http://purl.org/dc/terms/__relation
        <http://purl.org/dc/terms/relation>>
        <http://localhost:8080/app/__agent2
        <http://localhost:8080/app/agent2>> .
        <http://localhost:8080/app/__agent1
        <http://localhost:8080/app/agent1>>
        <http://purl.org/dc/terms/__format
        <http://purl.org/dc/terms/format>>
        <http://formatsite.org/__fileformat
        <http://formatsite.org/fileformat>> .
        <http://localhost:8080/app/__agent1
        <http://localhost:8080/app/agent1>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#type
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>
        <http://purl.org/dc/terms/__Agent
        <http://purl.org/dc/terms/Agent>> .
        <http://formatsite.org/__fileformat
        <http://formatsite.org/fileformat>>
        <http://purl.org/dc/terms/__title
        <http://purl.org/dc/terms/title>> "TXT" .
        <http://formatsite.org/__fileformat
        <http://formatsite.org/fileformat>>
        <http://www.w3.org/1999/02/22-__rdf-syntax-ns#type
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>
        <http://purl.org/dc/terms/__FileFormat
        <http://purl.org/dc/terms/FileFormat>> .
        ---------
        ==============================__===================


        On Sat, Dec 24, 2011 at 8:24 AM, Dave Reynolds
        <[email protected] <mailto:[email protected]>
        <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>>


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






Reply via email to