metafacture / metafacture-fix

Work in progress towards an implementation of the Fix language for Metafacture
Apache License 2.0
6 stars 2 forks source link

Nested do list does not work wih creating arrays?? #292

Closed TobiasNx closed 1 year ago

TobiasNx commented 1 year ago

In context of oersi we found tghe following

do list(path:"html.head.meta","var":"$i") does not work with element-mappins (id, name, description, dateCreated, license work, creator and inLanguage do not work and create empty arrays). the difference seems to be mappin into an array.

vacuum()
do list(path:"html.head.meta","var":"$i")

  /* Map some of the data we have to the oersi model: */
  # ---------------id --------
  copy_field("$i.DC_Identifier_URI", "id")

  # ---------------name --------
  copy_field("$i.citation_title", "name")

  # ---------------description --------
  copy_field("$i.DC_Description", "description")

  # ---------------dateCreated --------
  copy_field("$i.DC_Date_created", "dateCreated")

      # ---------------license --------
  if any_match("$i.DC_Rights","https://creativecommons.org/.*")
    copy_field("$i.DC_Rights", "license.id")
  end

  # ------ creator --- 
  set_array("creator[]")
  copy_field("$i.DC_Creator_PersonalName", "creator[].$append.name")
  add_field("creator[].*.type", "Person")

  # ------ inLanguage------
  set_array("inLanguage[]")
  copy_field("$i.DC_Language", "inLanguage[].$append")

end

retain("@context[]","id","image","name","creator[]","contributor[]","sourceOrganization[]", "license","description","datePublished","dateCreated","dateModified","inLanguage[]","type[]","learningResourceType[]","keywords[]","about[]", "encoding[]", "publisher[]", "isPartOf[]", "mainEntityOfPage[]","conditionsOfAccess","duration")

See Playground

when setting the do list path deeper it works: do list(path:"html.head.meta.DC_Creator_PersonalName","var":"$i")


do list(path:"html.head.meta.DC_Creator_PersonalName","var":"$i")
  # ------ creator --- 
  set_array("creator[]")
  copy_field("$i", "creator[].$append.name")
end
add_field("creator[].*.type", "Person")

do list(path:"html.head.meta.DC_Language","var":"$i")
  # ------ inLanguage------
  set_array("inLanguage[]")
  copy_field("$i", "inLanguage[].$append")
end

retain("@context[]","id","image","name","creator[]","contributor[]","sourceOrganization[]", "license","description","datePublished","dateCreated","dateModified","inLanguage[]","type[]","learningResourceType[]","keywords[]","about[]", "encoding[]", "publisher[]", "isPartOf[]", "mainEntityOfPage[]","conditionsOfAccess","duration")

it works,. see playground

blackwinter commented 1 year ago

set_array("creator[]") set_array("inLanguage[]")

You're clearing these arrays during every iteration, and the last one (<meta name="citation_publisher" content="Language Science Press"/>) does not contain any relevant data for these fields.