Jena export: Nesting elements or adding Description












2















I want to export my jena database in file and when i use RDF/XML i am getting the objects with rdf:Description. When i use RDF/XML-ABBREV i am getting my objects with correct tag but they are nested.



dataset = TDBFactory.createDataset("C:\Users\PC\Desktop\db\");
Model model = dataset.getDefaultModel();

outputPath ="C:\Users\PC\Desktop\file.xml";
writer = new FileWriter(outputPath);
model.write(writer, "RDF/XML-ABBREV");


So, can anyone tell me how to fix this problem..



I tried with this but here is the response:



If i use:



RDFDataMgr.write(System.out, model, RDFFormat.RDFXML_PRETTY);


then it gives the prefixes fine but the objects are nested:



<cim:VoltageLevel rdf:about="urn:uuid:0#_2ecd8d06-9088-4adc-8800-80d5e73c1b94">
<cim:IdentifiedObject.name>Domžale 20kV</cim:IdentifiedObject.name>
<cim:VoltageLevel.BaseVoltage>
<cim:BaseVoltage rdf:about="urn:uuid:0#_5132f6db-1342-4f27-b701-2c446aba1590">
<cim:IdentifiedObject.name>20kV</cim:IdentifiedObject.name>
<cim:BaseVoltage.nominalVoltage>20000</cim:BaseVoltage.nominalVoltage>
</cim:BaseVoltage>
</cim:VoltageLevel.BaseVoltage>
<cim:VoltageLevel.highVoltageLimit>22000</cim:VoltageLevel.highVoltageLimit>
<cim:VoltageLevel.lowVoltageLimit>18000</cim:VoltageLevel.lowVoltageLimit>
<cim:VoltageLevel.Substation>
<cim:Substation rdf:about="urn:uuid:0#_dc3cd19e-3ea5-4f61-89db-656ee1b8684a">
<cim:IdentifiedObject.name>RTP Domžale</cim:IdentifiedObject.name>
<cim:Substation.Region rdf:resource="urn:uuid:0#_ee169401-9cef-417d-b01e-db2f9d3ce98b"/>
</cim:Substation>
</cim:VoltageLevel.Substation>




If i use



model.write(System.out, "RDF/XML");


i am getting the objects like i want but instead of Description i want there to be the correct tags:



  <rdf:Description rdf:about="urn:uuid:0#_2ecd8d06-9088-4adc-8800-80d5e73c1b94">
<cim:IdentifiedObject.name>Domžale 20kV</cim:IdentifiedObject.name>
<rdf:type rdf:resource="http://iec.ch/TC57/2013/CIM-schema-cim16#VoltageLevel"/>
<cim:VoltageLevel.BaseVoltage rdf:resource="urn:uuid:0#_5132f6db-1342-4f27-b701-2c446aba1590"/>
<cim:VoltageLevel.highVoltageLimit>22000</cim:VoltageLevel.highVoltageLimit>
<cim:VoltageLevel.lowVoltageLimit>18000</cim:VoltageLevel.lowVoltageLimit>
<cim:VoltageLevel.Substation rdf:resource="urn:uuid:0#_dc3cd19e-3ea5-4f61-89db-656ee1b8684a"/>
</rdf:Description>









share|improve this question

























  • See stackoverflow.com/questions/53439861/… for how to write with a different variation of RDF/XML.

    – AndyS
    Nov 27 '18 at 21:45






  • 1





    I edited my question

    – Bambus
    Nov 28 '18 at 8:57











  • By "correct tags", you mean the RDF type as the outer tag? See options for RDF/XMl output jena.apache.org/documentation/io/… or you may need to use XSLT. The role of writing RDf/XMl isn't to produce output for an arbitrary XML schema, it's to produce RDF. Some times, it will need post-processing.

    – AndyS
    Nov 28 '18 at 10:45
















2















I want to export my jena database in file and when i use RDF/XML i am getting the objects with rdf:Description. When i use RDF/XML-ABBREV i am getting my objects with correct tag but they are nested.



dataset = TDBFactory.createDataset("C:\Users\PC\Desktop\db\");
Model model = dataset.getDefaultModel();

outputPath ="C:\Users\PC\Desktop\file.xml";
writer = new FileWriter(outputPath);
model.write(writer, "RDF/XML-ABBREV");


So, can anyone tell me how to fix this problem..



I tried with this but here is the response:



If i use:



RDFDataMgr.write(System.out, model, RDFFormat.RDFXML_PRETTY);


then it gives the prefixes fine but the objects are nested:



<cim:VoltageLevel rdf:about="urn:uuid:0#_2ecd8d06-9088-4adc-8800-80d5e73c1b94">
<cim:IdentifiedObject.name>Domžale 20kV</cim:IdentifiedObject.name>
<cim:VoltageLevel.BaseVoltage>
<cim:BaseVoltage rdf:about="urn:uuid:0#_5132f6db-1342-4f27-b701-2c446aba1590">
<cim:IdentifiedObject.name>20kV</cim:IdentifiedObject.name>
<cim:BaseVoltage.nominalVoltage>20000</cim:BaseVoltage.nominalVoltage>
</cim:BaseVoltage>
</cim:VoltageLevel.BaseVoltage>
<cim:VoltageLevel.highVoltageLimit>22000</cim:VoltageLevel.highVoltageLimit>
<cim:VoltageLevel.lowVoltageLimit>18000</cim:VoltageLevel.lowVoltageLimit>
<cim:VoltageLevel.Substation>
<cim:Substation rdf:about="urn:uuid:0#_dc3cd19e-3ea5-4f61-89db-656ee1b8684a">
<cim:IdentifiedObject.name>RTP Domžale</cim:IdentifiedObject.name>
<cim:Substation.Region rdf:resource="urn:uuid:0#_ee169401-9cef-417d-b01e-db2f9d3ce98b"/>
</cim:Substation>
</cim:VoltageLevel.Substation>




If i use



model.write(System.out, "RDF/XML");


i am getting the objects like i want but instead of Description i want there to be the correct tags:



  <rdf:Description rdf:about="urn:uuid:0#_2ecd8d06-9088-4adc-8800-80d5e73c1b94">
<cim:IdentifiedObject.name>Domžale 20kV</cim:IdentifiedObject.name>
<rdf:type rdf:resource="http://iec.ch/TC57/2013/CIM-schema-cim16#VoltageLevel"/>
<cim:VoltageLevel.BaseVoltage rdf:resource="urn:uuid:0#_5132f6db-1342-4f27-b701-2c446aba1590"/>
<cim:VoltageLevel.highVoltageLimit>22000</cim:VoltageLevel.highVoltageLimit>
<cim:VoltageLevel.lowVoltageLimit>18000</cim:VoltageLevel.lowVoltageLimit>
<cim:VoltageLevel.Substation rdf:resource="urn:uuid:0#_dc3cd19e-3ea5-4f61-89db-656ee1b8684a"/>
</rdf:Description>









share|improve this question

























  • See stackoverflow.com/questions/53439861/… for how to write with a different variation of RDF/XML.

    – AndyS
    Nov 27 '18 at 21:45






  • 1





    I edited my question

    – Bambus
    Nov 28 '18 at 8:57











  • By "correct tags", you mean the RDF type as the outer tag? See options for RDF/XMl output jena.apache.org/documentation/io/… or you may need to use XSLT. The role of writing RDf/XMl isn't to produce output for an arbitrary XML schema, it's to produce RDF. Some times, it will need post-processing.

    – AndyS
    Nov 28 '18 at 10:45














2












2








2








I want to export my jena database in file and when i use RDF/XML i am getting the objects with rdf:Description. When i use RDF/XML-ABBREV i am getting my objects with correct tag but they are nested.



dataset = TDBFactory.createDataset("C:\Users\PC\Desktop\db\");
Model model = dataset.getDefaultModel();

outputPath ="C:\Users\PC\Desktop\file.xml";
writer = new FileWriter(outputPath);
model.write(writer, "RDF/XML-ABBREV");


So, can anyone tell me how to fix this problem..



I tried with this but here is the response:



If i use:



RDFDataMgr.write(System.out, model, RDFFormat.RDFXML_PRETTY);


then it gives the prefixes fine but the objects are nested:



<cim:VoltageLevel rdf:about="urn:uuid:0#_2ecd8d06-9088-4adc-8800-80d5e73c1b94">
<cim:IdentifiedObject.name>Domžale 20kV</cim:IdentifiedObject.name>
<cim:VoltageLevel.BaseVoltage>
<cim:BaseVoltage rdf:about="urn:uuid:0#_5132f6db-1342-4f27-b701-2c446aba1590">
<cim:IdentifiedObject.name>20kV</cim:IdentifiedObject.name>
<cim:BaseVoltage.nominalVoltage>20000</cim:BaseVoltage.nominalVoltage>
</cim:BaseVoltage>
</cim:VoltageLevel.BaseVoltage>
<cim:VoltageLevel.highVoltageLimit>22000</cim:VoltageLevel.highVoltageLimit>
<cim:VoltageLevel.lowVoltageLimit>18000</cim:VoltageLevel.lowVoltageLimit>
<cim:VoltageLevel.Substation>
<cim:Substation rdf:about="urn:uuid:0#_dc3cd19e-3ea5-4f61-89db-656ee1b8684a">
<cim:IdentifiedObject.name>RTP Domžale</cim:IdentifiedObject.name>
<cim:Substation.Region rdf:resource="urn:uuid:0#_ee169401-9cef-417d-b01e-db2f9d3ce98b"/>
</cim:Substation>
</cim:VoltageLevel.Substation>




If i use



model.write(System.out, "RDF/XML");


i am getting the objects like i want but instead of Description i want there to be the correct tags:



  <rdf:Description rdf:about="urn:uuid:0#_2ecd8d06-9088-4adc-8800-80d5e73c1b94">
<cim:IdentifiedObject.name>Domžale 20kV</cim:IdentifiedObject.name>
<rdf:type rdf:resource="http://iec.ch/TC57/2013/CIM-schema-cim16#VoltageLevel"/>
<cim:VoltageLevel.BaseVoltage rdf:resource="urn:uuid:0#_5132f6db-1342-4f27-b701-2c446aba1590"/>
<cim:VoltageLevel.highVoltageLimit>22000</cim:VoltageLevel.highVoltageLimit>
<cim:VoltageLevel.lowVoltageLimit>18000</cim:VoltageLevel.lowVoltageLimit>
<cim:VoltageLevel.Substation rdf:resource="urn:uuid:0#_dc3cd19e-3ea5-4f61-89db-656ee1b8684a"/>
</rdf:Description>









share|improve this question
















I want to export my jena database in file and when i use RDF/XML i am getting the objects with rdf:Description. When i use RDF/XML-ABBREV i am getting my objects with correct tag but they are nested.



dataset = TDBFactory.createDataset("C:\Users\PC\Desktop\db\");
Model model = dataset.getDefaultModel();

outputPath ="C:\Users\PC\Desktop\file.xml";
writer = new FileWriter(outputPath);
model.write(writer, "RDF/XML-ABBREV");


So, can anyone tell me how to fix this problem..



I tried with this but here is the response:



If i use:



RDFDataMgr.write(System.out, model, RDFFormat.RDFXML_PRETTY);


then it gives the prefixes fine but the objects are nested:



<cim:VoltageLevel rdf:about="urn:uuid:0#_2ecd8d06-9088-4adc-8800-80d5e73c1b94">
<cim:IdentifiedObject.name>Domžale 20kV</cim:IdentifiedObject.name>
<cim:VoltageLevel.BaseVoltage>
<cim:BaseVoltage rdf:about="urn:uuid:0#_5132f6db-1342-4f27-b701-2c446aba1590">
<cim:IdentifiedObject.name>20kV</cim:IdentifiedObject.name>
<cim:BaseVoltage.nominalVoltage>20000</cim:BaseVoltage.nominalVoltage>
</cim:BaseVoltage>
</cim:VoltageLevel.BaseVoltage>
<cim:VoltageLevel.highVoltageLimit>22000</cim:VoltageLevel.highVoltageLimit>
<cim:VoltageLevel.lowVoltageLimit>18000</cim:VoltageLevel.lowVoltageLimit>
<cim:VoltageLevel.Substation>
<cim:Substation rdf:about="urn:uuid:0#_dc3cd19e-3ea5-4f61-89db-656ee1b8684a">
<cim:IdentifiedObject.name>RTP Domžale</cim:IdentifiedObject.name>
<cim:Substation.Region rdf:resource="urn:uuid:0#_ee169401-9cef-417d-b01e-db2f9d3ce98b"/>
</cim:Substation>
</cim:VoltageLevel.Substation>




If i use



model.write(System.out, "RDF/XML");


i am getting the objects like i want but instead of Description i want there to be the correct tags:



  <rdf:Description rdf:about="urn:uuid:0#_2ecd8d06-9088-4adc-8800-80d5e73c1b94">
<cim:IdentifiedObject.name>Domžale 20kV</cim:IdentifiedObject.name>
<rdf:type rdf:resource="http://iec.ch/TC57/2013/CIM-schema-cim16#VoltageLevel"/>
<cim:VoltageLevel.BaseVoltage rdf:resource="urn:uuid:0#_5132f6db-1342-4f27-b701-2c446aba1590"/>
<cim:VoltageLevel.highVoltageLimit>22000</cim:VoltageLevel.highVoltageLimit>
<cim:VoltageLevel.lowVoltageLimit>18000</cim:VoltageLevel.lowVoltageLimit>
<cim:VoltageLevel.Substation rdf:resource="urn:uuid:0#_dc3cd19e-3ea5-4f61-89db-656ee1b8684a"/>
</rdf:Description>






java jena






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 8:57







Bambus

















asked Nov 27 '18 at 11:58









BambusBambus

688517




688517













  • See stackoverflow.com/questions/53439861/… for how to write with a different variation of RDF/XML.

    – AndyS
    Nov 27 '18 at 21:45






  • 1





    I edited my question

    – Bambus
    Nov 28 '18 at 8:57











  • By "correct tags", you mean the RDF type as the outer tag? See options for RDF/XMl output jena.apache.org/documentation/io/… or you may need to use XSLT. The role of writing RDf/XMl isn't to produce output for an arbitrary XML schema, it's to produce RDF. Some times, it will need post-processing.

    – AndyS
    Nov 28 '18 at 10:45



















  • See stackoverflow.com/questions/53439861/… for how to write with a different variation of RDF/XML.

    – AndyS
    Nov 27 '18 at 21:45






  • 1





    I edited my question

    – Bambus
    Nov 28 '18 at 8:57











  • By "correct tags", you mean the RDF type as the outer tag? See options for RDF/XMl output jena.apache.org/documentation/io/… or you may need to use XSLT. The role of writing RDf/XMl isn't to produce output for an arbitrary XML schema, it's to produce RDF. Some times, it will need post-processing.

    – AndyS
    Nov 28 '18 at 10:45

















See stackoverflow.com/questions/53439861/… for how to write with a different variation of RDF/XML.

– AndyS
Nov 27 '18 at 21:45





See stackoverflow.com/questions/53439861/… for how to write with a different variation of RDF/XML.

– AndyS
Nov 27 '18 at 21:45




1




1





I edited my question

– Bambus
Nov 28 '18 at 8:57





I edited my question

– Bambus
Nov 28 '18 at 8:57













By "correct tags", you mean the RDF type as the outer tag? See options for RDF/XMl output jena.apache.org/documentation/io/… or you may need to use XSLT. The role of writing RDf/XMl isn't to produce output for an arbitrary XML schema, it's to produce RDF. Some times, it will need post-processing.

– AndyS
Nov 28 '18 at 10:45





By "correct tags", you mean the RDF type as the outer tag? See options for RDF/XMl output jena.apache.org/documentation/io/… or you may need to use XSLT. The role of writing RDf/XMl isn't to produce output for an arbitrary XML schema, it's to produce RDF. Some times, it will need post-processing.

– AndyS
Nov 28 '18 at 10:45












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53499192%2fjena-export-nesting-elements-or-adding-description%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53499192%2fjena-export-nesting-elements-or-adding-description%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks