-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #577 from dbs/fix_576_time_child_element
Prevent RDFa parser from failing on time elements with child nodes, backported in RDFLib/pyrdfa3@f1030e7
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |