On Thu, 10 Feb 2011 18:39:44 +0100
Ivan Herman <ivan@w3.org> wrote:
> What I do in my distiller, and I think this is the only way to do it,
> is to separate the two. For SVG files I first try to find the RDF/XML
> portions, extract it from the SVG file, and parse it into a graph. I
> then parse the same file with the RDFa parser, produce another graph.
> I then merge the two graphs before outputting it to the caller.
I do this slightly differently, though it has the same effect.
I parse the file as RDFa, but in the processing algorithm, if the
current element is <rdf:RDF>, serialise the element as canonical XML and
pass that to an RDF/XML parser which has a callback, accepting each
triple and dealing with it the same way I would triples from RDFa. Then
I set the recurse flag to false and carry on as normal.
The advantage of doing it this way is that anybody using the callback
feature of my library receives the triples in document order whether
they came from RDFa or RDF/XML. It also means that the algorithm
remains mostly one-pass.
--
Toby A Inkster
<mailto:mail@tobyinkster.co.uk>
<http://tobyinkster.co.uk>