njh/easyrdf — pull request #97 by scor (2012-12-24 14:04:57+00:00)
Title: Support for loadHTML()

loadXML() chokes on non-valid XML, and as a result easyrdf doesn't return any triple nor any error message explaining what happened, this currently happens with Drupal 8 HTML5 output, see example HTML and its empty output on the easyrdf converter service. (In this particular case, this HTML is not valid XML due to ``` ``` entities. I propose to fall back on the more lenient loadHTML() when loadXM() fails.

I've also added a more generic support for extracting the base for HTML and XHTML documents. I tried putting the XML xpath in the loadXML hunk and the HTML xpath in the loadHTML hunk, but I found that for some cases where HTML5 documents were parsed as XML (needed for xmlns: support in HTML5), the HTML xpath was needed as well. So I believe the base extraction should live outside the respective parsing code hunks, and instead both xpath should be ran (they are very fast in comparison to the loadXML/loadHTML).

A side effect of this change is that it now brings the RDFa HTML test suite results on par with the XHTML results :)