parameters: (xml, identifier="", vals={}, regions=[], keywords=[], custom={})
return_statement: return [identifier, vals, regions, keywords, custom]
docstring: Generate dict of model properties based on XML metadata
docstring_summary: Generate dict of model properties based on XML metadata
docstring_tokens: Generate dict of model properties based on XML metadata
function: def set_metadata(xml, identifier="", vals={}, regions=[], keywords=[], custom={}):
      """Generate dict of model properties based on XML metadata"""
  
      # check if document is XML
      try:
          exml = dlxml.fromstring(xml.encode())
      except Exception as err:
          raise GeoNodeException(
              f'Uploaded XML document is not XML: {str(err)}')
  
      # check if document is an accepted XML metadata format
      tagname = get_tagname(exml)
  
      if tagname == 'GetRecordByIdResponse':  # strip CSW element
          LOGGER.debug('stripping CSW root element')
          exml = list(exml)[0]
          tagname = get_tagname(exml)
  
      if tagname == 'MD_Metadata':  # ISO
          identifier, vals, regions, keywords = iso2dict(exml)
      elif tagname == 'metadata':  # FGDC
          identifier, vals, regions, keywords = fgdc2dict(exml)
      elif tagname == 'Record':  # Dublin Core
          identifier, vals, regions, keywords = dc2dict(exml)
      else:
          raise RuntimeError('Unsupported metadata format')
  
      if not vals.get("date"):
          vals["date"] = datetime.datetime.now(timezone.get_current_timezone()).strftime("%Y-%m-%dT%H:%M:%S")
  
      return [identifier, vals, regions, keywords, custom]
function_tokens: def set_metadata ( xml , identifier = "" , vals = { } , regions = [ ] , keywords = [ ] , custom = { } ) : # check if document is XML try : exml = dlxml . fromstring ( xml . encode ( ) ) except Exception as err : raise GeoNodeException ( f'Uploaded XML document is not XML: {str(err)}' ) # check if document is an accepted XML metadata format tagname = get_tagname ( exml ) if tagname == 'GetRecordByIdResponse' : # strip CSW element LOGGER . debug ( 'stripping CSW root element' ) exml = list ( exml ) [ 0 ] tagname = get_tagname ( exml ) if tagname == 'MD_Metadata' : # ISO identifier , vals , regions , keywords = iso2dict ( exml ) elif tagname == 'metadata' : # FGDC identifier , vals , regions , keywords = fgdc2dict ( exml ) elif tagname == 'Record' : # Dublin Core identifier , vals , regions , keywords = dc2dict ( exml ) else : raise RuntimeError ( 'Unsupported metadata format' ) if not vals . get ( "date" ) : vals [ "date" ] = datetime . datetime . now ( timezone . get_current_timezone ( ) ) . strftime ( "%Y-%m-%dT%H:%M:%S" ) return [ identifier , vals , regions , keywords , custom ]