<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:spinque="com.spinque.tools.importStream.EmitterWrapper" xmlns:su="com.spinque.tools.importStream.Utils" extension-element-prefixes="spinque" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output encoding="UTF-8" method="text"/>
  <xsl:template match="table/row">
  
    <xsl:variable name="entityID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/', field[@name='ID'])"/>
    <xsl:variable name="Year" select="substring (field[@name='Datum_ISO_8601'], 1,4)" />
   
    <spinque:relation object="http://purl.org/dc/dcmitype/StillImage" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$entityID}"/>
    <spinque:relation object="https://schema.org/Photograph" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$entityID}"/>
    
    <xsl:if test="field[@name='Opdracht'] != ''"> 
    <xsl:variable name="organizationID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/organization/', field[@name='Opdracht'])"/>
    <spinque:relation object="{$organizationID}" predicate="https://schema.org/sourceOrganization" subject="{$entityID}"/>
    <spinque:relation object="https://schema.org/Organization" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$organizationID}"/>
    <spinque:attribute attribute="https://schema.org/name" subject="{$organizationID}" type="string" value="{field[@name='Opdracht']}" lang="nl"/>
    <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$organizationID}" type="string" value="{field[@name='Opdracht']}" lang="nl"/>
    <spinque:relation object="{field[@name='Opdracht_wikidata_qid']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$organizationID}"/>
    </xsl:if>
    
    <xsl:if test="field[@name='Fotograaf'] != ''"> 
    <xsl:variable name="photographerID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/photographer/', field[@name='Fotograaf'])"/>
    <spinque:relation object="{$photographerID}" predicate="https://schema.org/author" subject="{$entityID}"/>
    <spinque:relation object="https://schema.org/Person" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$photographerID}"/>
    <spinque:attribute attribute="https://schema.org/name" subject="{$photographerID}" type="string" value="{field[@name='Fotograaf']}" lang="nl"/>
    <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$photographerID}" type="string" value="{field[@name='Fotograaf']}" lang="nl"/>
    <spinque:relation object="{field[@name='Fotograaf_wikidata_qid']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$photographerID}"/>
    </xsl:if>
    
    <xsl:if test="field[@name='Fotopersbureau'] != ''"> 
    <xsl:variable name="pressagencyID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/photographer/', field[@name='Fotopersbureau'])"/>
    <spinque:relation object="{$pressagencyID}" predicate="https://schema.org/author" subject="{$entityID}"/>
    <spinque:relation object="https://schema.org/Organization" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$pressagencyID}"/>
    <spinque:attribute attribute="https://schema.org/name" subject="{$pressagencyID}" type="string" value="{field[@name='Fotopersbureau']}" lang="nl"/>
    <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$pressagencyID}" type="string" value="{field[@name='Fotopersbureau']}" lang="nl"/>
    <spinque:relation object="{field[@name='Fotograaf_wikidata_qid']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$pressagencyID}"/>
    </xsl:if>
    
    <spinque:attribute attribute="https://schema.org/license" subject="{$entityID}" type="string" value="{field[@name='Copyright']}"/>
    <spinque:attribute attribute="https://schema.org/dateCreated" subject="{$entityID}" type="date" value="{field[@name='Datum_ISO_8601']}"/>
    <spinque:attribute attribute="https://iisg.amsterdam/vocab/photocollections/period" subject="{$entityID}" type="string" value="{field[@name='Periode']}"/>
    <spinque:attribute attribute="https://schema.org/name" subject="{$entityID}" type="string" value="{field[@name='Titel']}" lang="nl"/>
    
    <xsl:if test="field[@name='Gebouw'] != ''"> 
     <xsl:variable name="locationID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Gebouw'])"/>
     <spinque:relation object="{$locationID}" predicate="https://schema.org/contentLocation" subject="{$entityID}"/>
     <spinque:relation object="https://schema.org/LandmarksOrHistoricalBuildings" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$locationID}"/>
     <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$locationID}" type="string" value="{field[@name='Gebouw']}"/>
     <spinque:attribute attribute="https://schema.org/name" subject="{$locationID}" type="string" value="{field[@name='Gebouw']}"/>
     <spinque:relation object="{field[@name='Gebouw_Adamlink']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$locationID}"/>
     
     <xsl:if test="field[@name='Adres'] != '' ">
      <xsl:variable name="addressID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Adres'])"/>
      <spinque:relation object="{$addressID}" predicate="https://schema.org/address" subject="{$locationID}"/>
      <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$addressID}" type="string" value="{field[@name='Adres']}"/>
      <spinque:attribute attribute="https://schema.org/name" subject="{$addressID}" type="string" value="{field[@name='Adres']}"/>
      
      <xsl:choose>
       <xsl:when test="field[@name='Huisnummer'] != '' ">
        <spinque:relation object="https://schema.org/PostalAddress" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$addressID}"/>
        <spinque:attribute attribute="https://iisg.amsterdam/vocab/photocollections/houseNumber" subject="{$addressID}" type="string" value="{field[@name='Huisnummer']}" lang="nl"/>
        <xsl:variable name="streetID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Straat'])"/>
        <spinque:relation object="{$streetID}" predicate="https://iisg.amsterdam/vocab/photocollections/street" subject="{$addressID}"/>
        <spinque:relation object="http://rdf.histograph.io/Street" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$streetID}"/>
        <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$streetID}" type="string" value="{field[@name='Straat']}"/>
        <spinque:attribute attribute="https://schema.org/name" subject="{$streetID}" type="string" value="{field[@name='Straat']}"/>
        <spinque:relation object="{field[@name='Straat_adamlink_uri']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$streetID}"/>
       </xsl:when>
      
       <xsl:when test="field[@name='Huisnummer'] = '' ">
        <spinque:relation object="http://rdf.histograph.io/Street" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$addressID}"/>
        <spinque:relation object="{field[@name='Straat_adamlink_uri']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$addressID}"/>   
       </xsl:when>
      </xsl:choose>
     
      <xsl:if test="field[@name='Plaats'] != '' ">
       <xsl:variable name="placeID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Plaats'])"/>
       <spinque:relation object="{$placeID}" predicate="http://opengis.net/ont/geosparql#sfWithin" subject="{$addressID}"/>
       <spinque:relation object="https://schema.org/City" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$placeID}"/>
       <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
       <spinque:attribute attribute="https://schema.org/name" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
       <spinque:relation object="{field[@name='Plaats_gemeentegeschiedenis']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$placeID}"/>
      </xsl:if>

     </xsl:if>
    
    <xsl:if test="field[@name='Adres'] = '' and field[@name='Plaats'] != ''">
     <xsl:variable name="placeID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Plaats'])"/>
     <spinque:relation object="{$placeID}" predicate="http://opengis.net/ont/geosparql#sfWithin" subject="{$locationID}"/>
     <spinque:relation object="https://schema.org/City" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$placeID}"/>
     <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
     <spinque:attribute attribute="https://schema.org/name" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
     <spinque:relation object="{field[@name='Plaats_gemeentegeschiedenis']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$placeID}"/>
    </xsl:if>
       
   </xsl:if>
    
   <xsl:if test="field[@name='Gebouw'] = '' and field[@name='Adres'] != ''"> 
    <xsl:variable name="locationID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Adres'])"/>
    <spinque:relation object="{$locationID}" predicate="https://schema.org/contentLocation" subject="{$entityID}"/>
    <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$locationID}" type="string" value="{field[@name='Adres']}"/>
    <spinque:attribute attribute="https://schema.org/name" subject="{$locationID}" type="string" value="{field[@name='Adres']}"/>
    
    <xsl:choose>
     <xsl:when test="field[@name='Huisnummer'] != '' ">
      <spinque:relation object="https://schema.org/PostalAddress" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$locationID}"/>
      <spinque:attribute attribute="https://iisg.amsterdam/vocab/photocollections/houseNumber" subject="{$locationID}" type="string" value="{field[@name='Huisnummer']}" lang="nl"/>
      <xsl:variable name="streetID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Straat'])"/>
      <spinque:relation object="{$streetID}" predicate="https://iisg.amsterdam/vocab/photocollections/street" subject="{$locationID}"/>
      <spinque:relation object="http://rdf.histograph.io/Street" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$streetID}"/>
      <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$streetID}" type="string" value="{field[@name='Straat']}"/>
      <spinque:relation object="{field[@name='Straat_adamlink_uri']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$streetID}"/>
     </xsl:when>
      
     <xsl:when test="field[@name='Huisnummer'] = '' ">
      <spinque:relation object="http://rdf.histograph.io/Street" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$locationID}"/>       
      <spinque:relation object="{field[@name='Straat_adamlink_uri']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$locationID}"/>   
     </xsl:when>  
    </xsl:choose>     
   
    <xsl:if test="field[@name='Buurt'] != '' ">
     <xsl:variable name="buurtID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Buurt'])"/>
     <spinque:relation object="{$buurtID}" predicate="http://opengis.net/ont/geosparql#sfWithin" subject="{$locationID}"/>
     <spinque:relation object="http://rdf.histograph.io/District" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$buurtID}"/>
     <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$buurtID}" type="string" value="{field[@name='Buurt']}"/>
     <spinque:attribute attribute="https://schema.org/name" subject="{$buurtID}" type="string" value="{field[@name='Buurt']}"/>
     <spinque:relation object="{field[@name='Buurt_Adamlink']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$buurtID}"/>
      
     <xsl:if test="field[@name='Plaats'] != '' ">
      <xsl:variable name="placeID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Plaats'])"/>
      <spinque:relation object="{$placeID}" predicate="http://opengis.net/ont/geosparql#sfWithin" subject="{$buurtID}"/>
      <spinque:relation object="https://schema.org/City" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$placeID}"/>
      <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
      <spinque:attribute attribute="https://schema.org/name" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
      <spinque:relation object="{field[@name='Plaats_gemeentegeschiedenis']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$placeID}"/>
     </xsl:if>
    </xsl:if>
    
    <xsl:if test="field[@name='Buurt'] = '' and field[@name='Plaats'] != '' ">
     <xsl:variable name="placeID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Plaats'])"/>
     <spinque:relation object="{$placeID}" predicate="http://opengis.net/ont/geosparql#sfWithin" subject="{$locationID}"/>
     <spinque:relation object="https://schema.org/City" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$placeID}"/>
     <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
     <spinque:attribute attribute="https://schema.org/name" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
    <spinque:relation object="{field[@name='Plaats_gemeentegeschiedenis']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$placeID}"/>
    </xsl:if>
   </xsl:if>

   <xsl:if test="field[@name='Gebouw'] = '' and field[@name='Adres'] = ''  and field[@name='Buurt'] != ''">
    <xsl:variable name="locationID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Buurt'])"/>
    <spinque:relation object="{$locationID}" predicate="https://schema.org/contentLocation" subject="{$entityID}"/>
    <spinque:relation object="http://rdf.histograph.io/District" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$locationID}"/>
    <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$locationID}" type="string" value="{field[@name='Buurt']}"/>
    <spinque:attribute attribute="https://schema.org/name" subject="{$locationID}" type="string" value="{field[@name='Buurt']}"/>
    <spinque:relation object="{field[@name='Buurt_Adamlink']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$locationID}"/>
    
    <xsl:if test="field[@name='Plaats'] != '' ">
     <xsl:variable name="placeID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Plaats'])"/>
     <spinque:relation object="{$placeID}" predicate="http://opengis.net/ont/geosparql#sfWithin" subject="{$locationID}"/>
     <spinque:relation object="https://schema.org/City" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$placeID}"/>
     <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
     <spinque:attribute attribute="https://schema.org/name" subject="{$placeID}" type="string" value="{field[@name='Plaats']}"/>
     <spinque:relation object="{field[@name='Plaats_gemeentegeschiedenis']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$placeID}"/>
    </xsl:if>
   </xsl:if>
   
   <xsl:if test="field[@name='Gebouw'] = '' and field[@name='Adres'] = ''  and field[@name='Buurt'] = '' and field[@name='Plaats'] = ''">
    <xsl:variable name="locationID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/location/', field[@name='Plaats'])"/>
    <spinque:relation object="https://schema.org/City" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" subject="{$locationID}"/>
    <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$locationID}" type="string" value="{field[@name='Plaats']}"/>
    <spinque:attribute attribute="https://schema.org/name" subject="{$locationID}" type="string" value="{field[@name='Plaats']}"/>
    <spinque:relation object="{field[@name='Plaats_gemeentegeschiedenis']}" predicate="http://www.w3.org/2002/07/owl#sameAs" subject="{$locationID}"/>
   </xsl:if>

    <xsl:call-template name="templateForThemes">
      <xsl:with-param name="entityID" select="$entityID" />
    </xsl:call-template>
    
    <xsl:call-template name="templateForOrganizations">
      <xsl:with-param name="entityID" select="$entityID" />
    </xsl:call-template>
    
    <xsl:call-template name="templateForPersons">
      <xsl:with-param name="entityID" select="$entityID" />
    </xsl:call-template>
    
    <xsl:call-template name="templateForImages">
      <xsl:with-param name="entityID" select="$entityID" />
    </xsl:call-template>
    
  </xsl:template>
  <xsl:template name="templateForThemes">
    <xsl:param name="entityID" />
    <xsl:param name="index" select="1" />
    <xsl:param name="maxValue" select="3" />

    <xsl:variable name="theme" select="field[@name=concat('Thema_', $index)]"/>
    <xsl:variable name="theme_iisg" select="field[@name=concat('Thema_', $index, '_IISGThesaurus')]"/>
    <xsl:variable name="theme_wiki" select="field[@name=concat('Thema_', $index, '_Wikidata_Qid')]"/>

    <xsl:if test="$theme != ''">
      <xsl:variable name="themeID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/theme/', $theme)"/>

      <spinque:relation subject="{$themeID}" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" object="http://www.w3.org/2004/02/skos/core#Concept" />
      <spinque:attribute subject="{$themeID}" attribute="https://schema.org/name" type="string" value="{$theme}" />
      <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$themeID}" type="string" value="{$theme}"/>
      <spinque:relation subject="{$themeID}" predicate="http://www.w3.org/2002/07/owl#sameAs" object="{$theme_iisg}" />
      <spinque:relation subject="{$themeID}" predicate="http://www.w3.org/2002/07/owl#sameAs" object="{$theme_wiki}" />
      <spinque:relation subject="{$entityID}" predicate="https://schema.org/about" object="{$themeID}" />

      <xsl:if test="$index &lt; $maxValue">
        <xsl:call-template name="templateForThemes">
          <xsl:with-param name="entityID" select="$entityID" />
          <xsl:with-param name="index" select="$index + 1" />
          <xsl:with-param name="total" select="$maxValue" />
        </xsl:call-template>
      </xsl:if>

    </xsl:if>
    </xsl:template>
     
    <xsl:template name="templateForOrganizations">
    <xsl:param name="entityID" />
    <xsl:param name="index" select="1" />
    <xsl:param name="maxValue" select="2" />

    <xsl:variable name="organization" select="field[@name=concat('Organisatie_', $index)]"/>
    <xsl:variable name="organization_wiki" select="field[@name=concat('Organisatie_', $index, '_Wikidata_Qid')]"/>

    <xsl:if test="$organization != ''">
      <xsl:variable name="organizationID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/organization/', $organization)"/>

      <spinque:relation subject="{$organizationID}" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" object="https://schema.org/Organization" />
      <spinque:attribute subject="{$organizationID}" attribute="https://schema.org/name" type="string" value="{$organization}" />
      <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$organizationID}" type="string" value="{$organization}"/>
      <spinque:relation subject="{$organizationID}" predicate="http://www.w3.org/2002/07/owl#sameAs" object="{$organization_wiki}" />
      <spinque:relation subject="{$entityID}" predicate="https://schema.org/about" object="{$organizationID}" />

      <xsl:if test="$index &lt; $maxValue">
        <xsl:call-template name="templateForOrganizations">
          <xsl:with-param name="entityID" select="$entityID" />
          <xsl:with-param name="index" select="$index + 1" />
          <xsl:with-param name="total" select="$maxValue" />
        </xsl:call-template>
      </xsl:if>

    </xsl:if>

  </xsl:template>
  
  <xsl:template name="templateForPersons">
    <xsl:param name="entityID" />
    <xsl:param name="index" select="1" />
    <xsl:param name="maxValue" select="3" />

    <xsl:variable name="person" select="field[@name=concat('Organisatie_', $index)]"/>
    <xsl:variable name="person_wiki" select="field[@name=concat('Organisatie_', $index, '_Wikidata_Qid')]"/>

    <xsl:if test="$person != ''">
      <xsl:variable name="personID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/person/', $person)"/>

      <spinque:relation subject="{$personID}" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" object="https://schema.org/Person" />
      <spinque:attribute subject="{$personID}" attribute="https://schema.org/name" type="string" value="{$person}" />
      <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$personID}" type="string" value="{$person}"/>
      <spinque:relation subject="{$personID}" predicate="http://www.w3.org/2002/07/owl#sameAs" object="{$person_wiki}" />
      <spinque:relation subject="{$entityID}" predicate="https://schema.org/about" object="{$personID}" />

      <xsl:if test="$index &lt; $maxValue">
        <xsl:call-template name="templateForPersons">
          <xsl:with-param name="entityID" select="$entityID" />
          <xsl:with-param name="index" select="$index + 1" />
          <xsl:with-param name="total" select="$maxValue" />
        </xsl:call-template>
      </xsl:if>

    </xsl:if>

  </xsl:template>
  
  <xsl:template name="templateForImages">
    <xsl:param name="entityID" />
    <xsl:param name="index" select="1" />
    <xsl:param name="maxValue" select="39" />

    <xsl:variable name="image" select="field[@name=concat('Link_', $index)]"/>

    <xsl:if test="$image != ''">
      <xsl:variable name="imageID" select="su:uri('https://iisg.amsterdam/id/vanmeerendonk/', field[@name='ID'], 'depiction')"/>

      <spinque:relation subject="{$imageID}" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" object="https://schema.org/ImageObject" />
      <spinque:attribute subject="{$imageID}" attribute="https://schema.org/contentUrl" type="anyURL" value="{$image}" />
      <spinque:attribute attribute="http://www.w3.org/2000/01/rdf-schema#label" subject="{$imageID}" type="string" value="Afbeelding"/>
      <spinque:attribute attribute="https://schema.org/encodingFormat" subject="{$imageID}" type="string" value="image/jpeg" />
      
      <spinque:relation subject="{$entityID}" predicate="https://schema.org/image" object="{$imageID}" />

      <xsl:if test="$index &lt; $maxValue">
        <xsl:call-template name="templateForImages">
          <xsl:with-param name="entityID" select="$entityID" />
          <xsl:with-param name="index" select="$index + 1" />
          <xsl:with-param name="total" select="$maxValue" />
        </xsl:call-template>
      </xsl:if>

    </xsl:if>

  </xsl:template>
</xsl:stylesheet>
