Generic XML Tips : Copy All to Construct 3 Creators (AND in Exists Condition)
Please send suggestions and improvements to joan.kolarik@weizmann.ac.il
Both these methods will create 3 creator fields if the source record contains 3 or more creators.
A sample source record XML:
<mods:name type="personal">
<mods:role>
<mods:roleTerm type="text" authority="pure/role">author</mods:roleTerm>
</mods:role>
<mods:namePart type="given">Yuri</mods:namePart>
<mods:namePart type="family">Lima</mods:namePart>
<mods:affiliation>
Univ Fed Ceara, Universidade Federal do Ceara, Dept Matemat
</mods:affiliation>
</mods:name>
Method 1
These copy all examples take all child subfields, in the order that they occur, and create a field containing both subfields with a space between -- from the sample above, the result will be "Yuri Lima"
rule "creator1"
when
exist "//*[local-name()='mods']/*[local-name()='name' and @type='personal'][1]/child::*[local-name()='namePart']"
then
copy all "//*[local-name()='mods']/*[local-name()='name' and @type='personal'][1]/child::*[local-name()='namePart']/text()"(", ") to "dc"."creator"
end
rule "creator2"
when
exist "//*[local-name()='mods']/*[local-name()='name' and @type='personal'][2]/child::*[local-name()='namePart']"
then
copy all "//*[local-name()='mods']/*[local-name()='name' and @type='personal'][2]/child::*[local-name()='namePart']/text()"(", ") to "dc"."creator"
end
rule "creator3"
when
exist "//*[local-name()='mods']/*[local-name()='name' and @type='personal'][3]/child::*[local-name()='namePart']"
then
set "et al" in "dc"."creator"
end
Method 2
These copy examples take 2 specific child subfields (family and given) and create a field containing both with a comma and space between -- from the sample above, the result will be "Lima, Yuri"
rule "creator1"
when
exist "//*[@type='personal'][1]/child::*[local-name()='namePart']"
then
copy "concat( //*[@type='personal'][1]/child::*[local-name()='namePart'][@type='family']/text(), ', ', //*[@type='personal'][1]/child::*[local-name()='namePart'][@type='given']/text())" to "dc"."creator"
end
rule "creator2"
when
exist "//*[@type='personal'][2]/child::*[local-name()='namePart']"
then
copy "concat( //*[@type='personal'][2]/child::*[local-name()='namePart'][@type='family']/text(), ', ', //*[@type='personal'][2]/child::*[local-name()='namePart'][@type='given']/text())" to "dc"."creator"
end
rule "creator3"
when
exist "//*[@type='personal'][3]/child::*[local-name()='namePart']"
then
copy "concat( //*[@type='personal'][3]/child::*[local-name()='namePart'][@type='family']/text(), ', ', //*[@type='personal'][3]/child::*[local-name()='namePart'][@type='given']/text())" to "dc"."creator"
end
Return to Contents Page for Generic XML Tips