robstewart57/rdf4h — pull request #6 by maertsen (2014-01-14 23:17:27+00:00)
Title: XmlParser does not implicitly connect a child of a resource-less element, produces literal for newline instead

Rob,

I've been using rdf4h during my thesis project. I've been a happy user for some time, thanks for writing this library!

I found my first bug today :-), at least I think it is a bug. I created a xml/rdf file using rdflib for Python (pretty-xml output format) and am attempting to parse that using rdf4h. But the XmlParser does not implicitly connect a child of a resource-less element and produces a literal for the newline instead.

In other words, this:
```

```
is not the same as this:
```

```
while I think they should be identical in terms of generated Triples.

I wrote some tests that illustrate this problem, with and without a child element. Test NML1, which tries the first example above is currently failing, with the following output:

```
NML: [Failed]
expected: Triple(UNode("urn:ogf:network:example.org:2014:foo"),UNode("rdf:type"),UNode("nml:Node"))
Triple(UNode("urn:ogf:network:example.org:2014:foo"),UNode("nml:hasInboundPort"),UNode("urn:ogf:network:example.org:2014:foo:A1:in"))
Triple(UNode("urn:ogf:network:example.org:2014:foo:A1:in"),UNode("rdf:type"),UNode("nml:Port"))
Triple(UNode("urn:ogf:network:example.org:2014:foo:A1:in"),UNode("nml:isSink"),UNode("urn:ogf:network:example.org:2014:link:1"))
but got: Triple(UNode("urn:ogf:network:example.org:2014:foo"),UNode("rdf:type"),UNode("nml:Node"))
Triple(UNode("urn:ogf:network:example.org:2014:foo"),UNode("nml:hasInboundPort"),LNode(PlainL(
)))
Triple(UNode("urn:ogf:network:example.org:2014:foo"),UNode("nml:hasInboundPort"),LNode(PlainL(
)))
```
So it skips processing of the children entirely, instead returning a literal for the newline. I must admit that I don't know enough RDF to classify this as a bug, but it seems unlogical given that it is both unambiguous and generated by rdflib. What do you think?

Tests NML2 and NML3 illustrate working xml/rdf input (of the second kind above) for the same expected results and are currently passing. My first guess was that it had something to do with the fact that all xml/rdf input in the test suite seems to omit newlines (probably due to Haskell's lack of heredoc), hence NML2 uses explicit newlines in the input. NML3 uses the newline-less format of the rest of the testsuite. That means this behaviour seems not directly related to newlines.
My new guess is something to do with the lack of resource attribute, but I haven't had the time to dive into the code.

Any insights are appreciated!