kitodo / kitodo-ugh

Kitodo.UGH Library
2 stars 10 forks source link

Wrong evaluation of WriteXPath writing metadata groups #85

Closed matthias-ronge closed 2 years ago

matthias-ronge commented 5 years ago

Given the following <Mets> export rules:

<Group>
    <InternalName>Author</InternalName>
    <WriteXPath>./mods:mods/#mods:name[@type='personal'][mods:role]</WriteXPath>
    <Metadata>
        <InternalName>Author_Firstname</InternalName>
        <WriteXPath>./#mods:namePart[@type='given']</WriteXPath>
    </Metadata>
    <Metadata>
        <InternalName>Author_Lastname</InternalName>
        <WriteXPath>./#mods:namePart[@type='family']</WriteXPath>
    </Metadata>                
    <Metadata>
        <InternalName>Author_Relationcode</InternalName>
        <WriteXPath>./mods:role/#mods:roleTerm[@type='code'][@authority='marcrelator']</WriteXPath>
    </Metadata>
    <Metadata>
        <InternalName>Author_Relationtext</InternalName>
        <WriteXPath>./mods:role/#mods:roleTerm[@type='text']</WriteXPath>
    </Metadata>                
    <Metadata>
        <InternalName>Author_Expansion</InternalName>
        <WriteXPath>./#mods:displayForm</WriteXPath>
    </Metadata>
    <Metadata>
        <InternalName>Author_GNDID</InternalName>
        <WriteXPath>./@valueURI</WriteXPath>   
        <namespaceXPath>./@authorityURI</namespaceXPath>
        <prefixXPath>./@authority</prefixXPath>
    </Metadata>
    <Metadata>
        <InternalName>Author_Date</InternalName>
        <WriteXPath>./#mods:namePart[@type='date']</WriteXPath>
    </Metadata>
</Group>

produces an output like:

<mods:name type="personal" valueURI="http://d-nb.info/gnd/116040149">
    <mods:role/>
    <mods:namePart type="given">Johann Wilhelm</mods:namePart>
    <mods:namePart type="family">Baier</mods:namePart>
    <mods:role>
        <mods:roleTerm authority="marcrelator" type="code">aut</mods:roleTerm>
    </mods:role>
    <mods:role>
        <mods:roleTerm type="text">VerfasserIn1</mods:roleTerm>
    </mods:role>
    <mods:displayForm>Baier, Johann Wilhelm</mods:displayForm>
    <mods:namePart type="date">1647-1695</mods:namePart>
</mods:name>

The two <mods:roleTerm> values appear inside separate <mods:role> elements, where they should share the same <mods:role> element.