[%- USE CGI -%]
<?xml version="1.0"?>
<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:dc="http://purl.org/dc/1.0/"
  xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
>

<rdf:Description rdf:about="">
[% IF criterion %]
  <dc:title>[% CGI.escapeHTML(criterion.name) %]</dc:title>
[% ELSE %]
  <dc:title>Full site index</dc:title>
[% END %]
  <foaf:topic rdf:resource="#listing" />
</rdf:Description>

[% USE Dumper %]
<rdf:Bag rdf:ID="listing">
[%- FOREACH node = nodes %]
[% metadata = node.node_data.metadata %]

  [%- IF metadata.os_x.list.first || metadata.os_y.list.first || metadata.latitude.list.first || metadata.longitude.list.first ||
        metadata.locale.list.first || metadata.address.list.first || metadata.postcode.list.first || metadata.map_link.list.first -%]
    [% nodeType = 'geo:SpatialThing' %]
  [%- ELSE -%]
    [% nodeType = 'rdf:Description' %]
  [%- END -%]

  <rdf:li>
    <[% nodeType %] rdf:about="[% full_cgi_url %]?id=[% node.param %];format=rdf#obj">
      <rdfs:seeAlso rdf:resource="[% full_cgi_url %]?id=[% node.param %];format=rdf" />
      <dc:title>[% node.name %]</dc:title>
    </[% nodeType %]>
  </rdf:li>
[% END %]
</rdf:Bag>

</rdf:RDF>