Copy RDFa metadata
It’s been quiet on the show-and-tell side of things here as we’ve been working on more lower-level stuff, but now it’s time to pick up the thread again on how to copy metadata over the clipboard. Last time I showed how XMP-embedded metadata could be copied from GNOME Image Viewer into Inkscape (with some patches).
This time we have a Firefox add-on to copy RDFa-embedded metadata from a webpage, and you can easily try this yourself:
- Install the add-on
- Open this example page, which contains an image with embedded metadata
- Right-click on the image to open the context menu, and select “Copy metadata”
- Go to a text editor or word processor and paste it
- You should now see a chunk of rather ugly XML: that’s the RDF metadata about the image, now in RDF/XML format
Jonas explains what happens in this video:
The “Copy linked metadata” function is similar, but it also includes any metadata about linked resources, e.g. source work attribution. If you try this option on the same image, you’ll see that the pasted RDF/XML now contains more information.
The add-on also provides the experimental “Copy image with metadata” function. Trying this function requires the experimentally patched Inkscape from the last post, so I show that in this video:
Finally, the add-on only adds the menu functions on images that have any metadata to copy. On most of the images out there on the web you will not see this, as they lack metadata.
More about RDFa
RDFa is an elegant way to embed metadata using the document structure that webpages already have. Here are three good places to start exploring using RDFa:
- RDFa 1.1 Primer
- Lot’s of examples of using RDFa to embed Creative Commons licensing information in webpages
The example web page contains quite a lot of RDFa. The central part of it is this, with the RDFa metadata highlighted:
<img src="ttcfont.jpg" /> <div about="ttcfont.jpg" typeof="cc:Work"> <p> <span property="dc:title" xml:lang="en">TTC font collage</span>, by <a href="http://brugd.ctrl-c.liu.se/~petli/examples/ttcfont.xhtml" property="cc:attributionName dc:creator" rel="cc:attributionURL">Peter Liljenberg</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>. </p> ... </div>
The bold red text is RDFa markup, and the bold blue text is the parts of the webpage that the RDFa markup turn into metadata.
about="ttcfont.jpg" says that the contents of the div describes the resource with that URI, i.e. the image embedded previously.
typeof="cc:Work" adds the information that the image is a resource of the type Work, in the Creative Commons namespace. This lets parsers know that they can expect information about a Creative Commons-licensed work in the metadata.
The license used is defined by the
rel="license" attribute, which says that the license is identified by the URI pointed to by the href. This is the standard URI to the license deed for a CC-BY 3.0 license. This shows the power of RDFa: it provides both human-readable information about the license with a clickable link, as well as providing the same information in a machine-readable format with very little extra overhead.
rel="cc:attributionURL" do the same for the attribution link for this work. Another kind of metadata is created by
property="cc:attributionName dc:creator", which says that the content of the a element is the value of these properties, in this case the name of the creator of the work, which is here also the name that should be used in attributions when reusing this work elsewhere.
This is semantically identical to this RDF/XML representation, which is what the add-on copy to the clipboard:
<rdf:RDF> <rdf:Description rdf:about="http://brugd.ctrl-c.liu.se/~petli/examples/ttcfont.jpg"> <rdf:type rdf:resource="http://creativecommons.org/ns#Work"/> <dc:title xml:lang="en">TTC font collage</dc:title> <cc:attributionURL rdf:resource="http://brugd.ctrl-c.liu.se/~petli/examples/ttcfont.xhtml"/> <cc:attributionName>Peter Liljenberg</cc:attributionName> <dc:creator>Peter Liljenberg</dc:creator> <xhv:license rdf:resource="http://creativecommons.org/licenses/by/3.0/"/> </rdf:Description> </rdf:RDF>