Search code examples
rrdfrdfahttr

distill RDFa into RDF-XML in R


How would I go about distilling RDF-XML from RDFa in R? Is there an existing package or function for this?

Alternatively, it would be workable if not ideal to simply post to some web service to perform the extraction, but I cannot seem to get this working with Apache's http://any23.org api either:

httr::POST("http://any23.org/rdfxml", 
           body=list(file=upload_file("inst/examples/meta_example.xml")), 
           add_headers("Content-Type"="application/xhtml+xml"))

Returns a 501 error, "no triples found", despite the fact that manually loading the example file into the any23 web interface works fine.

A solution using httr calls to an alternate server would also be fine, and an ideal solution could extract RDFa triples as RDF-XML with pure R functions (e.g. something analogous to this python library: pyrdfa3)


Solution

  • Was able to find a different RESTful service I could call from R for this purpose. Not ideal but functional. With file the path to the file containing RDFa, I can do:

    library(httr)
    response <- POST("http://rdf-translator.appspot.com/convert/rdfa/xml/content", 
                   body=list(content=upload_file(file)))
    doc <- content(response, "parsed", "text/xml")