<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic arcpy.XSLTransform_conversion Functionality in Pro --&amp;gt; Location of xml Templates in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-xsltransform-conversion-functionality-in-pro/m-p/1054754#M40609</link>
    <description>&lt;P&gt;Hi everybody.&amp;nbsp; Trying to "stamp" (term I made up - makes sense?) metadata in feature classes within file geodatabase utilizing arcpy functionality in Pro - looping through an entire gdb, so many fcs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am cannibalizing pieces from this script: .&amp;nbsp;&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/how-can-i-refresh-metadata-on-geodatabase-feature-classes/m-p/159598" target="_self"&gt;esri forum metadata post&lt;/A&gt;.&amp;nbsp; Note that I am NOT interested in the Thumbnail portion, just basic workflow to update Item Description via: 1) pull xml from feature classes within gdb 2) update a handful of xml elements (abstract, purpose, credits, etc.) in xml 3) update xml in gdb.&amp;nbsp; I am utilizing xmltree and pandas dataframes in Python scripts for the workflow FYI.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My dumbed-down pseudocode is as follows:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fcs = 'path/to/feature_class'
# below line yields - 'C:\Program Files\ArcGIS\Pro'
dir = arcpy.GetInstallInfo('desktop')['InstallDir']
# but exact copy of.xslt is NOT here - can be found in desktop folder
copy_xslt = r'{0}'.format(os.path.join(dir,'Metadata\Stylesheets\gpTools\exact copy of.xslt'))
# temporary XML file
xml_file = arcpy.CreateScratchName('.xml',workspace=arcpy.env.scratchFolder)
xml_file = 'name.xml'
XSLTransform_conversion(fcs, copy_xslt, xml_file,'')
arcpy.MetadataImporter_conversion(xml_file, fcs)&lt;/LI-CODE&gt;&lt;P&gt;The main thing confusing me is that&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dir = arcpy.GetInstallInfo('desktop')['InstallDir']&lt;/LI-CODE&gt;&lt;P&gt;YIELDS: C:\Program Files\ArcGIS\Pro\Resources\Metadata\Stylesheets&amp;nbsp; but does NOT have the "exact copy of.xslt".&amp;nbsp; If I go 'C:\Program Files (x86)\ArcGIS\Desktop10.6\Metadata\Stylesheets' then it exists.&amp;nbsp; However the online documentation indicates that the Pro file ...Stylesheets subdirectory should have that file.&amp;nbsp; Any idea why I don't have it and should I be concerned?&amp;nbsp; I will basically just hardcode the file path the xslt file while running scripts via Pro.&lt;/P&gt;</description>
    <pubDate>Wed, 05 May 2021 16:55:30 GMT</pubDate>
    <dc:creator>ZacharyUhlmann1</dc:creator>
    <dc:date>2021-05-05T16:55:30Z</dc:date>
    <item>
      <title>arcpy.XSLTransform_conversion Functionality in Pro --&gt; Location of xml Templates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-xsltransform-conversion-functionality-in-pro/m-p/1054754#M40609</link>
      <description>&lt;P&gt;Hi everybody.&amp;nbsp; Trying to "stamp" (term I made up - makes sense?) metadata in feature classes within file geodatabase utilizing arcpy functionality in Pro - looping through an entire gdb, so many fcs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am cannibalizing pieces from this script: .&amp;nbsp;&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/how-can-i-refresh-metadata-on-geodatabase-feature-classes/m-p/159598" target="_self"&gt;esri forum metadata post&lt;/A&gt;.&amp;nbsp; Note that I am NOT interested in the Thumbnail portion, just basic workflow to update Item Description via: 1) pull xml from feature classes within gdb 2) update a handful of xml elements (abstract, purpose, credits, etc.) in xml 3) update xml in gdb.&amp;nbsp; I am utilizing xmltree and pandas dataframes in Python scripts for the workflow FYI.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My dumbed-down pseudocode is as follows:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fcs = 'path/to/feature_class'
# below line yields - 'C:\Program Files\ArcGIS\Pro'
dir = arcpy.GetInstallInfo('desktop')['InstallDir']
# but exact copy of.xslt is NOT here - can be found in desktop folder
copy_xslt = r'{0}'.format(os.path.join(dir,'Metadata\Stylesheets\gpTools\exact copy of.xslt'))
# temporary XML file
xml_file = arcpy.CreateScratchName('.xml',workspace=arcpy.env.scratchFolder)
xml_file = 'name.xml'
XSLTransform_conversion(fcs, copy_xslt, xml_file,'')
arcpy.MetadataImporter_conversion(xml_file, fcs)&lt;/LI-CODE&gt;&lt;P&gt;The main thing confusing me is that&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dir = arcpy.GetInstallInfo('desktop')['InstallDir']&lt;/LI-CODE&gt;&lt;P&gt;YIELDS: C:\Program Files\ArcGIS\Pro\Resources\Metadata\Stylesheets&amp;nbsp; but does NOT have the "exact copy of.xslt".&amp;nbsp; If I go 'C:\Program Files (x86)\ArcGIS\Desktop10.6\Metadata\Stylesheets' then it exists.&amp;nbsp; However the online documentation indicates that the Pro file ...Stylesheets subdirectory should have that file.&amp;nbsp; Any idea why I don't have it and should I be concerned?&amp;nbsp; I will basically just hardcode the file path the xslt file while running scripts via Pro.&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 16:55:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-xsltransform-conversion-functionality-in-pro/m-p/1054754#M40609</guid>
      <dc:creator>ZacharyUhlmann1</dc:creator>
      <dc:date>2021-05-05T16:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.XSLTransform_conversion Functionality in Pro --&gt; Location of xml Templates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-xsltransform-conversion-functionality-in-pro/m-p/1054844#M40620</link>
      <description>&lt;P&gt;If a tree in the falls in the forest and no one's around to hear it in practice:&lt;/P&gt;&lt;P&gt;Well, I figured it out.&amp;nbsp; Should have read the ArcPro docs more thoroughly because they have basically simplified (in my view) the syntax and process to copy metadata in the updating xml from gdb process (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/migrating-from-arcmap-to-arcgis-pro.htm" target="_self"&gt;arcpro docs&lt;/A&gt;&amp;nbsp;).&amp;nbsp; Instead of referencing an xslt file ('exact copy of.xslt') in the bowels of the ArcPro folder structure as an argument in the Desktop XSLTransformation_conversion function , they replaced it with an argument in the Pro version of the function called arcpy.saveAsXML in which you pass a string argument - in this case 'EXACT COPY' which performs the same purpose of&amp;nbsp; `exact copy of.xslt'.&amp;nbsp; 'EXACT COPY' most likely transforms your metadata using that same xslt without having to explicitly pass the file path.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcpy import metadata as md
fp_fcs = 'path/to/fcs'
tgt_item_md = md.Metadata(fp_fcs)
xml_file = arcpy.CreateScratchName('.xml', workspace = arcpy.env.scratchFolder)
tgt_item_md.saveAsXML(xml_file, 'EXACT_COPY')
# From here - update the xml_file and then update the target: Update xml file using xml.etree.ElementTree protocol - examples all over the internet - in this case to update my Item Description 'idPurp' or 'idAbstract'
src_template_md = md.Metadata(xml_file)
tgt_item_md.copy(src_template_md)
tgt_item_md.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Someday in four years somebody will stumble across this and hopefully not get dumber...&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 19:15:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-xsltransform-conversion-functionality-in-pro/m-p/1054844#M40620</guid>
      <dc:creator>ZacharyUhlmann1</dc:creator>
      <dc:date>2021-05-05T19:15:57Z</dc:date>
    </item>
  </channel>
</rss>

