delving / sip-creator

The Delving SIP-Creator
sip-creator.delving.eu
9 stars 3 forks source link

Empty elements in output #169

Closed glamcloud closed 12 years ago

glamcloud commented 12 years ago

This have been discussed but still has to be resolved sometime. In the record below some of the elements are and branches are empty and should not be part of output.

    <aff:relations>
        <aff:relation aff:typeUri="http://id.culturecloud.eu/concepts/#isPartOf"/>
    </aff:relations>

     <aff:concept aff:type="Technique" aff:typeUri="http://www.cidoc-crm.org/rdfs/P32F"/>
<?xml version="1.0" encoding="UTF-8"?>
<aff:record xmlns:aff="http://schemas.delving.eu/aff/">
    <aff:admin>
        <aff:displayDataProvider>Princessehof</aff:displayDataProvider>
        <aff:displayProvider>Friese Verhalen</aff:displayProvider>
    </aff:admin>
    <aff:thing aff:lang="nl" aff:localId="04020">
        <aff:uri>04020</aff:uri>
        <aff:displayIdentification>04020</aff:displayIdentification>
        <aff:displayTitle>Drie monniken te Maredsous</aff:displayTitle>
        <aff:displayDescription>Op het schilderij zijn, tegen een grijze achtergrond, drie monniken in zwarte pij afgebeeld. De middelste monnik is en face weergegeven en de beide anderen en profil naar rechts kijkend. Ze kijken zeer ingetogen. Zij zijn niet in hun volle lengte geschilderd. Tot op de hoogte van hun taille is een bruine lambrisering.</aff:displayDescription>
        <aff:displayInscription>Walter Vaes., Het Singer Museum, Laren N/.H. met tekst: nr. 773, Walter Vaes</aff:displayInscription>
        <aff:displayRights>http://creativecommons.org/publicdomain/mark/1.0/</aff:displayRights>
    </aff:thing>
    <aff:relations>
        <aff:relation aff:typeUri="http://id.culturecloud.eu/concepts/#isPartOf"/>
    </aff:relations>
    <aff:concepts>
        <aff:concept aff:type="Work type" aff:typeUri="http://id.culturecloud.eu/concepts/#workType">
            <aff:displayConcept>schildering</aff:displayConcept>
        </aff:concept>
        <aff:concept aff:type="Object name/keyword" aff:typeUri="http://id.culturecloud.eu/concepts/#objectName">
            <aff:displayConcept>schilderij</aff:displayConcept>
            <aff:displayConcept>paneel</aff:displayConcept>
            <aff:displayConcept>olieverf</aff:displayConcept>
        </aff:concept>
        <aff:concept aff:type="Subject" aff:typeUri="http://www.cidoc-crm.org/rdfs/P129B">
            <aff:displayConcept>groepsportret</aff:displayConcept>
            <aff:displayConcept>monniken</aff:displayConcept>
            <aff:displayConcept>België-Maredsous</aff:displayConcept>
        </aff:concept>
        <aff:concept aff:type="Material" aff:typeUri="http://www.cidoc-crm.org/rdfs/E57">
            <aff:displayConcept>hout</aff:displayConcept>
            <aff:displayConcept>olieverf</aff:displayConcept>
        </aff:concept>
        <aff:concept aff:type="Technique" aff:typeUri="http://www.cidoc-crm.org/rdfs/P32F"/>
    </aff:concepts>
    <aff:events>
        <aff:event aff:typeUri="http://www.cidoc-crm.org/rdfs/.E12.Production"/>
        <aff:event aff:typeUri="http://www.cidoc-crm.org/rdfs/E65.Creation">
            <aff:eventActor>
                <aff:displayActor>Vaes, Walter</aff:displayActor>
                <aff:relatedEvent aff:typeUri="http://www.cidoc-crm.org/rdfs/E67.Birth">
                    <aff:displayDate>1882</aff:displayDate>
                </aff:relatedEvent>
                <aff:relatedEvent aff:typeUri="http://www.cidoc-crm.org/rdfs/E69.Death">
                    <aff:displayDate>1958</aff:displayDate>
                </aff:relatedEvent>
            </aff:eventActor>
        </aff:event>
        <aff:event aff:typeUri="http://www.cidoc-crm.org/rdfs/E8.Acquisition">
            <aff:displayDate>1982-01-01</aff:displayDate>
            <aff:displayMethod>schenking</aff:displayMethod>
            <aff:eventActor>
                <aff:displayActor>Heesters, Jan</aff:displayActor>
            </aff:eventActor>
        </aff:event>
    </aff:events>
    <aff:resources>
        <aff:resource aff:typeUri="http://id.culturecloud.eu/concepts/#thumbnail">
            <aff:resourceUrl>M:\JHH_Collectie\Registratiefoto\04000-04099\04020.JPG</aff:resourceUrl>
            <aff:resourceUrl>M:\JHH_Collectie\Registratiefoto\04000-04099\04020a.JPG</aff:resourceUrl>
        </aff:resource>
        <aff:resource aff:typeUri="http://id.culturecloud.eu/concepts/#fullImage">
            <aff:resourceUrl>M:\JHH_Collectie\Registratiefoto\04000-04099\04020.JPG</aff:resourceUrl>
            <aff:resourceUrl>M:\JHH_Collectie\Registratiefoto\04000-04099\04020a.JPG</aff:resourceUrl>
        </aff:resource>
        <aff:resource aff:typeUri="http://id.culturecloud.eu/concepts/#landingPage">
            <aff:resourceUrl>04020</aff:resourceUrl>
        </aff:resource>
    </aff:resources>
</aff:record>
geralddejong commented 12 years ago

A previous solution which prunes empty elements from the tree that comes out of running the mapping won't work. These elements are not empty, so that can't be done here.

As a result, the only way to solve this problem is to generate slightly different code that avoids creating these entries in the first place. To do this I have to be able to look at the code that is doing this. Could you copy that code to here as well, or provide me with this whole dataset so I can reproduce it myself. This should all actually be part of a unit test.

geralddejong commented 12 years ago

It would be solved manually by also mapping things to the outer element so that the looping gets done at that level (and prevents the empty one from appearing). That pointed to a potential trick.

So what I did was have the code create a virtual node mapping on these opt-elements when all of the children map from the same input path. Now the generated code is different because it loops the opt-element, which means that when there is no input, there is no output of that opt-element.

This should fix it, and it appears to be a safe new general code-generation rule.

glamcloud commented 12 years ago

ok