Closed jlaura closed 3 years ago
I would try something like this:
class CustomParser(FgdcParser):
def _init_data_map(self):
if self._data_map is not None:
return
super(CustomParser, self)._init_data_map()
# Overridden to reverse primary and secondary contact paths
self._data_structures[CONTACTS] = format_xpaths(
FGDC_DEFINITIONS[CONTACTS],
name=ct_format.format(ct_path='cntorgp/cntper'),
_name=ct_format.format(ct_path='cntperp/cntper'), # If not in cntorgp
organization=ct_format.format(ct_path='cntorgp/cntorg'),
_organization=ct_format.format(ct_path='cntperp/cntorg'), # If not in cntorgp
position=ct_format.format(ct_path='cntpos'),
email=ct_format.format(ct_path='cntemail')
)
:+1:
Thank you for the info. I am going to close as this solution is working for me right now. I will also spend some time thinking about how to handle FGDC contacts that occur in 3+ different places and how that might be as elegantly handled as this library handles other properties. And then how it might be possible to have a primary contact that is the organization and a producer contact that is a specific person.
Docs do a great job describing secondary lookup locations, e.g. :
This then supports reading from a path such as
cntorgp/cntorg
in a FGDC metadata file. Docs also indicate that secondary properties are parsed, but not validated or written.Does any method exist to set the secondary as the primary? For example, compliant FGDC has either a primary contact person or a primary contact organization. Right now, I am not sure how to serialize the latter as a primary contact organization is specified as the secondary property. The result is XML like so on write:
The desired output is: