Skip to content

Commit

Permalink
Fix #472
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed Apr 11, 2024
1 parent 4f7d18d commit a684146
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public int transformFromXPath(VTDNav vn, int result, int child, String parentId,
log.trace(" -- tag: {} ", tag);
String childId = String.join("", parentId , "/" , Integer.toString(child), ":", tag);
builder.addContainer(dataSourceId, parentId, child, childId);
builder.addType(dataSourceId, childId, XYZ_NS+tag);

// Attributes
int attrCount = vn.getAttrCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public MoreXMLTriplifierTest() {

@Override
protected void properties(Properties properties) {
// this.setPrintWholeGraph(true);
if(name.getMethodName().equals("testSimple$1")){
properties.put("blank-nodes", "false");
}else
Expand All @@ -50,6 +51,10 @@ protected void properties(Properties properties) {
}else if(name.getMethodName().equals("testBooks_2$1")){
properties.put("blank-nodes", "false");
properties.put("xml.path", "//book");
}else if(name.getMethodName().equals("testXPathAndSlice")){
properties.put("blank-nodes", "true");
properties.put("xml.path", "//Record");
properties.put("slice", "true");
}
}

Expand Down Expand Up @@ -87,4 +92,11 @@ protected void properties(Properties properties) {
//RDFDataMgr.write(System.err, result, Lang.TTL);
assertResultIsIsomorphicWithExpected();
}

@Test
public void testXPathAndSlice() {
L.debug("Test XML books (XPath //Record, with slicing)");
//RDFDataMgr.write(System.err, result, Lang.TTL);
assertResultIsIsomorphicWithExpected();
}
}
42 changes: 21 additions & 21 deletions sparql-anything-xml/src/test/resources/Books_1.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.


<http://www.example.org/document/3:book/3:genre>
<http://www.example.org/document/3:book/3:genre> a <http://sparql.xyz/facade-x/data/genre> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Fantasy" .

<http://www.example.org/document/2:book/6:description>
<http://www.example.org/document/2:book/6:description> a <http://sparql.xyz/facade-x/data/description> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"A former architect battles corporate zombies,\n an evil sorceress, and her own childhood to become queen\n of the world." .

<http://www.example.org/document/1:book/1:author>
<http://www.example.org/document/1:book/1:author> a <http://sparql.xyz/facade-x/data/author> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Gambardella, Matthew" .

Expand All @@ -26,35 +26,35 @@
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_3>
<http://www.example.org/document/3:book> .

<http://www.example.org/document/3:book/1:author>
<http://www.example.org/document/3:book/1:author> a <http://sparql.xyz/facade-x/data/author> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Corets, Eva" .

<http://www.example.org/document/1:book/5:publish_date>
<http://www.example.org/document/1:book/5:publish_date> a <http://sparql.xyz/facade-x/data/publish_date> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"2000-10-01" .

<http://www.example.org/document/2:book/3:genre>
<http://www.example.org/document/2:book/3:genre> a <http://sparql.xyz/facade-x/data/genre> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Fantasy" .

<http://www.example.org/document/2:book/5:publish_date>
<http://www.example.org/document/2:book/5:publish_date> a <http://sparql.xyz/facade-x/data/publish_date> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"2000-12-16" .

<http://www.example.org/document/3:book/4:price>
<http://www.example.org/document/3:book/4:price> a <http://sparql.xyz/facade-x/data/price> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"5.95" .

<http://www.example.org/document/1:book/3:genre>
<http://www.example.org/document/1:book/3:genre> a <http://sparql.xyz/facade-x/data/genre> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Computer" .

<http://www.example.org/document/3:book/2:title>
<http://www.example.org/document/3:book/2:title> a <http://sparql.xyz/facade-x/data/title> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Maeve Ascendant" .

<http://www.example.org/document/1:book>
<http://www.example.org/document/1:book> a <http://sparql.xyz/facade-x/data/book> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
<http://www.example.org/document/1:book/1:author> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
Expand All @@ -70,39 +70,39 @@
<http://sparql.xyz/facade-x/data/isbn>
"978-3-12-148410-0" .

<http://www.example.org/document/2:book/4:price>
<http://www.example.org/document/2:book/4:price> a <http://sparql.xyz/facade-x/data/price> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"5.95" .

<http://www.example.org/document/1:book/6:description>
<http://www.example.org/document/1:book/6:description> a <http://sparql.xyz/facade-x/data/description> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"An in-depth look at creating applications\n with XML." .

<http://www.example.org/document/3:book/5:publish_date>
<http://www.example.org/document/3:book/5:publish_date> a <http://sparql.xyz/facade-x/data/publish_date> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"2000-11-17" .

<http://www.example.org/document/2:book/1:author>
<http://www.example.org/document/2:book/1:author> a <http://sparql.xyz/facade-x/data/author> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Ralls, Kim" .

<http://www.example.org/document/2:book/2:title>
<http://www.example.org/document/2:book/2:title> a <http://sparql.xyz/facade-x/data/title> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Midnight Rain" .

<http://www.example.org/document/1:book/4:price>
<http://www.example.org/document/1:book/4:price> a <http://sparql.xyz/facade-x/data/price> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"44.95" .

<http://www.example.org/document/1:book/2:title>
<http://www.example.org/document/1:book/2:title> a <http://sparql.xyz/facade-x/data/title> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"XML Developer's Guide" .

<http://www.example.org/document/3:book/6:description>
<http://www.example.org/document/3:book/6:description> a <http://sparql.xyz/facade-x/data/description> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"After the collapse of a nanotechnology\n society in England, the young survivors lay the\n foundation for a new society." .

<http://www.example.org/document/2:book>
<http://www.example.org/document/2:book> a <http://sparql.xyz/facade-x/data/book> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
<http://www.example.org/document/2:book/1:author> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
Expand All @@ -118,7 +118,7 @@
<http://sparql.xyz/facade-x/data/isbn>
"928-3-16-148410-0" .

<http://www.example.org/document/3:book>
<http://www.example.org/document/3:book> a <http://sparql.xyz/facade-x/data/book> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
<http://www.example.org/document/3:book/1:author> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
Expand Down
42 changes: 21 additions & 21 deletions sparql-anything-xml/src/test/resources/Books_2.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.


<http://www.example.org/document/3:book/3:genre>
<http://www.example.org/document/3:book/3:genre> a xyz:genre ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Fantasy" .

<http://www.example.org/document/2:book/6:description>
<http://www.example.org/document/2:book/6:description> a xyz:description ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"A former architect battles corporate zombies,\n an evil sorceress, and her own childhood to become queen\n of the world." .

<http://www.example.org/document/1:book/1:author>
<http://www.example.org/document/1:book/1:author> a xyz:author ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Gambardella, Matthew" .

Expand All @@ -26,35 +26,35 @@
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_3>
<http://www.example.org/document/3:book> .

<http://www.example.org/document/3:book/1:author>
<http://www.example.org/document/3:book/1:author> a xyz:author ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Corets, Eva" .

<http://www.example.org/document/1:book/5:publish_date>
<http://www.example.org/document/1:book/5:publish_date> a xyz:publish_date ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"2000-10-01" .

<http://www.example.org/document/2:book/3:genre>
<http://www.example.org/document/2:book/3:genre> a xyz:genre ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Fantasy" .

<http://www.example.org/document/2:book/5:publish_date>
<http://www.example.org/document/2:book/5:publish_date> a xyz:publish_date ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"2000-12-16" .

<http://www.example.org/document/3:book/4:price>
<http://www.example.org/document/3:book/4:price> a xyz:price ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"5.95" .

<http://www.example.org/document/1:book/3:genre>
<http://www.example.org/document/1:book/3:genre> a xyz:genre ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Computer" .

<http://www.example.org/document/3:book/2:title>
<http://www.example.org/document/3:book/2:title> a xyz:title ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Maeve Ascendant" .

<http://www.example.org/document/1:book>
<http://www.example.org/document/1:book> a xyz:book ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
<http://www.example.org/document/1:book/1:author> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
Expand All @@ -70,39 +70,39 @@
<http://sparql.xyz/facade-x/data/isbn>
"978-3-12-148410-0" .

<http://www.example.org/document/2:book/4:price>
<http://www.example.org/document/2:book/4:price> a xyz:price ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"5.95" .

<http://www.example.org/document/1:book/6:description>
<http://www.example.org/document/1:book/6:description> a xyz:description ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"An in-depth look at creating applications\n with XML." .

<http://www.example.org/document/3:book/5:publish_date>
<http://www.example.org/document/3:book/5:publish_date> a xyz:publish_date ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"2000-11-17" .

<http://www.example.org/document/2:book/1:author>
<http://www.example.org/document/2:book/1:author> a xyz:author ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Ralls, Kim" .

<http://www.example.org/document/2:book/2:title>
<http://www.example.org/document/2:book/2:title> a xyz:title ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"Midnight Rain" .

<http://www.example.org/document/1:book/4:price>
<http://www.example.org/document/1:book/4:price> a xyz:price ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"44.95" .

<http://www.example.org/document/1:book/2:title>
<http://www.example.org/document/1:book/2:title> a xyz:title ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"XML Developer's Guide" .

<http://www.example.org/document/3:book/6:description>
<http://www.example.org/document/3:book/6:description> a xyz:description ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
"After the collapse of a nanotechnology\n society in England, the young survivors lay the\n foundation for a new society." .

<http://www.example.org/document/2:book>
<http://www.example.org/document/2:book> a xyz:book ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
<http://www.example.org/document/2:book/1:author> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
Expand All @@ -118,7 +118,7 @@
<http://sparql.xyz/facade-x/data/isbn>
"928-3-16-148410-0" .

<http://www.example.org/document/3:book>
<http://www.example.org/document/3:book> a xyz:book ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
<http://www.example.org/document/3:book/1:author> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
Expand Down
Loading

0 comments on commit a684146

Please sign in to comment.