Re: RDF in SVG (or other XML)

"Danny Ayers" <danny666@virgilio.it>
> The SVG spec uses RDF in its examples of what to put in <metadata>
elements,
> and I was wondering how people were getting on with this in practice.
In
> particular, unmarshalling the markup in such a way that references
between
> the SVG elements and RDF statements are maintained/created in their
> respective models strikes me as potentially tricky.

I agree, I've kept them seperate so I have an RDF view of the data which
is converted to SVG purely for output purposes.  I'm annotating image and
I prefer doing it this way where the references don't point to elements
in the SVG document, because this isn't robust against changes of the
document, and also requires that you "own" the SVG document, limiting
what you can annotate.

So all my RDF I store seperately, and just say the RDF refers to a
seperate file, using path data for what I'm talking about - this is not
robust against user stylesheets in the SVG display, and can cause
problems with changes - however it does mean I can easily annotate raster
images, or even movies etc. with the same vocabulary.

> It's a fairly general problem - I know folks have done RDF scraping
from
> (X)HTML, but I can't remember seeing anything that kept references to
> fragments annotated with the RDF.

Putting (also at http://jibbering.com/2002/8/rocky.svg ):

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <title>Rocky!</title>
  <desc>Rocky the Rock Hyrax</desc>
<a xlink:href="mailto:rocky-fanmail@rdfweb.org"><image id="rock_hyrax"
clip-path="url(#ref0)" opacity="1" width="640" height="480" x="0" y="0"
xlink:href="http://swordfish.rdfweb.org/photos/2002/06/27/002281.JPG">
</image></a>  <g clip-rule="evenodd" >  <clipPath id="ref0"> <path
id="pathref0" d="M405 151  L405 151L356 146 L343 167 L338 181 L300 180
L256 191 L185 240 L181 246 L163 301 L193 327 L193 343 L194 347 L231 352
L265 327 L309 310 L330 317 L335 300 L383 232 L393 205 L393 186 L405 178
L410 168 z L405 151  z" fill="red" /></clipPath></g>
<metadata>
<rdf:RDF>
<rdf:Description rdf:about="#rock_hyrax">
 <foaf:name>Rocky</foaf:name>
</rdf:Description>
</rdf:RDF>
</metadata>
</svg>

through the RDF validator, correctly sorts out the references, (my cygwin
raptor rdfdump doesn't seem to find anything with --scan)  So I don't
have any problems doing it, I just find the rdf view in
http://jibbering.com/rdfsvg/1025711279152.rdf more useful a view rather
than embedding.)

> The simplest way that occurs to me would be to run the source doc
through
> stylesheets first to split it into separate SVG and RDF DOMs, and then
pass
> these to appropriate APIs. If the original generator included
> cross-references in the RDF then the XSLT should be pretty trivial.
This
> does seem like a bit of a sledgehammer approach though, presumably it
should
> be possible to do it more elegantly using DOM programmatically.

Well, raptor (should) and arp both can get at the RDF bits without
trouble.

Inside an SVG document (probably only in ASV), my RDF parser can also
access the RDF:
http://jibbering.com/2002/8/rocky-parser.svg , but I still prefer the
seperate view as being neater - but I've not found any problems doing it.

Jim.

Received on Friday, 9 August 2002 07:37:46 UTC