Skip to content

Commit

Permalink
Merge pull request #577 from dbs/fix_576_time_child_element
Browse files Browse the repository at this point in the history
Prevent RDFa parser from failing on time elements with child nodes, backported in RDFLib/pyrdfa3@f1030e7
  • Loading branch information
joernhees committed Jan 28, 2016
2 parents d1a530e + 8bbbc80 commit 2344de9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rdflib/plugins/parsers/pyRdfa/host/html5.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _get_literal(Pnode):
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
elif node.nodeType == node.ELEMENT_NODE :
rc = rc + self._get_literal(node)
rc = rc + _get_literal(node)
if state.options.space_preserve :
return rc
else :
Expand Down
26 changes: 26 additions & 0 deletions test/test_issue576.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import rdflib

html = """<!DOCTYPE html>
<html>
<head>
<title>Boom</title>
</head>
<body vocab="http://schema.org/" typeof="Book" resource="http://example.com/">
<time property="dateCreated"><em>2016-01-01</em></time>
</body>
</html>
"""


def test_time_child_element():
"""
Ensure TIME elements that contain child nodes parse cleanly
"""
g = rdflib.Graph()
g.parse(data=html, format='rdfa')
date = g.value(
rdflib.URIRef("http://example.com/"),
rdflib.URIRef("http://schema.org/dateCreated")
)
assert len(g) == 3
assert date == rdflib.term.Literal("2016-01-01")

0 comments on commit 2344de9

Please sign in to comment.