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 cbabcd5 commit f8207b8
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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, tag);

// Attributes
int attrCount = vn.getAttrCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,75 @@

public class MoreXMLTriplifierTest extends AbstractTriplifierTester {
private final Logger L = LoggerFactory.getLogger(MoreXMLTriplifierTest.class);

public MoreXMLTriplifierTest() {
super(new XMLTriplifier(), new Properties(), "xml", "ttl");
}

@Override
protected void properties(Properties properties) {
if(name.getMethodName().equals("testSimple$1")){
if (name.getMethodName().equals("testSimple$1")) {
properties.put("blank-nodes", "false");
}else
if(name.getMethodName().equals("testBooks$1")){
} else if (name.getMethodName().equals("testBooks$1")) {
properties.put("blank-nodes", "false");
}else
if(name.getMethodName().equals("testBooks_1$1")){
} else if (name.getMethodName().equals("testBooks_1$1")) {
properties.put("blank-nodes", "false");
properties.put("xml.path", "//book");
}else
if(name.getMethodName().equals("testSliceBooks$1")){
} else if (name.getMethodName().equals("testSliceBooks$1")) {
properties.put("blank-nodes", "false");
properties.put("slice", "true");
properties.put("xml.path", "//book");
}else if(name.getMethodName().equals("testBooks_2$1")){
} 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");
}
}

@Test
public void testSimple$1(){
public void testSimple$1() {
L.debug("Test XML (one go)");
//RDFDataMgr.write(System.err, result, Lang.TTL);
assertResultIsIsomorphicWithExpected();
}

@Test
public void testBooks$1(){
public void testBooks$1() {
L.debug("Test XML books (one go)");
// RDFDataMgr.write(System.err, result, Lang.TTL);
assertResultIsIsomorphicWithExpected();
}

@Test
public void testBooks_1$1(){
public void testBooks_1$1() {
L.debug("Test XML books (XPath //book, one go)");
//RDFDataMgr.write(System.err, result, Lang.TTL);
assertResultIsIsomorphicWithExpected();
}

@Test
public void testBooks_2$1(){
public void testBooks_2$1() {
L.debug("Test XML books (XPath //book, one go) -- different input but same output as _1");
//RDFDataMgr.write(System.err, result, Lang.TTL);
assertResultIsIsomorphicWithExpected();
}

@Test
public void testSliceBooks$1(){
public void testSliceBooks$1() {
L.debug("Test XML books (XPath //book, with slicing)");
//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 f8207b8

Please sign in to comment.