Closed white-gecko closed 6 years ago
I could actually reproduce this bug, but it seems to be a problem with the liquid engine.
I went ahead and added the following line in the first line of sparql_query
def sparql_query(resource = nil, query)
Jekyll.logger.info "resource: #{resource}\nquery: #{query}"
the console result is:
resource: https://www.leds-projekt.de/lswt2018.html#dbpedia
query: SELECT ?room WHERE {?resourceUri <http://schema.org/location> ?room }
resource: https://www.leds-projekt.de/lswt2018.html#begruessung
query: SELECT ?room WHERE {<https://www.leds-projekt.de/lswt2018.html#dbpedia> <http://schema.org/location> ?room }
resource: https://www.leds-projekt.de/lswt2018.html#jekyllrdf
query: SELECT ?room WHERE {<https://www.leds-projekt.de/lswt2018.html#dbpedia> <http://schema.org/location> ?room }
resource: https://www.leds-projekt.de/lswt2018.html#keynotesoeren
query: SELECT ?room WHERE {<https://www.leds-projekt.de/lswt2018.html#dbpedia> <http://schema.org/location> ?room }
it seems like the query parameter is set only one time and after that liquid seems to refeed the same (edited) varaiable over and over.
I`m unsure what we can do about it.
But how is this possible, since we could show that the variable is changed in the scope outside of the filter method. And if I'm not completely wrong, it works for other filters to receive and compute different values. So where is the variable actually changing its value?
There is an easy way to force liquid to reinit the sparql string in each iteration, by using prepend
.
---
---
<?xml version="1.0" encoding="UTF-8"?>
<schedule>
{%- assign lswt = "<https://www.leds-projekt.de/lswt2018.html#event>" | rdf_get -%}
{%- assign results = lswt | sparql_query: "SELECT distinct ?subEvent WHERE {?resourceUri <http://schema.org/subEvent> ?subEvent }" -%}
{%- for row in results -%}
{% assign event = row.subEvent %}
<list name="{{ event }}">
{% assign query = "SELECT ?room WHERE {?resourceUri <http://schema.org/location> ?room }" | prepend: "" %}
{%- assign rooms = event | sparql_query: query -%}
{%- for row in rooms -%}
<event.location>{{ event | rdf_property: "<http://schema.org/location>" }}</event.location>
<row.room>{{row.room}}</row.room>
{% endfor %}
</list>
{% endfor %}
</schedule>
leads to
<?xml version="1.0" encoding="UTF-8"?>
<schedule>
<list name="https://www.leds-projekt.de/lswt2018.html#keynotesoeren">
<event.location>https://www.leds-projekt.de/lswt2018.html#vortragsraum</event.location>
<row.room>https://www.leds-projekt.de/lswt2018.html#vortragsraum</row.room>
</list>
<list name="https://www.leds-projekt.de/lswt2018.html#begruessung">
<event.location>https://www.leds-projekt.de/lswt2018.html#vortragsraum</event.location>
<row.room>https://www.leds-projekt.de/lswt2018.html#vortragsraum</row.room>
</list>
<list name="https://www.leds-projekt.de/lswt2018.html#dbpedia">
<event.location>https://www.leds-projekt.de/lswt2018.html#tutorialraum</event.location>
<row.room>https://www.leds-projekt.de/lswt2018.html#tutorialraum</row.room>
</list>
<list name="https://www.leds-projekt.de/lswt2018.html#jekyllrdf">
<event.location>https://www.leds-projekt.de/lswt2018.html#tutorialraum</event.location>
<row.room>https://www.leds-projekt.de/lswt2018.html#tutorialraum</row.room>
</list>
</schedule>
After realising this, the fix is a simple matter of working on a copy of the static string
The
sparql_query
filter does not bind the input to ?resourceUri.Template:
graph.ttl
Actual Output:
Expected Output