Hi
I'm testing this custom class to export metadata using ArcGIS 10.1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.Catalog;
using ESRI.ArcGIS.Geodatabase;
//' Copyright 2008 ESRI
//'
//' All rights reserved under the copyright laws of the United States
//' and applicable international laws, treaties, and conventions.
//'
//' You may freely redistribute and use this sample code, with or
//' without modification, provided you include the original copyright
//' notice and use restrictions.
//'
//' See use restrictions at <your ArcGIS install location>/developerkit/userestrictions.txt.
namespace CopyFiles
{
class ExporterXML: ESRI.ArcGIS.Catalog.IMetadataExport
{
public string DefaultFilename{
// 'in the Export Metadata dialog box...
// 'if you select a file first and then choose this exporter from the
// 'Format dropdown list, this file extension replaces the original
// 'one that you see at the end of the path in the Location text box
// 'if you choose this exporter first then click Browse, this filename
// 'is the default file name, and this file extension is used as
// 'the default filter for listing files
get { return "template.xml"; }
}
public void Export(ESRI.ArcGIS.Geodatabase.IMetadata source, string destination)
{
IXmlPropertySet pXPS;
string vValues;
string sService;
string sServe;
string sTitle;
//'1. get metadata from the source GxObject
//'The IMetadata.Metadata property returns an XmlPropertySet object; if
//' metadata doesn't exist, ArcCatalog creates and initializes a new
//' XmlPropertySet object for you. If metadata doesn't exist, don't export.
pXPS = (IXmlPropertySet)source.Metadata;
if (pXPS.IsNew)
return ;
//'2. apply stylesheet to generate output XML
//'This exporter uses the XSLT stylesheet provided with the sample to modify the
//' metadata and copy the output to a new XML file. XSLT removes all synchronized
//' information, removes FGDC hints, removes thumbnail and enclosures, and then
//' removes any empty container elements left over after the leaf nodes have been
//' removed. Leaves in empty elements that have a value attribute that contains
//' text - used in ISO to store values for some elements.
//'
//'If no path specified for xslPath parameter,
//' the XSLT stylesheet must reside in ArcGIS bin directory. If it resides elsewhere,
//' set the appropriate path below and recompile. If it resides in
//' %ARCHOME\Metadata\Stylesheets, add an underscore (_) to the beginning of filename
//' so it won't appear in dropdown lists in ArcCatalog, modify path below and
//' recompile. outputANSI parameter must be FALSE and header must be NULL for this to
//' work. XSLT stylesheet adds the XML processing instruction and DOCTYPE comment.
//' pXPS.SaveAsFile "exportDocumentation.xsl", vbNullString, False, destination
//pXPS.SaveAsFile("D:\\ArcGIS2FGDC.xsl","", false, destination);
pXPS.SaveAsFile("C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\Metadata\\Stylesheets\\ArcGIS_ItemDescription.xsl", "", false, destination);
}
public string Name
{
get {
// 'this is the name that appears in the Format dropdown list in the
// 'Export Metadata dialog box
return "Template Exporter";
}
}
}
}
And try to make a QI like this
string strName;
strName = pGxObj1.Name;
pMD = (IMetadata)pGxObj1;
// IMetadataExport a;
m_pExporterXML = new ExporterXML();
pExport = m_pExporterXML;
//'Export the metadata to a local directory
pExport.Export( pMD, "D:\\" + strName + ".html");
pGxObj1 = pEnumGxObj.Next();
intCount = intCount + 1;
Works when I use ArcGIS_ItemDescription.xsl but Now what I want is to export metadata but using FGDC standar.
but it crash when I use ARCGIS2FGDC.xml located on C:\Program Files (x86)\ArcGIS\Desktop10.1\Metadata\Translator.
I think I must use python to get this FGDC format and use ExportMetadata_conversion
import arcpy
from arcpy import env
env.workspace = "C:/data"
#set local variables
dir = arcpy.GetInstallInfo("desktop")["InstallDir"]
translator = dir + "Metadata/Translator/ESRI_ISO2ISO19139.xml"
arcpy.ExportMetadata_conversion ("data.gdb/roads", translator,
"roads_19139.xml")
so then what is the diference between ExportMetadata_conversion on python and pXPS.SaveAsFile on arcobjects.
I'm a Little confused
Thanks for read.