/upstream/templates/type/work/rdf.tmpl
Type: /type/template
body: value: $def with (work)
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
  xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#'
  xmlns:rdrel='http://RDVocab.info/RDARelationshipsWEMI/'
  xmlns:dcterms='http://purl.org/dc/terms/'
  xmlns:dcam='http://purl.org/dc/dcam/'
  xmlns:ov='http://open.vocab.org/terms/'
  xmlns:frbr='http://purl.org/vocab/frbr/core#'
>

    $ wuri = "http://openlibrary.org" + work.key + "/"
    $ wAbout = "http://openlibrary.org" + work.key + "/about/"

    $if work.subtitle:
           $ title = work.title + ": " + work.subtitle
    $else:
           $ title = work.title

    $def display(tag, value):
        $if isinstance(value, list):
            $for x in value:
                <$tag>$x</$tag>
        $elif value:
            <$tag>$value</$tag>

    <frbr:Work rdf:about="$wuri">
        $:display("dcterms:title", title)

        $for a in work.authors:
            <dcterms:creator>
              <rdf:Description rdf:about="http://openlibrary.org$a.author.key">
              <rdf:value>$a.author.name</rdf:value> 
              </rdf:Description>
            </dcterms:creator> 
       
       
        $:display("dcterms:subject", work.subjects)
        $:display("dcterms:coverage", work.subject_places)
        $:display("dcterms:coverage", work.subject_times)
        $:display("dcterms:description", work.description)

        $for DDC in work.dewey_number:   
            <dcterms:subject>
                <rdf:Description>
                <dcam:memberOf rdf:resource="http://purl.org/dc/terms/DDC"/>
                <rdf:value>$DDC</rdf:value>
            </rdf:Description>
            </dcterms:subject>
        $for LCC in work.lc_classifications:
            <dcterms:subject>
                <rdf:Description>
                    <dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCC"/>
                    <rdf:value>$LCC</rdf:value>
                </rdf:Description>
            </dcterms:subject>

        $:display("dcterms:date", work.first_publish_date)

        $:display("dcterms:alternative", work.other_titles) 

        $for link in work.links:
            <foaf:page>
                <foaf:Document rdf:about="$link.url">
                    <rdfs:label>$link.title</rdfs:label>
                </foaf:Document>
            </foaf:page>
        </frbr:Work> 

        $for edition in work.editions:
            $ eduri = "http://openlibrary.org" + edition.key + "/"
            $if edition.subtitle:
               $ etitle = edition.title + ": " + edition.subtitle
            $else:
              $ etitle = edition.title

            <rdf:Description rdf:about="$eduri">
               <rdrel:workManifested>
                  "$wuri"
                 </rdrel:workManifested>
                <dcterms:title>$etitle</dcterms:title>
                <dcterms:date>$edition.publish_date</dcterms:date>
            </rdf:Description>    

    
    <!-- administrative -->
    <rdf:Description rdf:about="$wAbout">
        <dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">$work.last_modified</dcterms:modified>
        <dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">$work.created</dcterms:created>
        <ov:versionnumber>$work.revision</ov:versionnumber>
    </rdf:Description>

</rdf:RDF>
title: type/work/rdf
plugin: openlibrary