Exemple #1
0
        /// <summary>
        /// Translates metadata document
        /// </summary>
        /// <remarks>
        /// used to translate metadata document.
        /// </remarks>
        /// <param name="sourceXml">Metadata to be converted</param>
        /// <param name="xsltFileName">Translation xslt</param>
        /// <param name="xmlFileName">Metadata xml file name.</param>
        /// <returns>Returns true if execution was successful.</returns>
        private bool TranslateMetadata(string sourceXml, String xsltFileName, ref String xmlFileName)
        {
            ESRITranslator gpTool = GpHelper.xmlTranslator(sourceXml, xsltFileName, xmlFileName);

            // Request that the GpHelper execute the instantiated tool. A wrapper is
            // used to abstract error handling and allow a simple integer success code
            // equivalency check to determine success/failure.
            string[] xmlFilePaths;
            return(GpHelper.Execute(gpTool, out xmlFilePaths) == 0);
        }
        /// <summary>
        /// Translates metadata document
        /// </summary>
        /// <remarks>
        /// used to translate source metadata to another format using xslt.
        /// </remarks>
        /// <param name="propertySet">IXmlPropertySet2 metadata to be converted</param>
        /// <param name="xmlFilePaths">string[] output string array of file paths.</param>
        /// <returns>Returns true if execution was successful.</returns>
        private bool TranslateMetadata(IXmlPropertySet2 propertySet, out string[] xmlFilePaths)
        {
            const string noHeader     = "";
            const bool   ansiRestrict = false;
            string       sourceXml    = Path.GetTempFileName();

            propertySet.SaveAsFile(null, noHeader, ansiRestrict, ref sourceXml);

            String selectedStyleCfg = Globals.ArcGISInstallationFolderFromCommandLine + "\\Metadata\\Config\\" + Globals.ArcGISDesktopMetadataConfig + ".cfg";

            translatorPath = readTranslatorFromConfig(selectedStyleCfg);
            ESRITranslator gpTool = GpHelper.xmlTranslator(sourceXml, translatorPath);

            // Request that the GpHelper execute the instantiated tool. A wrapper is
            // used to abstract error handling and allow a simple integer success code
            // equivalency check to determine success/failure.
            return(GpHelper.Execute(gpTool, out xmlFilePaths) == 0);
        }