Select to view content in your preferred language

Has anyone exported Metadata using a custom XSLT?

519
2
06-13-2024 11:45 AM
Labels (1)
cordtsra
Emerging Contributor

I am on Pro version 3.2.0. I am currently working on exporting feature class level metadata to xml files using a custom XSLT. I am currently getting the following error

 RuntimeError: Failed to export metadata to 's'
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_ return fn(*args, **kw) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\metadata.py", line 144, in exportMetadata return _convertArcObjectToPythonObject(arcgisscripting.metadata.Metadata.exportMetadata(*_gp_fixargs((self, outputPath, metadata_export_option, metadata_removal_option, customStylesheetPath), True))) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\arcobjects\arcobjectconversion.py", line 67, in convertArcObjectToPythonObject name=type(obj).__name__ SystemError: <class 'type'> returned a result with an error set

 

My code is attached below.

 

xslt = r'C:/Documents/Custom.xslt'
if os.path.isfile(xslt):
    arcpy.AddMessage("xslt located")
else:
    arcpy.AddError("xslt file does not exist")

for fc, fcpath in FCtoFCPath.items():
    fcToExport=md.Metadata(fcpath)
    fcToExport.exportMetadata(os.path.join(mdir, fc + ".xml"), 'CUSTOM', 'EXACT_COPY', xslt)

 

If I change the last line of my code to

 

fcToExport.exportMetadata(os.path.join(mdir, fc + ".xml"), 'FGDC_CSDGM', 'EXACT_COPY')

 

The script executes without error, but it is not in the format that I need. Has anyone else had this error before, or know what might be causing the error?

 

2 Replies
urquidid
Emerging Contributor

Hi! We're also a bit mystified by the format conversion outputs from/into ESRI and aiming to develop our own XSLTs for a migration. I'm not sure if this helps you at all, but our developer has been looking into reusing some of the Geoportal Server Catalog (https://github.com/Esri/geoportal-server-catalog/tree/master/geoportal/src/main/resources/metadata/x...) and Harvester (https://github.com/Esri/geoportal-server-harvester/tree/master/geoportal-commons/geoportal-commons-m...) packaged XSLTs. As an open source project adjacent to ESRI, I believe that folks in the community have been developing support to export ESRI into other ISO profiles, including the European INSPIRE and UK GEMINI initiatives. Not sure how much they support feature-level metadata export, but I think it's worth looking into how these folks are doing it.

0 Kudos
TimHaverlandNOAA
Regular Contributor

Hi did you ever find a solution to this problem? I'm trying to do a custom xslt transform and getting the same  error "SystemError: <class 'type'> returned a result with an error set" 

0 Kudos