Java - SPARQL query rewriting through parsing Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Is Java “pass-by-reference” or “pass-by-value”?How do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?How do I parse a string to a float or int in Python?Iterate through a HashMapHow to parse JSON in JavaHow do you parse and process HTML/XML in PHP?Parse JSON in JavaScript?Creating a memory leak with Java
What is the purpose of the side handle on a hand ("eggbeater") drill?
Why does Java have support for time zone offsets with seconds precision?
Will I have to go through TSA security when I return to the US after preclearance in Atlanta?
Is there a verb for listening stealthily?
When speaking, how do you change your mind mid-sentence?
What do you call an IPA symbol that lacks a name (e.g. ɲ)?
Married in secret, can marital status in passport be changed at a later date?
Is there an efficient way for synchronising audio events real-time with LEDs using an MCU?
All ASCII characters with a given bit count
Coin Game with infinite paradox
Is Bran literally the world's memory?
Calculating the expected value of truncated normal
Why doesn't the university give past final exams' answers?
Why isn't everyone flabbergasted about Bran's "gift"?
What's the difference between using dependency injection with a container and using a service locator?
What to do with someone that cheated their way though university and a PhD program?
Suing a Police Officer Instead of the Police Department
What is ls Largest Number Formed by only moving two sticks in 508?
How to translate "red flag" into Spanish?
What is the evidence that custom checks in Northern Ireland are going to result in violence?
Protagonist's race is hidden - should I reveal it?
`FindRoot [ ]`::jsing: Encountered a singular Jacobian at a point...WHY
Translate text contents of an existing file from lower to upper case and copy to a new file
Has a Nobel Peace laureate ever been accused of war crimes?
Java - SPARQL query rewriting through parsing
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Is Java “pass-by-reference” or “pass-by-value”?How do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?How do I parse a string to a float or int in Python?Iterate through a HashMapHow to parse JSON in JavaHow do you parse and process HTML/XML in PHP?Parse JSON in JavaScript?Creating a memory leak with Java
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to use Jena or some other Java library to achieve some coding challenge (in this case a rewriting through post-order traversal). I am not asking a methodology to translate SPARQL to SQL query. I already have that.
I am currently trying to translate a given SPARQL query into an some other SQL query.
So far, I've used Jena parser, that given a SPARQL query, returns an ARQ tree representation, that can be traversed in post-order. This is exactly what I want to do.
The only problem is that the Walker, just walks through the tree. What I would like to do, is something like this (suppose I am going through a MINUS) :
String visit(OpMinus minus)
String l_res = minus.getLeft().visit();
String r_res = minus.getRight().visit();
/*
... do some stuff with the result ...
*/
String res = l_res + "MINUS (" + r_res + ")";
return res;
Jena's visitor however returns void, making this impossible. Is there another way of doing it, instead of copying the Walker and the Visitor code, in order to make it work the way I want ? Thank you.
I am not looking for a SPARQL-to-SQL direct translator, because I need to work with the tree elements.
java parsing jena
|
show 2 more comments
I am trying to use Jena or some other Java library to achieve some coding challenge (in this case a rewriting through post-order traversal). I am not asking a methodology to translate SPARQL to SQL query. I already have that.
I am currently trying to translate a given SPARQL query into an some other SQL query.
So far, I've used Jena parser, that given a SPARQL query, returns an ARQ tree representation, that can be traversed in post-order. This is exactly what I want to do.
The only problem is that the Walker, just walks through the tree. What I would like to do, is something like this (suppose I am going through a MINUS) :
String visit(OpMinus minus)
String l_res = minus.getLeft().visit();
String r_res = minus.getRight().visit();
/*
... do some stuff with the result ...
*/
String res = l_res + "MINUS (" + r_res + ")";
return res;
Jena's visitor however returns void, making this impossible. Is there another way of doing it, instead of copying the Walker and the Visitor code, in order to make it work the way I want ? Thank you.
I am not looking for a SPARQL-to-SQL direct translator, because I need to work with the tree elements.
java parsing jena
A walker does not return anything, butTransformerand theTransformclasses do.
– AKSW
Mar 22 at 17:35
Your question suggests a generalized translation, but that is not possible, because SPARQL and SQL have significant differences. Virtuoso performs such translations in different ways for different jobs. Translating "a given" (do you mean "any given" or "a specific"?) SPARQL query to "an equivalent" SQL query depends on the SQL schema(s), SQL dialects, SQL engines, and RDF ontology/ies in use, among other variables. So perhaps your question could be modified to include some mention of your target SQL backend(s), and more about your specific SPARQL query/ies?
– TallTed
Mar 22 at 21:04
@TallTed Yes, of course I am trying to translate only a fragment of sparql into some generic SQL dialect. This however was not the main purpose of the question. I am not trying to find a method to translate a given sparql query, but given this method I already have, I am trying to be able to do it via Jena or some other library without rewriting everything.
– Valerio Colitta
Mar 22 at 21:13
@AKSW This is an idea, I could investigate, even though it wouldn't be really a clean solution. Thank you though
– Valerio Colitta
Mar 22 at 21:14
So, your question isn't about SPARQL nor SQL nor translating between them, but about some specific Java and Jena (or other Java library) programming challenge... Please edit the title and the body to make this clearer! The larger context of your immediate question is good to include, but that context should not appear to be the main focus.
– TallTed
Mar 22 at 21:27
|
show 2 more comments
I am trying to use Jena or some other Java library to achieve some coding challenge (in this case a rewriting through post-order traversal). I am not asking a methodology to translate SPARQL to SQL query. I already have that.
I am currently trying to translate a given SPARQL query into an some other SQL query.
So far, I've used Jena parser, that given a SPARQL query, returns an ARQ tree representation, that can be traversed in post-order. This is exactly what I want to do.
The only problem is that the Walker, just walks through the tree. What I would like to do, is something like this (suppose I am going through a MINUS) :
String visit(OpMinus minus)
String l_res = minus.getLeft().visit();
String r_res = minus.getRight().visit();
/*
... do some stuff with the result ...
*/
String res = l_res + "MINUS (" + r_res + ")";
return res;
Jena's visitor however returns void, making this impossible. Is there another way of doing it, instead of copying the Walker and the Visitor code, in order to make it work the way I want ? Thank you.
I am not looking for a SPARQL-to-SQL direct translator, because I need to work with the tree elements.
java parsing jena
I am trying to use Jena or some other Java library to achieve some coding challenge (in this case a rewriting through post-order traversal). I am not asking a methodology to translate SPARQL to SQL query. I already have that.
I am currently trying to translate a given SPARQL query into an some other SQL query.
So far, I've used Jena parser, that given a SPARQL query, returns an ARQ tree representation, that can be traversed in post-order. This is exactly what I want to do.
The only problem is that the Walker, just walks through the tree. What I would like to do, is something like this (suppose I am going through a MINUS) :
String visit(OpMinus minus)
String l_res = minus.getLeft().visit();
String r_res = minus.getRight().visit();
/*
... do some stuff with the result ...
*/
String res = l_res + "MINUS (" + r_res + ")";
return res;
Jena's visitor however returns void, making this impossible. Is there another way of doing it, instead of copying the Walker and the Visitor code, in order to make it work the way I want ? Thank you.
I am not looking for a SPARQL-to-SQL direct translator, because I need to work with the tree elements.
java parsing jena
java parsing jena
edited Mar 22 at 21:54
TallTed
6,88521528
6,88521528
asked Mar 22 at 14:59
Valerio ColittaValerio Colitta
265
265
A walker does not return anything, butTransformerand theTransformclasses do.
– AKSW
Mar 22 at 17:35
Your question suggests a generalized translation, but that is not possible, because SPARQL and SQL have significant differences. Virtuoso performs such translations in different ways for different jobs. Translating "a given" (do you mean "any given" or "a specific"?) SPARQL query to "an equivalent" SQL query depends on the SQL schema(s), SQL dialects, SQL engines, and RDF ontology/ies in use, among other variables. So perhaps your question could be modified to include some mention of your target SQL backend(s), and more about your specific SPARQL query/ies?
– TallTed
Mar 22 at 21:04
@TallTed Yes, of course I am trying to translate only a fragment of sparql into some generic SQL dialect. This however was not the main purpose of the question. I am not trying to find a method to translate a given sparql query, but given this method I already have, I am trying to be able to do it via Jena or some other library without rewriting everything.
– Valerio Colitta
Mar 22 at 21:13
@AKSW This is an idea, I could investigate, even though it wouldn't be really a clean solution. Thank you though
– Valerio Colitta
Mar 22 at 21:14
So, your question isn't about SPARQL nor SQL nor translating between them, but about some specific Java and Jena (or other Java library) programming challenge... Please edit the title and the body to make this clearer! The larger context of your immediate question is good to include, but that context should not appear to be the main focus.
– TallTed
Mar 22 at 21:27
|
show 2 more comments
A walker does not return anything, butTransformerand theTransformclasses do.
– AKSW
Mar 22 at 17:35
Your question suggests a generalized translation, but that is not possible, because SPARQL and SQL have significant differences. Virtuoso performs such translations in different ways for different jobs. Translating "a given" (do you mean "any given" or "a specific"?) SPARQL query to "an equivalent" SQL query depends on the SQL schema(s), SQL dialects, SQL engines, and RDF ontology/ies in use, among other variables. So perhaps your question could be modified to include some mention of your target SQL backend(s), and more about your specific SPARQL query/ies?
– TallTed
Mar 22 at 21:04
@TallTed Yes, of course I am trying to translate only a fragment of sparql into some generic SQL dialect. This however was not the main purpose of the question. I am not trying to find a method to translate a given sparql query, but given this method I already have, I am trying to be able to do it via Jena or some other library without rewriting everything.
– Valerio Colitta
Mar 22 at 21:13
@AKSW This is an idea, I could investigate, even though it wouldn't be really a clean solution. Thank you though
– Valerio Colitta
Mar 22 at 21:14
So, your question isn't about SPARQL nor SQL nor translating between them, but about some specific Java and Jena (or other Java library) programming challenge... Please edit the title and the body to make this clearer! The larger context of your immediate question is good to include, but that context should not appear to be the main focus.
– TallTed
Mar 22 at 21:27
A walker does not return anything, but
Transformer and the Transform classes do.– AKSW
Mar 22 at 17:35
A walker does not return anything, but
Transformer and the Transform classes do.– AKSW
Mar 22 at 17:35
Your question suggests a generalized translation, but that is not possible, because SPARQL and SQL have significant differences. Virtuoso performs such translations in different ways for different jobs. Translating "a given" (do you mean "any given" or "a specific"?) SPARQL query to "an equivalent" SQL query depends on the SQL schema(s), SQL dialects, SQL engines, and RDF ontology/ies in use, among other variables. So perhaps your question could be modified to include some mention of your target SQL backend(s), and more about your specific SPARQL query/ies?
– TallTed
Mar 22 at 21:04
Your question suggests a generalized translation, but that is not possible, because SPARQL and SQL have significant differences. Virtuoso performs such translations in different ways for different jobs. Translating "a given" (do you mean "any given" or "a specific"?) SPARQL query to "an equivalent" SQL query depends on the SQL schema(s), SQL dialects, SQL engines, and RDF ontology/ies in use, among other variables. So perhaps your question could be modified to include some mention of your target SQL backend(s), and more about your specific SPARQL query/ies?
– TallTed
Mar 22 at 21:04
@TallTed Yes, of course I am trying to translate only a fragment of sparql into some generic SQL dialect. This however was not the main purpose of the question. I am not trying to find a method to translate a given sparql query, but given this method I already have, I am trying to be able to do it via Jena or some other library without rewriting everything.
– Valerio Colitta
Mar 22 at 21:13
@TallTed Yes, of course I am trying to translate only a fragment of sparql into some generic SQL dialect. This however was not the main purpose of the question. I am not trying to find a method to translate a given sparql query, but given this method I already have, I am trying to be able to do it via Jena or some other library without rewriting everything.
– Valerio Colitta
Mar 22 at 21:13
@AKSW This is an idea, I could investigate, even though it wouldn't be really a clean solution. Thank you though
– Valerio Colitta
Mar 22 at 21:14
@AKSW This is an idea, I could investigate, even though it wouldn't be really a clean solution. Thank you though
– Valerio Colitta
Mar 22 at 21:14
So, your question isn't about SPARQL nor SQL nor translating between them, but about some specific Java and Jena (or other Java library) programming challenge... Please edit the title and the body to make this clearer! The larger context of your immediate question is good to include, but that context should not appear to be the main focus.
– TallTed
Mar 22 at 21:27
So, your question isn't about SPARQL nor SQL nor translating between them, but about some specific Java and Jena (or other Java library) programming challenge... Please edit the title and the body to make this clearer! The larger context of your immediate question is good to include, but that context should not appear to be the main focus.
– TallTed
Mar 22 at 21:27
|
show 2 more comments
1 Answer
1
active
oldest
votes
I eventually solved the problem by implementing my own Walker (since anything I am looking for is implemented in Jena) that traverses the tree in post-order and returns Strings
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302436%2fjava-sparql-query-rewriting-through-parsing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I eventually solved the problem by implementing my own Walker (since anything I am looking for is implemented in Jena) that traverses the tree in post-order and returns Strings
add a comment |
I eventually solved the problem by implementing my own Walker (since anything I am looking for is implemented in Jena) that traverses the tree in post-order and returns Strings
add a comment |
I eventually solved the problem by implementing my own Walker (since anything I am looking for is implemented in Jena) that traverses the tree in post-order and returns Strings
I eventually solved the problem by implementing my own Walker (since anything I am looking for is implemented in Jena) that traverses the tree in post-order and returns Strings
answered Mar 23 at 21:08
Valerio ColittaValerio Colitta
265
265
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302436%2fjava-sparql-query-rewriting-through-parsing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
A walker does not return anything, but
Transformerand theTransformclasses do.– AKSW
Mar 22 at 17:35
Your question suggests a generalized translation, but that is not possible, because SPARQL and SQL have significant differences. Virtuoso performs such translations in different ways for different jobs. Translating "a given" (do you mean "any given" or "a specific"?) SPARQL query to "an equivalent" SQL query depends on the SQL schema(s), SQL dialects, SQL engines, and RDF ontology/ies in use, among other variables. So perhaps your question could be modified to include some mention of your target SQL backend(s), and more about your specific SPARQL query/ies?
– TallTed
Mar 22 at 21:04
@TallTed Yes, of course I am trying to translate only a fragment of sparql into some generic SQL dialect. This however was not the main purpose of the question. I am not trying to find a method to translate a given sparql query, but given this method I already have, I am trying to be able to do it via Jena or some other library without rewriting everything.
– Valerio Colitta
Mar 22 at 21:13
@AKSW This is an idea, I could investigate, even though it wouldn't be really a clean solution. Thank you though
– Valerio Colitta
Mar 22 at 21:14
So, your question isn't about SPARQL nor SQL nor translating between them, but about some specific Java and Jena (or other Java library) programming challenge... Please edit the title and the body to make this clearer! The larger context of your immediate question is good to include, but that context should not appear to be the main focus.
– TallTed
Mar 22 at 21:27