Skip to content

Commit

Permalink
Reproduce issue #154
Browse files Browse the repository at this point in the history
  • Loading branch information
enridaga committed Nov 24, 2021
1 parent df64f0c commit 5911d22
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import org.apache.jena.query.ResultSet;
import org.apache.jena.query.ResultSetFormatter;
import org.apache.jena.query.Syntax;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.engine.main.QC;
import org.junit.Assert;
import org.junit.Ignore;
Expand Down Expand Up @@ -196,4 +198,23 @@ public void testIssue114() throws IOException, URISyntaxException {
assertEquals(Sets.newHashSet("b", "d", "c"), slots);
}

/**
* See https://github.com/SPARQL-Anything/sparql.anything/issues/154
*
* @throws URISyntaxException
* @throws IOException
*/
@Ignore
@Test
public void testIssue154() throws URISyntaxException, IOException {
String queryStr = IOUtils.toString(getClass().getClassLoader().getResource("issues/e.sparql").toURI(), StandardCharsets.UTF_8);
String location = getClass().getClassLoader().getResource("issues/a00002-1036.xml").toURI().toString();
Query query = QueryFactory.create(queryStr.replace("%%LOCATION%%", location));
Dataset ds = DatasetFactory.createGeneral();
QC.setFactory(ARQ.getContext(), FacadeX.ExecutorFactory);
// XXX This process never ends!
Model rs = QueryExecutionFactory.create(query, ds).execConstruct();
rs.write(System.err, "TTL");
}

}
93 changes: 93 additions & 0 deletions sparql-anything-it/src/test/resources/issues/a00002-1036.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<artwork>
<acno>A00002</acno>
<acquisitionYear>1922</acquisitionYear>
<creator>
<name>Robert Blake</name>
<birthYear>1762</birthYear>
<gender>Male</gender>
<id>38</id>
</creator>
<creditLine>Presented by Mrs John Richmond 1992</creditLine>
<height>213</height>
<id>1036</id>
<medium>Graphite on paper</medium>
<topics>
<children>
<children>
<children>
<item>
<id>273</id>
<name>comforting</name>
</item>
<item>
<id>544</id>
<name>embracing</name>
</item>
<item>
<id>2653</id>
<name>recoiling</name>
</item>
</children>
<item>
<id>177</id>
<name>actions: expressive</name>
</item>
</children>
<children>
<children>
<item>
<id>451</id>
<name>figure</name>
</item>
</children>
<item>
<id>95</id>
<name>adults</name>
</item>
</children>
<children>
<children>
<item>
<id>799</id>
<name>group</name>
</item>
</children>
<item>
<id>97</id>
<name>groups</name>
</item>
</children>
<item>
<id>91</id>
<name>people</name>
</item>
</children>
<children>
<children>
<children>
<item>
<id>2815</id>
<name>fear</name>
</item>
</children>
<item>
<id>31</id>
<name>emotions and human qualities</name>
</item>
</children>
<item>
<id>29</id>
<name>emotions, concepts and ideas</name>
</item>
</children>
<item>
<id>1</id>
<name>topicRoot</name>
</item>
</topics>
<title>Two Drawings of Frightened Figures, Probably for 'The Approach of Doom'</title>
<units>mm</units>
<url>https://www.tate.org.uk/art/artworks/blake-two-drawings-of-frightened-figures-probably-for-the-approach-of-doom-a00002</url>
<width>311</width>
</artwork>

24 changes: 24 additions & 0 deletions sparql-anything-it/src/test/resources/issues/e.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX tsub: <http://sparql.xyz/example/tate/topic/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

CONSTRUCT {
?artwork schema:about ?topic .
?topic schema:name ?name .
} WHERE {
SERVICE <x-sparql-anything:location=%%LOCATION%%> {
# [ a xyz:children; fx:anySlot [a xyz:item; fx:anySlot [ a xyz:id; rdf:_1 ?topicId]; fx:anySlot [ a xyz:name; rdf:_1 ?name ] ] ] .
# [ a xyz:children; ?li1 [a xyz:item; ?li2 [ a xyz:id; ?li3 ?topicId]; ?li4 [ a xyz:name; ?li5 ?name ] ] ] .
[] a xyz:children; fx:anySlot [a xyz:item; fx:anySlot [ a xyz:id; fx:anySlot ?topicId]; fx:anySlot [ a xyz:name; fx:anySlot ?name ]] .
# [] a xyz:children; ?li1 [a xyz:item; ?li2 [ a xyz:id; ?li3 ?topicId]; ?li4 [ a xyz:name; ?li5 ?name ]] .
[] a xyz:url; fx:anySlot ?artworkUrl .
BIND(IRI(?artworkUrl) as ?artwork) .
BIND(IRI(CONCAT(STR(tsub:),STR(?topicId))) AS ?topic) .
FILTER (?topicId != xyz:id) .
FILTER (?name != xyz:name) .
FILTER (?artworkUrl != xyz:url) .
}
}

0 comments on commit 5911d22

Please sign in to comment.