AnsweredAssumed Answered

How do I create default/minimal valid metadata in ArcObjects

Question asked by mnigbor on Jul 25, 2014
Latest reply on Jul 25, 2014 by mnigbor

We are implementing a set of custom classes that implement GxDatabase, GxDataset (and many other interfaces) so that data can be stored and retrieved in a database. This DB has geospatial capabilities but isn't one of the databases ArcGIS directly supports. For this post, let's call these classes MyDBGxDatabaseClass and MyDBGxDatasetClass.

 

My task is to implement metadata, which will be stored in a table like it is in the personal geodatabase and SDE databases.  I got MyDBGxDatabaseClass working by implementing IMetadata and IMetadataEdit using the XmlPropertySet class. The only trick was finding a way to create an initial, minimal metadata object for the first call, when nothing is stored in the database.

 

        public IPropertySet Metadata
        {
            get
            {
                    XmlPropertySet m_Metadata = new XmlPropertySet();
                    string xml = getMetadataXMLFromDB();
                    if( xml == null )
                    {
                         m_Metadata.InitNew();
                    }
                    else
                    {
                         ((IXmlPropertySet2)m_Metadata).SetXml(xml);  
                    }
                    return (IPropertySet)m_Metadata;
            }
            set
            {
                 // Removed for clarity
            }
        }

 

When this is used on MyDBGxDatabaseClass, ArcCatalog happily consumes the XML created by InitNew(). I can view, edit and save. Life is good.

 

When this is used on MyDBGxDatasetClass, ArcCatalog returns "The item's XML contains errors." Apparently, ArcCatalog expects different XML for Datasets than for Databases. I've tried lots of alternative XML, including copying metadata XML from a personal geodatabase.  The results are always the same: The item's XML contains errors.

 

  • Don't all objects, regardless of type, use the same metadata schema?
  • How can I determine what the error(s) is(are)? 

 

Almost forgot: This is on 10.2.2.

Outcomes