<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:lido="http://www.lido-schema.org"
  xmlns:xalan="http://xml.apache.org/xalan" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:gml="http://www.opengis.net/gml">
    <xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <lido:lidoWrap xmlns:lido="http://www.lido-schema.org" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.lido-schema.org http://www.lido-schema.org/schema/v1.0/lido-v1.0.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/feature.xsd"> 
            <xsl:apply-templates select="/root"/>
        </lido:lidoWrap>
    </xsl:template>
    <xsl:template match="/root">
        <lido:lido>
            <lido:lidoRecID>
                <xsl:attribute name="lido:source">
                    <xsl:value-of select="concat(md_version, 'institution/', institution_id)" disable-output-escaping="yes" />
                </xsl:attribute>
                <xsl:attribute name="lido:type">local</xsl:attribute>
                <xsl:value-of select="institution_isil" />
                <xsl:value-of select="'/'" />
                <xsl:value-of select="objekt_id" />
            </lido:lidoRecID>
            <lido:category/>
            <lido:descriptiveMetadata>
                <xsl:if test="objekt_record_set/objekt_record_lang!=''">
                    <xsl:attribute name="xml:lang">
                        <xsl:value-of select="objekt_record_set/objekt_record_lang" />
                    </xsl:attribute>
                </xsl:if>
                <xsl:if test="objekt_record_lang!=''">
                    <xsl:attribute name="xml:lang">
                        <xsl:value-of select="objekt_record_lang" />
                    </xsl:attribute>
                </xsl:if>
                <lido:objectClassificationWrap>
                    <lido:objectWorkTypeWrap>
                        <lido:objectWorkType>
                            <xsl:for-each select="objektart_gnd">
                                <lido:conceptID>
                                    <xsl:attribute name="lido:source">gnd</xsl:attribute>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>
                                    <xsl:value-of select="concat('http://d-nb.info/gnd/', .)" />
                                </lido:conceptID>
                            </xsl:for-each>
                            <xsl:for-each select="objektart_grobsystematik">
                                <lido:conceptID>
                                    <xsl:attribute name="lido:source">grobsystematik</xsl:attribute>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>
                                    <xsl:value-of select="concat('https://term.museum-digital.de/grobsystematik/tag/', .)" />
                                </lido:conceptID>
                            </xsl:for-each>
                            <xsl:for-each select="objektart_oberbegriffsdatei">
                                <lido:conceptID>
                                    <xsl:attribute name="lido:source">oberbegriffsdatei</xsl:attribute>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>
                                    <xsl:value-of select="concat('https://term.museum-digital.de/oberbegriffsdatei/tag/', .)" />
                                </lido:conceptID>
                            </xsl:for-each>
                            <xsl:for-each select="objektart_aat">
                                <lido:conceptID>
                                    <xsl:attribute name="lido:source">aat</xsl:attribute>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>
                                    <xsl:value-of select="concat('http://vocab.getty.edu/aat/', .)" />
                                </lido:conceptID>
                            </xsl:for-each>
                            <xsl:for-each select="objektart_lcsh">
                                <lido:conceptID>
                                    <xsl:attribute name="lido:source">lcsh</xsl:attribute>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>
                                    <xsl:value-of select="concat('http://id.loc.gov/authorities/subjects/', .)" />
                                </lido:conceptID>
                            </xsl:for-each>
                            <xsl:for-each select="objektart_md_tag">
                                <lido:conceptID>
                                    <xsl:attribute name="lido:source">md:term</xsl:attribute>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>
                                    <xsl:value-of select="concat('https://term.museum-digital.de/md-de/tag/', .)" />
                                </lido:conceptID>
                            </xsl:for-each>
                            <xsl:if test="objektart!=''">
                                <xsl:for-each select="objektart">
                                    <lido:term>
                                        <xsl:attribute name="xml:lang">de</xsl:attribute>
                                        <xsl:value-of select="." />
                                    </lido:term>
                                </xsl:for-each>
                            </xsl:if>
                            <xsl:if test="objekt_record_set/objektart!=''">
                                <xsl:for-each select="objekt_record_set">
                                    <xsl:if test="substring(objekt_record_weitergabe,1,1)=0">
                                        <lido:term>
                                            <xsl:attribute name="xml:lang">
                                                <xsl:value-of select="objekt_record_lang" />
                                            </xsl:attribute>
                                            <xsl:value-of select="objektart" />
                                        </lido:term>
                                    </xsl:if>
                                </xsl:for-each>
                            </xsl:if>
                        </lido:objectWorkType>
                    </lido:objectWorkTypeWrap>
                    <lido:classificationWrap>
                        <xsl:for-each select="collectionSet">
                            <lido:classification>
                                <xsl:attribute name="lido:type">Sammlung</xsl:attribute>
                                <xsl:for-each select="sammlung_id">
                                    <lido:conceptID>
                                        <xsl:attribute name="lido:source">local</xsl:attribute>
                                        <xsl:attribute name="lido:type">collection_id</xsl:attribute>
                                        <xsl:value-of select="." />
                                    </lido:conceptID>
                                </xsl:for-each>
                                <xsl:for-each select="sammlung_name">
                                    <lido:term>
                                        <xsl:attribute name="xml:lang">de</xsl:attribute>
                                        <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>
                                        <xsl:value-of select="." />
                                    </lido:term>
                                </xsl:for-each>

                                <xsl:for-each select="sammlung_record_set">
                                    <xsl:if test="substring(sammlung_record_weitergabe,1,1)=0">
                                        <lido:term>
                                            <xsl:attribute name="xml:lang">
                                                <xsl:value-of select="sammlung_record_lang" />
                                            </xsl:attribute>
                                            <xsl:value-of select="sammlung_name" />
                                        </lido:term>
                                    </xsl:if>
                                </xsl:for-each>

                            </lido:classification>
                        </xsl:for-each>
                        <xsl:for-each select="seriesSet">
                            <xsl:if test="serie_weitergabe='000'">
                                <lido:classification>
                                    <xsl:for-each select="serie_id">
                                        <lido:conceptID>
                                            <xsl:attribute name="lido:source">local</xsl:attribute>
                                            <xsl:attribute name="lido:type">series_id</xsl:attribute>
                                            <xsl:value-of select="." />
                                        </lido:conceptID>
                                    </xsl:for-each>
                                    <xsl:for-each select="serie_name">
                                        <lido:term>
                                            <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>
                                            <!--                   <xsl:text >&lt;![CDATA[</xsl:text> -->
                                            <xsl:value-of select="." />
                                            <!--                    <xsl:text >]]&gt;</xsl:text> -->
                                        </lido:term>
                                    </xsl:for-each>
                                </lido:classification>
                            </xsl:if>
                        </xsl:for-each>
                    </lido:classificationWrap>
                </lido:objectClassificationWrap>
                <lido:objectIdentificationWrap>
                    <lido:titleWrap>

                        <xsl:if test="objekt_name!=''">
                            <lido:titleSet>
                                <xsl:for-each select="objekt_name">
                                    <lido:appellationValue>
                                        <xsl:attribute name="lido:pref">preferred</xsl:attribute>
                                        <xsl:value-of select="."/>
                                    </lido:appellationValue>
                                </xsl:for-each>
                            </lido:titleSet>
                        </xsl:if>

                        <xsl:for-each select="objekt_record_set">
                            <xsl:if test="substring(objekt_record_weitergabe,1,1)=0">
                                <lido:titleSet>
                                    <lido:appellationValue>
                                        <!--<xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>-->
                                        <xsl:attribute name="xml:lang">
                                            <xsl:value-of select="objekt_record_lang" />
                                        </xsl:attribute>
                                        <xsl:value-of select="objekt_name" />
                                    </lido:appellationValue>
                                </lido:titleSet>
                            </xsl:if>
                        </xsl:for-each>

                    </lido:titleWrap>

                    <xsl:if test="beschriftung2!=''">
                        <lido:inscriptionsWrap>
                            <lido:inscriptions>
                                <lido:inscriptionDescription>
                                    <lido:descriptiveNoteValue>
                                        <xsl:value-of select="beschriftung2" />
                                    </lido:descriptiveNoteValue>
                                </lido:inscriptionDescription>
                            </lido:inscriptions>
                        </lido:inscriptionsWrap>
                    </xsl:if>

                    <lido:repositoryWrap>
                        <lido:repositorySet>
                            <xsl:attribute name="lido:type">current</xsl:attribute>
                            <lido:repositoryName>
                                <xsl:for-each select="institution_isil">
                                    <lido:legalBodyID>
                                        <xsl:attribute name="lido:type">isil</xsl:attribute>
                                        <xsl:value-of select="."/>
                                    </lido:legalBodyID>
                                </xsl:for-each>
                                <lido:legalBodyName>
                                    <xsl:for-each select="institution_name">
                                        <lido:appellationValue>
                                            <xsl:value-of select="."/>
                                        </lido:appellationValue>
                                    </xsl:for-each>

                                    <xsl:for-each select="institution_record_set">
                                        <xsl:if test="substring(institution_record_weitergabe,1,1)=0">
                                            <lido:appellationValue>
                                                <xsl:attribute name="xml:lang">
                                                    <xsl:value-of select="institution_record_lang" />
                                                </xsl:attribute>
                                                <xsl:value-of select="institution_name" />
                                            </lido:appellationValue>
                                        </xsl:if>
                                    </xsl:for-each>



                                </lido:legalBodyName>
                                <xsl:for-each select="institution_url">
                                    <lido:legalBodyWeblink>
                                        <xsl:value-of select="."/>
                                    </lido:legalBodyWeblink>
                                </xsl:for-each>
                            </lido:repositoryName>
                            <xsl:for-each select="objekt_inventarnr">
                                <lido:workID>
                                    <xsl:attribute name="lido:type">inventory number</xsl:attribute>
                                    <xsl:value-of select="."/>
                                </lido:workID>
                            </xsl:for-each>
                            <lido:repositoryLocation>
                                <xsl:if test="institution_osm">
                                    <lido:placeID>
                                        <xsl:attribute name="lido:source">OSM</xsl:attribute>
                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                        <xsl:value-of select="institution_osm"/>
                                    </lido:placeID>
                                </xsl:if>
                                <lido:namePlaceSet>
                                    <xsl:for-each select="institution_ort">
                                        <lido:appellationValue>
                                            <xsl:value-of select="."/>
                                        </lido:appellationValue>
                                    </xsl:for-each>


                                    <xsl:for-each select="institution_record_set">
                                        <xsl:if test="substring(institution_record_weitergabe,1,1)=0">
                                            <lido:appellationValue>
                                                <xsl:attribute name="xml:lang">
                                                    <xsl:value-of select="institution_record_lang" />
                                                </xsl:attribute>
                                                <xsl:value-of select="institution_ort" />
                                            </lido:appellationValue>
                                        </xsl:if>
                                    </xsl:for-each>

                                </lido:namePlaceSet>
                                <xsl:if test="institution_location_ow!=0.00000000">
                                    <lido:gml>
                                        <gml:Point srsName="EPSG:4326">
                                            <gml:pos>
                                                <xsl:value-of select="institution_location_ns" />
                                                <xsl:value-of select="' '" />
                                                <xsl:value-of select="institution_location_ow" />
                                            </gml:pos>
                                        </gml:Point>
                                    </lido:gml>
                                </xsl:if>
                            </lido:repositoryLocation>
                        </lido:repositorySet>
                    </lido:repositoryWrap>

                    <lido:objectDescriptionWrap>
                        <xsl:if test="objekt_beschreibung!=''">
                            <lido:objectDescriptionSet>
                                <xsl:for-each select="objekt_beschreibung">
                                    <lido:descriptiveNoteValue>
                                        <xsl:value-of select="." />
                                    </lido:descriptiveNoteValue>
                                </xsl:for-each>
                                <xsl:for-each select="institution_name">
                                    <lido:sourceDescriptiveNote>
                                        <xsl:value-of select="."/>
                                    </lido:sourceDescriptiveNote>
                                </xsl:for-each>
                                <xsl:for-each select="institution_record_set">
                                    <xsl:if test="substring(institution_record_weitergabe,1,1)=0">
                                        <lido:sourceDescriptiveNote>
                                            <xsl:attribute name="xml:lang">
                                                <xsl:value-of select="institution_record_lang" />
                                            </xsl:attribute>
                                            <xsl:value-of select="institution_name" />
                                        </lido:sourceDescriptiveNote>
                                    </xsl:if>
                                </xsl:for-each>
                            </lido:objectDescriptionSet>
                        </xsl:if>

                        <xsl:if test="detaileddescription2!=''">
                            <lido:objectDescriptionSet>
                                <xsl:attribute name="lido:type">detailedDescription</xsl:attribute>
                                <xsl:for-each select="detaileddescription2">
                                    <lido:descriptiveNoteValue>
                                        <xsl:value-of select="." />
                                    </lido:descriptiveNoteValue>
                                </xsl:for-each>
                                <xsl:for-each select="institution_name">
                                    <lido:sourceDescriptiveNote>
                                        <xsl:value-of select="."/>
                                    </lido:sourceDescriptiveNote>
                                </xsl:for-each>
                                <xsl:for-each select="institution_record_set">
                                    <xsl:if test="substring(institution_record_weitergabe,1,1)=0">
                                        <lido:sourceDescriptiveNote>
                                            <xsl:attribute name="xml:lang">
                                                <xsl:value-of select="institution_record_lang" />
                                            </xsl:attribute>
                                            <xsl:value-of select="institution_name" />
                                        </lido:sourceDescriptiveNote>
                                    </xsl:if>
                                </xsl:for-each>
                            </lido:objectDescriptionSet>
                        </xsl:if>
                        

                        <xsl:if test="objekt_record_set/objekt_beschreibung!=''">
                            <xsl:for-each select="objekt_record_set">
                                <lido:objectDescriptionSet>
                                    <xsl:if test="substring(objekt_record_weitergabe,1,1)=0">
                                        <lido:descriptiveNoteValue>
                                            <xsl:attribute name="xml:lang">
                                                <xsl:value-of select="objekt_record_lang" />
                                            </xsl:attribute>
                                            <xsl:value-of select="objekt_beschreibung" />
                                        </lido:descriptiveNoteValue>
                                    </xsl:if>

                                    <xsl:if test="//institution_name!=''">
                                        <lido:sourceDescriptiveNote>
                                            <xsl:attribute name="xml:lang">
                                                <xsl:value-of select="objekt_record_lang" />
                                            </xsl:attribute>
                                            <xsl:value-of select="//institution_name"/>
                                        </lido:sourceDescriptiveNote>
                                    </xsl:if>
                                </lido:objectDescriptionSet>
                             </xsl:for-each>
                        </xsl:if>
                    </lido:objectDescriptionWrap>

                    <lido:objectMeasurementsWrap>
                        <xsl:if test="objekt_masse!=''">
                            <lido:objectMeasurementsSet>
                                <xsl:for-each select="objekt_masse">
                                    <lido:displayObjectMeasurements>
                                        <xsl:value-of select="."/>
                                    </lido:displayObjectMeasurements>
                                </xsl:for-each>

                                <lido:objectMeasurements>
                                    <xsl:if test=" (mass2_laenge_wert!='') and (mass2_laenge_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>length</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_laenge_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_laenge_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_breite_wert!='') and (mass2_breite_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>width</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_breite_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_breite_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_hoehe_wert!='') and (mass2_hoehe_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>height</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_hoehe_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_hoehe_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_gewicht_wert!='') and (mass2_gewicht_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>weight</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_gewicht_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_gewicht_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_durchmesser_wert!='') and (mass2_durchmesser_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>diameter</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_durchmesser_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_durchmesser_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (wandungsstaerke_wert!='') and (wandungsstaerke_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>width of wall</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="wandungsstaerke_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="wandungsstaerke_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_seitenzahl!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>number of pages</lido:measurementType>
                                            <lido:measurementUnit>Pages</lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_seitenzahl" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_stempelstellung!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>Stempelstellung</lido:measurementType>
                                            <lido:measurementUnit>Clock</lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_stempelstellung" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                </lido:objectMeasurements>
                            </lido:objectMeasurementsSet>
                        </xsl:if>

                        <xsl:if test="objekt_record_set/objekt_masse!=''">
                            <lido:objectMeasurementsSet>
                                <xsl:for-each select="objekt_record_set">
                                    <xsl:if test="substring(objekt_record_weitergabe,1,1)=0">
                                        <lido:displayObjectMeasurements>
                                            <xsl:attribute name="xml:lang">
                                                <xsl:value-of select="objekt_record_lang" />
                                            </xsl:attribute>
                                            <xsl:value-of select="objekt_masse" />
                                        </lido:displayObjectMeasurements>
                                    </xsl:if>
                                </xsl:for-each>

                                <lido:objectMeasurements>
                                    <xsl:if test=" (mass2_laenge_wert!='') and (mass2_laenge_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>length</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_laenge_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_laenge_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_breite_wert!='') and (mass2_breite_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>width</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_breite_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_breite_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_hoehe_wert!='') and (mass2_hoehe_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>height</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_hoehe_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_hoehe_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_gewicht_wert!='') and (mass2_gewicht_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>weight</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_gewicht_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_gewicht_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_durchmesser_wert!='') and (mass2_durchmesser_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>diameter</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="mass2_durchmesser_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_durchmesser_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (wandungsstaerke_wert!='') and (wandungsstaerke_einheit!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>width of wall</lido:measurementType>
                                            <lido:measurementUnit>
                                                <xsl:value-of select="wandungsstaerke_einheit" />
                                            </lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="wandungsstaerke_wert" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                    <xsl:if test=" (mass2_seitenzahl!='') ">  
                                        <lido:measurementsSet>
                                            <lido:measurementType>number of pages</lido:measurementType>
                                            <lido:measurementUnit>Pages</lido:measurementUnit>
                                            <lido:measurementValue>
                                                <xsl:value-of select="mass2_seitenzahl" />
                                            </lido:measurementValue>
                                        </lido:measurementsSet>
                                    </xsl:if> 
                                </lido:objectMeasurements>
                            </lido:objectMeasurementsSet>
                        </xsl:if>
                    </lido:objectMeasurementsWrap>

                </lido:objectIdentificationWrap>
                <lido:eventWrap>
                    <xsl:for-each select="eventSet">
                        <xsl:if test="(ereignistyp != '5') and (ereignistyp != '22') and (ereignistyp != '23') and (ereignistyp != '24') and (ereignistyp != '33') and (ereignistyp != '36')">
                            <lido:eventSet>
                                <lido:displayEvent>
                                    <xsl:for-each select="ereignistyp_name">
                                        <xsl:value-of select="."/>
                                    </xsl:for-each>

                                </lido:displayEvent>
                                <lido:event>
                                    <xsl:for-each select="ereignis_id">
                                        <lido:eventID>
                                            <xsl:attribute name="lido:type">local</xsl:attribute>
                                            <xsl:value-of select="."/>
                                        </lido:eventID>
                                    </xsl:for-each>
                                    <lido:eventType>
                                        <xsl:for-each select="ereignistyp_name">
                                            <lido:conceptID lido:type="uri">https://event-types.museum-digital.org/<xsl:value-of select="../ereignistyp"/></lido:conceptID>
                                            <lido:term>
                                                <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>
                                                <xsl:value-of select="."/>
                                            </lido:term>
                                        </xsl:for-each>
                                    </lido:eventType>
                                    <lido:eventName>
                                        <xsl:for-each select="ereignis_name">
                                            <lido:appellationValue>
                                                <xsl:value-of select="."/>
                                            </lido:appellationValue>
                                        </xsl:for-each>
                                    </lido:eventName>
                                    <!---->
                                    <xsl:if test="string-length(persinst_anzeigename) != 0">
                                        <lido:eventActor>
                                            <xsl:if test="(ereignis_persinst_sicher = 'n')">
                                                <lido:displayActorInRole>
                                                    <xsl:for-each select="persinst_anzeigename[(../ereignis_persinst_sicher = 'n')]">
                                                        <xsl:value-of select="."/>
                                                    </xsl:for-each> (?)</lido:displayActorInRole>
                                            </xsl:if>
                                            <xsl:if test="(ereignis_persinst_sicher != 'n')">
                                                <xsl:for-each select="persinst_anzeigename[(../ereignis_persinst_sicher != 'n')]">
                                                    <lido:displayActorInRole>
                                                        <xsl:value-of select="."/>
                                                    </lido:displayActorInRole>
                                                </xsl:for-each>
                                            </xsl:if>
                                            <lido:actorInRole>
                                                <lido:actor>
                                                    <xsl:if test="(nodaSet/noda_source = 'wikipedia') or (nodaSet/noda_source = 'Wikipedia') or (nodaSet/noda_source = 'NDB/ADB')">
                                                        <xsl:for-each select="nodaSet/noda_link[(../noda_source = 'wikipedia') or (../noda_source = 'Wikipedia') or (../noda_source = 'NDB/ADB')]">
                                                            <lido:actorID>
                                                                <xsl:attribute name="lido:source">
                                                                    <xsl:for-each select="../noda_source">
                                                                        <xsl:if test="position() = 1">
                                                                            <xsl:value-of select="."/>
                                                                        </xsl:if>
                                                                    </xsl:for-each>
                                                                </xsl:attribute>
                                                                <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                                <xsl:value-of select="."/>
                                                            </lido:actorID>
                                                        </xsl:for-each>
                                                    </xsl:if>
                                                    <xsl:if test="(nodaSet/noda_source != 'wikipedia') and (nodaSet/noda_source != 'Wikipedia') and (nodaSet/noda_source != 'NDB/ADB')">
                                                        <xsl:for-each select="nodaSet/noda_link[(../noda_source != 'wikipedia') and (../noda_source != 'Wikipedia') and (../noda_source != 'NDB/ADB')]">
                                                            <lido:actorID>
                                                                <xsl:attribute name="lido:source">
                                                                    <xsl:for-each select="../noda_source">
                                                                        <xsl:if test="position() = 1">
                                                                            <xsl:value-of select="."/>
                                                                        </xsl:if>
                                                                    </xsl:for-each>
                                                                </xsl:attribute>
                                                                <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                                <xsl:value-of select="."/>
                                                            </lido:actorID>
                                                        </xsl:for-each>
                                                    </xsl:if>
                                                    <lido:nameActorSet>
                                                        <xsl:for-each select="persinst_name">
                                                            <lido:appellationValue>
                                                                <xsl:if test="string-length(./@lang)!=0">
                                                                    <xsl:attribute name="xml:lang">
                                                                        <xsl:value-of select="./@lang"/>
                                                                    </xsl:attribute>
                                                                </xsl:if>
                                                                <xsl:value-of select="."/>
                                                        </lido:appellationValue>
                                                        </xsl:for-each>
                                                    </lido:nameActorSet>
                                                    <lido:vitalDatesActor>
                                                        <xsl:for-each select="persinst_geburtsjahr">
                                                            <xsl:if test="position() = 1">
                                                                <lido:earliestDate>
                                                                    <xsl:value-of select="."/>
                                                                </lido:earliestDate>
                                                            </xsl:if>
                                                        </xsl:for-each>
                                                        <xsl:for-each select="persinst_sterbejahr">
                                                            <xsl:if test="position() = 1">
                                                                <lido:latestDate>
                                                                    <xsl:value-of select="."/>
                                                                </lido:latestDate>
                                                            </xsl:if>
                                                        </xsl:for-each>
                                                    </lido:vitalDatesActor>
                                                </lido:actor>
                                            </lido:actorInRole>
                                        </lido:eventActor>
                                        <!---->
                                    </xsl:if>
                                    <!---->
                                    <xsl:if test="string-length(zeit_name) != 0">
                                        <lido:eventDate>
                                            <xsl:if test="(ereignis_zeit_sicher = 'n')">
                                                <xsl:for-each select="zeit_name[(../ereignis_zeit_sicher = 'n')]">
                                                    <lido:displayDate>
                                                        <xsl:if test="string-length(./@lang)!=0">
                                                            <xsl:attribute name="xml:lang">
                                                            <xsl:value-of select="./@lang"/>
                                                            </xsl:attribute>
                                                            <xsl:value-of select="."/> (?)
                                                        </xsl:if>
                                                        <xsl:if test="string-length(./@lang) = 0"><xsl:value-of select="."/> (?)</xsl:if>
                                                    </lido:displayDate>
                                                </xsl:for-each>
                                            </xsl:if>
                                            <xsl:if test="(ereignis_zeit_sicher != 'n')">
                                                <xsl:for-each select="zeit_name[(../ereignis_zeit_sicher != 'n')]">
                                                    <lido:displayDate>
														<xsl:if test="string-length(./@lang)!=0">
															<xsl:attribute name="xml:lang">
															<xsl:value-of select="./@lang"/>
															</xsl:attribute>
												        </xsl:if>
														<xsl:value-of select="."/>
                                                    </lido:displayDate>
                                                </xsl:for-each>
                                            </xsl:if>
                                            <lido:date>
                                                <xsl:for-each select="zeit_beginn">
                                                    <xsl:if test="position() = 1">
                                                        <lido:earliestDate>
                                                            <xsl:value-of select="."/>
                                                        </lido:earliestDate>
                                                    </xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="zeit_ende">
                                                    <xsl:if test="position() = 1">
                                                        <lido:latestDate>
                                                            <xsl:value-of select="."/>
                                                        </lido:latestDate>
                                                    </xsl:if>
                                                </xsl:for-each>
                                            </lido:date>
                                        </lido:eventDate>
                                    </xsl:if>
                                    <xsl:if test="string-length(ort_name) != 0">
                                        <lido:eventPlace>
                                            <xsl:if test="(ereignis_orte_sicher = 'n')">
                                                <xsl:for-each select="ort_name[(../ereignis_orte_sicher = 'n')]">
                                                    <lido:displayPlace>
                                                        <xsl:if test="string-length(./@lang)!=0">
                                                            <xsl:attribute name="xml:lang">
                                                            <xsl:value-of select="./@lang"/>
                                                            </xsl:attribute>
                                                            <xsl:value-of select="."/> (?)
														</xsl:if>
                                                        <xsl:if test="string-length(./@lang) = 0">
                                                            <xsl:value-of select="."/> (?)
														</xsl:if>
    											    </lido:displayPlace>
                                                </xsl:for-each>
                                            </xsl:if>
                                            <xsl:if test="(ereignis_orte_sicher != 'n')">
                                                <xsl:for-each select="ort_name[(../ereignis_orte_sicher != 'n')]">
                                                    <lido:displayPlace>
														<xsl:if test="string-length(./@lang)!=0">
															<xsl:attribute name="xml:lang">
															<xsl:value-of select="./@lang"/>
															</xsl:attribute>
												        </xsl:if>
														<xsl:value-of select="."/>
                                                    </lido:displayPlace>
                                                </xsl:for-each>
                                            </xsl:if>
                                            <lido:place>
                                                <xsl:for-each select="ort_geonames[(string-length(../ort_geonames) != 1)]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">geonames</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="concat('https://sws.geonames.org/', .)"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="ort_land[(string-length(../ort_land) != 1)]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">TGN</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="concat('http://vocab.getty.edu/tgn/', .)"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="noda_ort_Set/noda_source[(../noda_source = 'gnd')]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">gnd</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="../noda_link"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="noda_ort_Set/noda_source[(../noda_source = 'wikidata')]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">wikidata</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="../noda_link"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="noda_ort_Set/noda_source[(../noda_source = 'md:term')]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">md:term</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="../noda_link"/>
                                                    </lido:placeID>
                                                </xsl:for-each>

                                                <lido:namePlaceSet>
                                                    <xsl:if test="(ereignis_orte_sicher = 'n')">
                                                        <xsl:for-each select="ort_name[(../ereignis_orte_sicher = 'n')]">
                                                            <lido:appellationValue>
                                                                <xsl:if test="string-length(./@lang)!=0">
                                                                    <xsl:attribute name="xml:lang">
                                                                     <xsl:value-of select="./@lang"/>
                                                                    </xsl:attribute>
                                                                </xsl:if>
                                                                <xsl:value-of select="."/><!-- (wahrscheinlich) -->
   													        </lido:appellationValue>
                                                        </xsl:for-each>
                                                    </xsl:if>
                                                    <xsl:if test="(ereignis_orte_sicher != 'n')">
                                                        <xsl:for-each select="ort_name[(../ereignis_orte_sicher != 'n')]">
                                                            <lido:appellationValue>
                                                                <xsl:if test="string-length(./@lang)!=0">
                                                                    <xsl:attribute name="xml:lang">
                                                                        <xsl:value-of select="./@lang"/>
                                                                    </xsl:attribute>
                                                                </xsl:if>
                                                                <xsl:value-of select="."/>
                                                            </lido:appellationValue>
                                                        </xsl:for-each>
                                                    </xsl:if>
                                                </lido:namePlaceSet>
                                                <xsl:if test="ort_nord_sued!=''">
                                                    <lido:gml>
                                                        <gml:Point srsName="EPSG:4326">
                                                            <!-- Check this out -->
                                                            <gml:pos>
                                                                <xsl:value-of select="ort_nord_sued" />
                                                                <xsl:value-of select="' '" />
                                                                <xsl:value-of select="ort_west_ost" />
                                                            </gml:pos>
                                                        </gml:Point>
                                                    </lido:gml>
                                                </xsl:if>

                                            </lido:place>
                                        </lido:eventPlace>
                                    </xsl:if>
                                    <xsl:if test="ereignis_anmerkung!=''">
                                        <lido:eventDescriptionSet>
                                            <lido:descriptiveNoteID>
                                                <xsl:attribute name="lido:type">local</xsl:attribute>
                                                <xsl:value-of select="ereignis_id"/>
                                            </lido:descriptiveNoteID>
                                            <lido:descriptiveNoteValue>
                                                <xsl:value-of select="ereignis_anmerkung"/>
                                            </lido:descriptiveNoteValue>
                                            <lido:sourceDescriptiveNote>
                                            </lido:sourceDescriptiveNote>
                                        </lido:eventDescriptionSet>
                                    </xsl:if>
                                </lido:event>
                            </lido:eventSet>
                        </xsl:if>
                    </xsl:for-each>
                    <xsl:if test="objekt_material_technik!=''">
                        <lido:eventSet>
                            <lido:event>
                                <lido:eventType>
                                    <lido:conceptID lido:type="uri">http://terminology.lido-schema.org/lido00003</lido:conceptID>
                                    <lido:term>Event (non-specified)</lido:term>
                                </lido:eventType>
                                <lido:eventMaterialsTech>
                                    <xsl:for-each select="objekt_material_technik">
                                        <lido:displayMaterialsTech>
                                            <xsl:value-of select="."/>
                                        </lido:displayMaterialsTech>
                                    </xsl:for-each>
                                </lido:eventMaterialsTech>
                                <xsl:if test="material2!=''">
                                    <lido:eventMaterialsTech>
                                        <lido:materialsTech>
                                            <lido:termMaterialsTech lido:type="material">
                                                <lido:term>
                                                    <xsl:value-of select="material2"/>
                                                </lido:term>
                                            </lido:termMaterialsTech>
                                        </lido:materialsTech>
                                    </lido:eventMaterialsTech>
                                </xsl:if> 
                                <xsl:if test="technik2!=''">
                                    <lido:eventMaterialsTech>
                                        <lido:materialsTech>
                                            <lido:termMaterialsTech lido:type="technique">
                                                <lido:term>
                                                    <xsl:value-of select="technik2"/>
                                                </lido:term>
                                            </lido:termMaterialsTech>
                                        </lido:materialsTech>
                                    </lido:eventMaterialsTech>
                                </xsl:if> 
                            </lido:event>
                        </lido:eventSet>
                    </xsl:if>

                    <xsl:for-each select="objekt_record_set">
                        <xsl:if test="objekt_material_technik!='' and substring(objekt_record_weitergabe,1,1)=0">
                            <lido:eventSet>
                                <lido:event>
                                    <lido:eventType>
                                        <lido:term>Event (non-specified)</lido:term>
                                    </lido:eventType>
                                    <lido:eventMaterialsTech>
                                        <!--<xsl:for-each select="objekt_material_technik">-->
                                        <lido:displayMaterialsTech>
                                            <xsl:attribute name="xml:lang">
                                                <xsl:value-of select="objekt_record_lang" />
                                            </xsl:attribute>
                                            <xsl:value-of select="objekt_material_technik"/>
                                        </lido:displayMaterialsTech>
                                        <!--</xsl:for-each>-->
                                        <xsl:if test="material2!=''"> 
                                            <lido:materialsTech>
                                                <lido:termMaterialsTech lido:type="material">
                                                    <lido:term>
                                                        <xsl:value-of select="material2"/>
                                                    </lido:term>
                                                </lido:termMaterialsTech>
                                            </lido:materialsTech>
                                        </xsl:if> 
                                        <xsl:if test="technik2!=''">
                                            <lido:materialsTech>
                                                <lido:termMaterialsTech lido:type="technique">
                                                    <lido:term>
                                                        <xsl:value-of select="technik2"/>
                                                    </lido:term>
                                                </lido:termMaterialsTech>
                                            </lido:materialsTech>
                                        </xsl:if> 

                                    </lido:eventMaterialsTech>
                                </lido:event>
                            </lido:eventSet>
                        </xsl:if>
                    </xsl:for-each>
                </lido:eventWrap>
                
                <lido:objectRelationWrap>
                    <lido:subjectWrap>
                        <xsl:if test="eventSet/ereignistyp = '24'">
                            <xsl:for-each select="eventSet/zeiten_id[(../ereignistyp = '24')]">
                                <lido:subjectSet>
                                    <lido:subject>
                                        <lido:subjectDate>
                                            <xsl:for-each select="../zeit_name">
                                                <lido:displayDate>
													<xsl:if test="string-length(./@lang)!=0">
														<xsl:attribute name="xml:lang">
														<xsl:value-of select="./@lang"/>
														</xsl:attribute>
											        </xsl:if>
													<xsl:value-of select="."/>
 												    <xsl:if test="../ereignis_zeit_sicher = 'n'"> (?)</xsl:if>
                                               </lido:displayDate>
											</xsl:for-each>
                                            <lido:date>
                                                <xsl:for-each select="../zeit_beginn">
                                                    <xsl:if test="position() = 1">
                                                        <lido:earliestDate>
                                                            <xsl:value-of select="."/>
                                                        </lido:earliestDate>
                                                    </xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="../zeit_ende">
                                                    <xsl:if test="position() = 1">
                                                        <lido:latestDate>
                                                            <xsl:value-of select="."/>
                                                        </lido:latestDate>
                                                    </xsl:if>
                                                </xsl:for-each>
                                            </lido:date>
                                        </lido:subjectDate>
                                    </lido:subject>
                                </lido:subjectSet>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="eventSet/ereignistyp = '22'">
                            <xsl:for-each select="eventSet/orte_id[(../ereignistyp = '22')]">
                                <lido:subjectSet>
                                    <lido:subject>
                                        <lido:subjectPlace>
                                            <xsl:for-each select="../ort_name">
                                                <lido:displayPlace>
                                                    <xsl:if test="string-length(./@lang)!=0">
                                                        <xsl:attribute name="xml:lang">
                                                            <xsl:value-of select="./@lang"/>
                                                        </xsl:attribute>
                                                    </xsl:if>
                                                    <xsl:value-of select="."/>
													<xsl:if test="../ereignis_orte_sicher = 'n'"> (?)</xsl:if>
                                                </lido:displayPlace>
                                            </xsl:for-each>  
                                            <lido:place>
                                                <xsl:for-each select="../ort_geonames[(../ereignistyp = '22') and (string-length(../ort_geonames) != 1)]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">geonames</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="concat('https://sws.geonames.org/', .)"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="../ort_land[(../ereignistyp = '22') and (string-length(../ort_land) != 1)]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">TGN</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="concat('http://vocab.getty.edu/tgn/', .)"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="../noda_ort_Set/noda_source[(../noda_source = 'gnd')]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">gnd</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="../noda_link"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="../noda_ort_Set/noda_source[(../noda_source = 'wikidata')]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">wikidata</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="../noda_link"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="../noda_ort_Set/noda_source[(../noda_source = 'md:term')]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">md:term</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="../noda_link"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <lido:namePlaceSet>
                                            <xsl:for-each select="../ort_name">
                                                    <lido:appellationValue>
                                                    <xsl:if test="string-length(./@lang)!=0">
                                                        <xsl:attribute name="xml:lang">
                                                            <xsl:value-of select="./@lang"/>
                                                        </xsl:attribute>
                                                    </xsl:if>                                                        <xsl:value-of select="."/>
                                                    </lido:appellationValue>
                                            </xsl:for-each>  
                                                </lido:namePlaceSet>

                                                <xsl:if test="../ort_nord_sued[(../ereignistyp = '22')]">
                                                    <lido:gml>
                                                        <gml:Point srsName="EPSG:4326">
                                                            <!-- Check this out -->
                                                            <gml:pos>
                                                                <xsl:value-of select="../ort_nord_sued[(../ereignistyp = '22')]" />
                                                                <xsl:value-of select="' '" />
                                                                <xsl:value-of select="../ort_west_ost[(../ereignistyp = '22')]" />
                                                            </gml:pos>
                                                        </gml:Point>
                                                    </lido:gml>
                                                </xsl:if>
                                                <!--  -->
                                            </lido:place>
                                        </lido:subjectPlace>
                                    </lido:subject>
                                </lido:subjectSet>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="(eventSet/ereignistyp = '23') or (eventSet/ereignistyp = '5') or (eventSet/ereignistyp = '33')">
                            <xsl:for-each select="eventSet/persinst_id[(../ereignistyp = '23') or (../ereignistyp = '5') or (../ereignistyp = '33')]">
                                <lido:subjectSet>
                                    <lido:subject>
                                        <lido:subjectActor>
                                            <xsl:for-each select="../persinst_anzeigename[(../ereignistyp = '23') or (../ereignistyp = '5') or (../ereignistyp = '33')]">
                                                <lido:displayActor>
                                                    <xsl:value-of select="../persinst_anzeigename[(../ereignistyp = '23') or (../ereignistyp = '5') or (../ereignistyp = '33')]"/>
													<xsl:if test="../ereignis_persinst_sicher = 'n'"> (?)</xsl:if>
                                                </lido:displayActor>
                                            </xsl:for-each>
                                            <lido:actor>
                                                <xsl:for-each select="../nodaSet/noda_link[(../../ereignistyp = '23') or (../../ereignistyp = '5') or (../../ereignistyp = '33')]">
                                                    <xsl:if test="string-length(../noda_link)!=0">
                                                        <lido:actorID>
                                                            <xsl:attribute name="lido:source">
                                                                <xsl:value-of select="../noda_source[(../../ereignistyp = '23') or (../../ereignistyp = '5') or (../../ereignistyp = '33')]"/>
                                                            </xsl:attribute>
                                                            <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                            <xsl:value-of select="."/>
                                                        </lido:actorID>
                                                    </xsl:if>
                                                </xsl:for-each>
                                                <lido:nameActorSet>
                                                    <xsl:for-each select="../persinst_name">
                                                        <lido:appellationValue>
                                                           <xsl:if test="string-length(./@lang)!=0">
                                                                <xsl:attribute name="xml:lang">
                                                                    <xsl:value-of select="./@lang"/>
                                                                </xsl:attribute>
                                                            </xsl:if>
                                                            <xsl:value-of select="."/>
                                                        </lido:appellationValue>
                                                    </xsl:for-each>
                                                </lido:nameActorSet>
                                                <lido:vitalDatesActor>
                                                    <lido:earliestDate>
                                                        <xsl:value-of select="../persinst_geburtsjahr"/>
                                                    </lido:earliestDate>
                                                    <lido:latestDate>
                                                        <xsl:value-of select="../persinst_sterbejahr"/>
                                                    </lido:latestDate>
                                                </lido:vitalDatesActor>
                                            </lido:actor>
                                        </lido:subjectActor>
                                    </lido:subject>
                                </lido:subjectSet>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="(eventSet/ereignistyp = '36')">
                            <xsl:for-each select="eventSet/orte_id[(../ereignistyp = '36')]">
                                <lido:subjectSet>
                                    <lido:subject>
                                        <lido:subjectPlace>
											<xsl:if test="(../ereignis_orte_sicher = 'n')">
												<xsl:for-each select="../ort_name[(../ereignis_orte_sicher = 'n')]">
													<lido:displayPlace>
														<xsl:if test="string-length(./@lang)!=0">
															<xsl:attribute name="xml:lang">
															<xsl:value-of select="./@lang"/>
															</xsl:attribute>
															<xsl:value-of select="."/> (?)
														</xsl:if>
														<xsl:if test="string-length(./@lang) = 0">
															<xsl:value-of select="."/> (?)
														</xsl:if>
													</lido:displayPlace>
												</xsl:for-each>
											</xsl:if>
											<xsl:if test="(../ereignis_orte_sicher != 'n')">
												<xsl:for-each select="../ort_name[(../ereignis_orte_sicher != 'n')]">
													<lido:displayPlace>
														<xsl:if test="string-length(./@lang)!=0">
															<xsl:attribute name="xml:lang">
															<xsl:value-of select="./@lang"/>
															</xsl:attribute>
														</xsl:if>
														<xsl:value-of select="."/>
													</lido:displayPlace>
												</xsl:for-each>
											</xsl:if>
                                            <lido:place>
                                                <xsl:for-each select="../ort_geonames[(../ereignistyp = '36') and (string-length(../ort_geonames) != 1)]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">geonames</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="concat('https://sws.geonames.org/', .)"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="../ort_land[(../ereignistyp = '36') and (string-length(../ort_land) != 1)]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">TGN</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="concat('http://vocab.getty.edu/tgn/', .)"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="../noda_ort_Set/noda_source[(../noda_source = 'gnd')]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">gnd</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="../noda_link"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="../noda_ort_Set/noda_source[(../noda_source = 'wikidata')]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">wikidata</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="../noda_link"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <xsl:for-each select="../noda_ort_Set/noda_source[(../noda_source = 'md:term')]">
                                                    <lido:placeID>
                                                        <xsl:attribute name="lido:source">md:term</xsl:attribute>
                                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                        <xsl:value-of select="../noda_link"/>
                                                    </lido:placeID>
                                                </xsl:for-each>
                                                <lido:namePlaceSet>
                                                    <xsl:for-each select="../ort_name">
                                                        <lido:appellationValue>
                                                            <xsl:if test="string-length(./@lang)!=0">
                                                                <xsl:attribute name="xml:lang">
                                                                    <xsl:value-of select="./@lang"/>
                                                                </xsl:attribute>
                                                            </xsl:if>
                                                            <xsl:value-of select="."/>
                                                        </lido:appellationValue>
                                                    </xsl:for-each>  
                                                </lido:namePlaceSet>
                                                
                                                <xsl:if test="../ort_nord_sued[(../ereignistyp = '36')]">
                                                    <lido:gml>
                                                        <gml:Point srsName="EPSG:4326">
                                                            <!-- Check this out -->
                                                            <gml:pos>
                                                                <xsl:value-of select="../ort_nord_sued[(../ereignistyp = '36')]" />
                                                                <xsl:value-of select="' '" />
                                                                <xsl:value-of select="../ort_west_ost[(../ereignistyp = '36')]" />
                                                            </gml:pos>
                                                        </gml:Point>
                                                    </lido:gml>
                                                </xsl:if>
                                            </lido:place>
                                        </lido:subjectPlace>
                                    </lido:subject>
                                </lido:subjectSet>
                            </xsl:for-each>
                        </xsl:if>					

                        <xsl:for-each select="tagSet/tag_id">
                            <lido:subjectSet>
                                <lido:subject>
                                    <lido:subjectConcept>
                                        <xsl:for-each select="../noda_tag_Set/noda_source">
                                            <xsl:if test="string-length(../noda_link)!=0">
                                                <lido:conceptID>
                                                    <xsl:attribute name="lido:source">
                                                        <xsl:value-of select="../noda_source"/>
                                                    </xsl:attribute>
                                                    <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                    <xsl:value-of select="../noda_link"/>
                                                </lido:conceptID>
                                            </xsl:if>
                                        </xsl:for-each>
                                        <xsl:for-each select="../tag_name">
                                        <lido:term>
                                            <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>
                                            <xsl:if test="string-length(./@lang)!=0">
                                                <xsl:attribute name="xml:lang">
                                                    <xsl:value-of select="./@lang"/>
                                                </xsl:attribute>
                                            </xsl:if>
                                            <xsl:value-of select="."/>
                                        </lido:term>
                                        </xsl:for-each>
                                    </lido:subjectConcept>
                                </lido:subject>
                            </lido:subjectSet>
                        </xsl:for-each>
                    </lido:subjectWrap>

                    <lido:relatedWorksWrap>
                    
                        <xsl:for-each select="vergleichsobjekte2">
                            <lido:relatedWorkSet>
                                <lido:relatedWork>
                                        <lido:displayObject>
                                            <xsl:value-of select="."/>
                                        </lido:displayObject>
                                </lido:relatedWork>
                            </lido:relatedWorkSet>
                        </xsl:for-each>
                        
                            <xsl:for-each select="linkSet/link_id">
                            <lido:relatedWorkSet>
                                <lido:relatedWork>
                                    <xsl:for-each select="../link_anzeige">
                                        <lido:displayObject>
                                            <xsl:value-of select="."/>
                                        </lido:displayObject>
                                    </xsl:for-each>
                                    <lido:object>
                                        <xsl:for-each select="../link_text">
                                            <lido:objectWebResource>
                                                <!--                    <xsl:attribute name="lido:type">uri</xsl:attribute>-->     
                                                <xsl:value-of select="."/>
                                            </lido:objectWebResource>
                                        </xsl:for-each>
                                    </lido:object>
                                </lido:relatedWork>
                            </lido:relatedWorkSet>
                        </xsl:for-each>
                        <xsl:for-each select="literatureSet/literatur_id">
                            <lido:relatedWorkSet>
                                <lido:relatedWork>
                                    <xsl:if test="(../literatur_autor) and (../literatur_jahr) and (../literatur_titel) and (../literatur_erscheinungsort)">
                                        <lido:displayObject>
                                            <xsl:for-each select="../literatur_autor[(.) and (../literatur_jahr) and (../literatur_titel) and (../literatur_erscheinungsort)]">
                                                <xsl:value-of select="."/>
                                            </xsl:for-each>
                                            <xsl:if test="string-length(../literatur_autor) != 0">, </xsl:if>
                                            <xsl:for-each select="../literatur_jahr[(../literatur_autor) and (.) and (../literatur_titel) and (../literatur_erscheinungsort)]">
                                                <xsl:value-of select="."/>
                                            </xsl:for-each>
                                            <xsl:if test="string-length(../literatur_jahr) != 0">: </xsl:if>
                                            <xsl:for-each select="../literatur_titel[(../literatur_autor) and (../literatur_jahr) and (.) and (../literatur_erscheinungsort)]">
                                                <xsl:value-of select="."/>
                                            </xsl:for-each>
                                            <xsl:if test="string-length(../literatur_erscheinungsort) != 0">, <xsl:for-each select="../literatur_erscheinungsort[(../literatur_autor) and (../literatur_jahr) and (../literatur_titel) and (.)]">
                                                    <xsl:value-of select="."/>
                                                </xsl:for-each>
                                            </xsl:if>
                                            <xsl:if test="string-length(../inlit) != 0">, <xsl:for-each select="../inlit">
                                                    <xsl:value-of select="."/>
                                                </xsl:for-each>
                                            </xsl:if>
                                        </lido:displayObject>
                                    </xsl:if>
                                    <xsl:if test="string-length(../literatur_kvk) != 0 or string-length(../literatur_isbn) != 0 or string-length(../literatur_gnd) != 0 or string-length(../literatur_online) != 0">
                                        <lido:object>
                                            <xsl:for-each select="../literatur_kvk">
                                                <lido:objectWebResource>
                                                    <xsl:value-of select="."/>
                                                </lido:objectWebResource>
                                            </xsl:for-each>
                                            <xsl:for-each select="../literatur_isbn">
                                                <lido:objectID>
                                                    <xsl:attribute name="lido:type">ISBN</xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:objectID>
                                            </xsl:for-each>
                                            <xsl:for-each select="../literatur_gnd">
                                                <lido:objectID>
                                                    <xsl:attribute name="lido:source">dnb</xsl:attribute>
                                                    <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:objectID>
                                            </xsl:for-each>
                                            <xsl:for-each select="../literatur_online">
                                                <lido:objectID>
                                                    <xsl:attribute name="lido:type">uri</xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:objectID>
                                            </xsl:for-each>
                                        </lido:object>
                                    </xsl:if>
                                </lido:relatedWork>
                            </lido:relatedWorkSet>

                        </xsl:for-each>
                    </lido:relatedWorksWrap>
                </lido:objectRelationWrap>
            </lido:descriptiveMetadata>
            <lido:administrativeMetadata>
                <xsl:attribute name="xml:lang">de</xsl:attribute>
                <lido:rightsWorkWrap>

					<lido:rightsWorkSet>
                        <lido:rightsHolder>
                            <lido:legalBodyName>
                                <xsl:if test="institution_name!=''">
                                    <xsl:for-each select="institution_name">
                                        <lido:appellationValue>
                                            <xsl:value-of select="."/>
                                        </lido:appellationValue>
                                    </xsl:for-each>
                                </xsl:if>
                                <xsl:if test="institution_record_set!=''">
                                    <xsl:for-each select="institution_record_set">
                                        <xsl:if test="substring(institution_record_weitergabe,1,1)=0">
                                            <lido:appellationValue>
                                                <xsl:attribute name="xml:lang">
                                                    <xsl:value-of select="institution_record_lang" />
                                                </xsl:attribute>
                                                <xsl:value-of select="institution_name" />
                                            </lido:appellationValue>
                                        </xsl:if>
                                    </xsl:for-each>
                                </xsl:if>


                            </lido:legalBodyName>
                        </lido:rightsHolder>
                    </lido:rightsWorkSet>
                </lido:rightsWorkWrap>
                <lido:recordWrap>
                    <xsl:for-each select="objekt_id">
                        <lido:recordID>
                            <xsl:attribute name="lido:type">museum-digital</xsl:attribute>
                            <xsl:value-of select="."/>
                        </lido:recordID>
                    </xsl:for-each>
                    <lido:recordType>
                        <lido:term>
                            <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>item</lido:term>
                    </lido:recordType>
                    <lido:recordSource>
                        <xsl:attribute name="lido:type">dataProvider</xsl:attribute>
                        <lido:legalBodyName>
                            <lido:appellationValue>museum-digital</lido:appellationValue>
                        </lido:legalBodyName>
 <!--                       <lido:legalBodyWeblink>http://www.museum-digital.de</lido:legalBodyWeblink> -->
                        <lido:legalBodyWeblink>
                            <xsl:value-of select="md_version" />
                        </lido:legalBodyWeblink>
                    </lido:recordSource>
                    <lido:recordSource>
                        <xsl:for-each select="institution_isil">
                            <lido:legalBodyID>
                                <xsl:attribute name="lido:type">isil</xsl:attribute>
                                <xsl:value-of select="."/>
                            </lido:legalBodyID>
                        </xsl:for-each>
                        <lido:legalBodyName>
                            <xsl:for-each select="institution_name">
                                <lido:appellationValue>
                                    <xsl:value-of select="."/>
                                </lido:appellationValue>
                            </xsl:for-each>
                            <xsl:for-each select="institution_record_set">
                                <xsl:if test="substring(institution_record_weitergabe,1,1)=0">
                                    <lido:appellationValue>
                                        <xsl:attribute name="xml:lang">
                                            <xsl:value-of select="institution_record_lang" />
                                        </xsl:attribute>
                                        <xsl:value-of select="institution_name" />
                                    </lido:appellationValue>
                                </xsl:if>
                            </xsl:for-each>
                        </lido:legalBodyName>
                    </lido:recordSource>

                    <lido:recordRights>
					
                        <xsl:if test="(metadata_rights_status = '') or (metadata_rights_status = 'CC BY-NC-SA')">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://creativecommons.org/licenses/by-nc-sa/4.0/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>CC BY-NC-SA</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'CC BY-NC-ND'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://creativecommons.org/licenses/by-nc-nd/4.0/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>CC BY-NC-ND</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'CC BY-NC'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://creativecommons.org/licenses/by-nc/4.0/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>CC BY-NC</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'CC BY-ND'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://creativecommons.org/licenses/by-nd/4.0/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>CC BY-ND</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'CC BY-SA'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://creativecommons.org/licenses/by-sa/4.0/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>CC BY-SA</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'CC BY'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://creativecommons.org/licenses/by/4.0/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>CC BY</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'CC0'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://creativecommons.org/publicdomain/zero/1.0/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>CC 0</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'RR-F'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://www.europeana.eu/rights/rr-f/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>RR-F</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'RR-P'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://www.europeana.eu/rights/rr-p/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>RR-P</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'RR-R'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://www.europeana.eu/rights/rr-r/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>RR-R</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'Orphan Work'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://www.europeana.eu/rights/orphan-work-eu/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>Orphan Work</lido:term>
                            </lido:rightsType>
                        </xsl:if>
                        <xsl:if test="metadata_rights_status = 'Public Domain Mark'">
                            <lido:rightsType>
                                <lido:conceptID>
                                    <xsl:attribute name="lido:type">uri</xsl:attribute>https://creativecommons.org/publicdomain/mark/1.0/</lido:conceptID>
                                <lido:term>
                                    <xsl:attribute name="lido:addedSearchTerm">no</xsl:attribute>Public Domain Mark</lido:term>
                            </lido:rightsType>
                        </xsl:if>

                        <xsl:choose>
                            <xsl:when test="(normalize-space(metadata_rights_holder) != '') and (normalize-space(metadata_rights_holder) != normalize-space(institution_name))">
                                <lido:rightsHolder>
                                    <lido:legalBodyName>
                                        <lido:appellationValue>
                                            <xsl:value-of select="metadata_rights_holder"/>
                                        </lido:appellationValue>
                                    </lido:legalBodyName>
                                </lido:rightsHolder>
                            </xsl:when>
                            <xsl:otherwise>
                                <lido:rightsHolder>
                                    <xsl:for-each select="institution_isil">
                                        <lido:legalBodyID>
                                            <xsl:attribute name="lido:type">isil</xsl:attribute>
                                            <xsl:value-of select="."/>
                                        </lido:legalBodyID>
                                    </xsl:for-each>
                                    <lido:legalBodyName>
                                        <xsl:for-each select="institution_name">
                                            <lido:appellationValue>
                                                <xsl:value-of select="."/>
                                            </lido:appellationValue>
                                        </xsl:for-each>
                                        <xsl:for-each select="institution_record_set">
                                            <xsl:if test="substring(institution_record_weitergabe,1,1)=0">
                                                <lido:appellationValue>
                                                    <xsl:attribute name="xml:lang">
                                                        <xsl:value-of select="institution_record_lang" />
                                                    </xsl:attribute>
                                                    <xsl:value-of select="institution_ort" />
                                                </lido:appellationValue>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:legalBodyName>
                                    <xsl:for-each select="institution_url">
                                        <lido:legalBodyWeblink>
                                            <xsl:value-of select="."/>
                                        </lido:legalBodyWeblink>
                                    </xsl:for-each>
                                </lido:rightsHolder>
                            </xsl:otherwise>
                        </xsl:choose>
					
						<xsl:if test="acknowledgements!=''">
							<lido:creditLine>
								<xsl:value-of select="acknowledgements" />
							</lido:creditLine>
						</xsl:if>
						
                    </lido:recordRights>
                    <lido:recordInfoSet>
                        <xsl:for-each select="sources_objektinfo">
                            <lido:recordInfoLink>
                                <xsl:value-of select="."/>
                            </lido:recordInfoLink>
                        </xsl:for-each>
                        <xsl:for-each select="exportdatum">
                            <lido:recordMetadataDate>
                                <!--							  <lido:displayDate>  -->
                                <xsl:value-of select="."/>
                                <!--								</lido:displayDate>  -->
                            </lido:recordMetadataDate>
                        </xsl:for-each>
                    </lido:recordInfoSet>
                </lido:recordWrap>
                <lido:resourceWrap>
                    <xsl:for-each select="resourceSet/resource_location[(string-length(../resource_location) != 0)]">
                        <lido:resourceSet>
                            <xsl:for-each select="../resource_sortorder">
                                <xsl:attribute name="lido:sortorder">
                                    <xsl:if test="position() = 1">
                                        <xsl:value-of select="."/>
                                    </xsl:if>
                                </xsl:attribute>
                            </xsl:for-each>
                            

                            <xsl:for-each select="../resource_table_id">
                                <xsl:if test="position() = 1">
                                    <lido:resourceID>
                                        <xsl:attribute name="lido:source">
                                            <xsl:value-of select="../resource_table"/>
                                        </xsl:attribute>
                                        <xsl:attribute name="lido:type">local</xsl:attribute>
                                        <xsl:value-of select="."/>
                                    </lido:resourceID>
                                </xsl:if>
                            </xsl:for-each>

                            <xsl:for-each select="../resource_mediatype">
                                <xsl:if test="../resource_mediatype = 'image'">
                                    <xsl:for-each select="../resource_master_file">
                                        <xsl:if test="position() = 1">
                                            <lido:resourceRepresentation>
                                                <xsl:attribute name="lido:type">masterfile</xsl:attribute>
                                                <xsl:for-each select="../resource_master_file">
                                                    <xsl:if test="position() = 1">
                                                        <lido:linkResource>
                                                            <xsl:attribute name="lido:formatResource">image/tiff</xsl:attribute>
                                                            <xsl:value-of select="."/>
                                                        </lido:linkResource>
                                                    </xsl:if>
                                                </xsl:for-each>
                                            </lido:resourceRepresentation>
                                        </xsl:if>
                                    </xsl:for-each>
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">image_thumb</xsl:attribute>
                                        <xsl:for-each select="../resource_thumb_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">image/jpeg</xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">image_preview</xsl:attribute>
                                        <xsl:for-each select="../resource_preview_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">image/jpeg</xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">image_master</xsl:attribute>
                                        <xsl:for-each select="../resource_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">
                                                        <xsl:value-of select="../resource_mimetype"/>
                                                    </xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceType>
                                        <lido:term>
                                            <xsl:value-of select="../resource_mediatype"/>
                                        </lido:term>
                                    </lido:resourceType>
                                </xsl:if>                        
                            </xsl:for-each>

                            <xsl:for-each select="../resource_mediatype">
                                <xsl:if test="../resource_mediatype = 'audio'">
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">image_master</xsl:attribute>
                                        <xsl:for-each select="../resource_preview_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">image/jpeg</xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">audio</xsl:attribute>
                                        <xsl:for-each select="../resource_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">
                                                        <xsl:value-of select="../resource_mimetype"/>
                                                    </xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceType>
                                        <lido:term>
                                            <xsl:value-of select="../resource_mediatype"/>
                                        </lido:term>
                                    </lido:resourceType>
                                </xsl:if>                        
                            </xsl:for-each>

                            <xsl:for-each select="../resource_mediatype">
                                <xsl:if test="../resource_mediatype = 'video'">
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">image_master</xsl:attribute>
                                        <xsl:for-each select="../resource_preview_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">image/jpeg</xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">video</xsl:attribute>
                                        <xsl:for-each select="../resource_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">
                                                        <xsl:value-of select="../resource_mimetype"/>
                                                    </xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceType>
                                        <lido:term>
                                            <xsl:value-of select="../resource_mediatype"/>
                                        </lido:term>
                                    </lido:resourceType>
                                </xsl:if>                        
                            </xsl:for-each>

                            <xsl:for-each select="../resource_mediatype">
                                <xsl:if test="../resource_mediatype = '3d'">
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">3d_preview</xsl:attribute>
                                        <xsl:for-each select="../resource_preview_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">image/jpeg</xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">3d</xsl:attribute>
                                        <xsl:for-each select="../resource_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">
                                                        <xsl:value-of select="../resource_mimetype"/>
                                                    </xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceType>
                                        <lido:term>
                                            <xsl:value-of select="../resource_mediatype"/>
                                        </lido:term>
                                    </lido:resourceType>
                                </xsl:if>                        
                            </xsl:for-each>

                            <xsl:for-each select="../resource_mediatype">
                                <xsl:if test="../resource_mediatype = 'text'">
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">image_master</xsl:attribute>
                                        <xsl:for-each select="../resource_preview_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">image/jpeg</xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceRepresentation>
                                        <xsl:attribute name="lido:type">text</xsl:attribute>
                                        <xsl:for-each select="../resource_location">
                                            <xsl:if test="position() = 1">
                                                <lido:linkResource>
                                                    <xsl:attribute name="lido:formatResource">
                                                        <xsl:value-of select="../resource_mimetype"/>
                                                    </xsl:attribute>
                                                    <xsl:value-of select="."/>
                                                </lido:linkResource>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </lido:resourceRepresentation>
                                    <lido:resourceType>
                                        <lido:term>
                                            <xsl:value-of select="../resource_mediatype"/>
                                        </lido:term>
                                    </lido:resourceType>
                                </xsl:if>                        
                            </xsl:for-each>
                            
                            <xsl:if test="(../main_resource = 'j')">
                                <lido:resourceRelType>
                                    <lido:term>Hauptansicht</lido:term>
                                </lido:resourceRelType>
                            </xsl:if>
                            <xsl:for-each select="../resource_description">
								<xsl:if test=".!=''">
									<lido:resourceDescription>
										<xsl:value-of select="."/>
									</lido:resourceDescription>
								</xsl:if>
								<xsl:if test=".=''">
									<lido:resourceDescription>
										<xsl:value-of select="../resource_name"/>
									</lido:resourceDescription>
								</xsl:if>
                            </xsl:for-each>
                            <lido:resourceSource>
                                <xsl:attribute name="lido:type">owner</xsl:attribute>
                                <lido:legalBodyName>
                                    <xsl:for-each select="../resource_owner">
                                        <lido:appellationValue>
                                            <xsl:value-of select="."/>
                                        </lido:appellationValue>
                                    </xsl:for-each>
                                </lido:legalBodyName>
                            </lido:resourceSource>

                            <lido:resourceSource>
                                <xsl:attribute name="lido:type">creator</xsl:attribute>
                                <lido:legalBodyName>
                                    <xsl:for-each select="../resource_creator">
                                        <lido:appellationValue>
                                            <xsl:value-of select="."/>
                                        </lido:appellationValue>
                                    </xsl:for-each>
                                </lido:legalBodyName>
                            </lido:resourceSource>

                            <lido:rightsResource>
                                <lido:rightsType>
                                    <lido:conceptID>
                                        <xsl:attribute name="lido:type">uri</xsl:attribute>
                                        <xsl:value-of select="../resource_rights_url" />
                                    </lido:conceptID>
                                    <lido:term>
                                        <xsl:value-of select="../resource_rights"/>							  
                                    </lido:term>
                                </lido:rightsType>
                                <lido:rightsHolder>
                                    <lido:legalBodyName>
                                        <xsl:for-each select="../resource_owner">
                                            <lido:appellationValue>
                                                <xsl:value-of select="."/>
                                            </lido:appellationValue>
                                        </xsl:for-each>
                                    </lido:legalBodyName>
                                </lido:rightsHolder>
                                <xsl:for-each select="../resource_creator">
                                    <lido:creditLine>
                                        <xsl:value-of select="."/>
                                    </lido:creditLine>
                                </xsl:for-each>
                            </lido:rightsResource>
                        </lido:resourceSet>
                    </xsl:for-each>
                    <!--	
	
					
					<xsl:for-each select="imageSet/image_num_in_set[(string-length(../image_num_in_set) != 0)]">
            <lido:resourceSet>
              <xsl:attribute name="lido:sortorder">
                <xsl:for-each select="../image_num_in_set">
                  <xsl:if test="position() = 1">
                    <xsl:value-of select="."/>
                  </xsl:if>
                </xsl:for-each>
              </xsl:attribute>
              <xsl:for-each select="../image_id">
                <xsl:if test="position() = 1">
                  <lido:resourceID>
                    <xsl:attribute name="lido:type">local</xsl:attribute>
                    <xsl:value-of select="."/>
                  </lido:resourceID>
                </xsl:if>
              </xsl:for-each>
              <lido:resourceRepresentation>
                <xsl:attribute name="lido:type">image_thumb</xsl:attribute>
                <xsl:for-each select="../image_smallsize_fullpath">
                  <xsl:if test="position() = 1">
                    <lido:linkResource>
                      <xsl:attribute name="lido:formatResource">jpg</xsl:attribute>
                      <xsl:value-of select="."/>
                    </lido:linkResource>
                  </xsl:if>
                </xsl:for-each>
              </lido:resourceRepresentation>
              <lido:resourceRepresentation>
                <xsl:attribute name="lido:type">image_medium</xsl:attribute>
                <xsl:for-each select="../image_mediumsize_fullpath">
                  <xsl:if test="position() = 1">
                    <lido:linkResource>
                      <xsl:attribute name="lido:formatResource">jpg</xsl:attribute>
                      <xsl:value-of select="."/>
                    </lido:linkResource>
                  </xsl:if>
                </xsl:for-each>
              </lido:resourceRepresentation>
              <lido:resourceRepresentation>
                <xsl:attribute name="lido:type">image_master</xsl:attribute>
                <xsl:for-each select="../image_fullsize_fullpath">
                  <xsl:if test="position() = 1">
                    <lido:linkResource>
                      <xsl:attribute name="lido:formatResource">jpg</xsl:attribute>
                      <xsl:value-of select="."/>
                    </lido:linkResource>
                  </xsl:if>
                </xsl:for-each>
              </lido:resourceRepresentation>
							<xsl:if test="(../main_image = 'j')">
							  <lido:resourceRelType>
								  <lido:term>Hauptansicht</lido:term>
								</lido:resourceRelType>
							</xsl:if>
              <xsl:for-each select="../image_beschreibung">
                <lido:resourceDescription>
                  <xsl:value-of select="."/>
                </lido:resourceDescription>
              </xsl:for-each>
              <lido:resourceSource>
                <xsl:for-each select="../../institution_isil">
                  <lido:legalBodyID>
                    <xsl:attribute name="lido:type">isil</xsl:attribute>
                    <xsl:value-of select="."/>
                  </lido:legalBodyID>
                </xsl:for-each>
                <lido:legalBodyName>
                  <xsl:for-each select="../../institution_name">
                    <lido:appellationValue>
                      <xsl:value-of select="."/>
                    </lido:appellationValue>
                  </xsl:for-each>
                </lido:legalBodyName>
                <xsl:for-each select="../../institution_url">
                  <lido:legalBodyWeblink>
                    <xsl:value-of select="."/>
                  </lido:legalBodyWeblink>
                </xsl:for-each>
              </lido:resourceSource>
              <lido:rightsResource>
                <lido:rightsHolder>
                  <xsl:for-each select="../../institution_isil">
                    <lido:legalBodyID>
                      <xsl:attribute name="lido:type">isil</xsl:attribute>
                      <xsl:value-of select="."/>
                    </lido:legalBodyID>
                  </xsl:for-each>
                  <lido:legalBodyName>
                    <xsl:for-each select="../../institution_name">
                      <lido:appellationValue>
                        <![CDATA[<xsl:value-of select="."/>]]>
                      </lido:appellationValue>
                    </xsl:for-each>
                  </lido:legalBodyName>
                  <xsl:for-each select="../../institution_url">
                    <lido:legalBodyWeblink>
                      <xsl:value-of select="."/>
                    </lido:legalBodyWeblink>
                  </xsl:for-each>
                </lido:rightsHolder>
                <xsl:for-each select="../image_rights">
                  <lido:creditLine>
                    <xsl:value-of select="."/>
                  </lido:creditLine>
                </xsl:for-each>
              </lido:rightsResource>
            </lido:resourceSet>
          </xsl:for-each>
					-->
                </lido:resourceWrap>
            </lido:administrativeMetadata>
        </lido:lido>
    </xsl:template>
</xsl:stylesheet>