NPS Metadata Extension: Source Code Documentation
Visual Basic project
The extension is all written in Visual Basic 6. All necessary files are
included within a visual basic project file directory. Download the
source
code in a zip file (version 1.5 posted 9/13/2004). The source code within this
project contains many generic routines that are useful for creating other ArcCatalog tools and almost all of the Visual Basic code can be directly used
within Visual Basic for Applications. If you are new to programming in Arc8,
please see our Migrating to VB in Arc8
documentation.
Compiling the project
NOTE: Before compiling, make sure to uninstall any version of
the extension and close any running Arc8 components. You cannot have the
extension installed using the install package and compile the project from VB
on the same machine. To compile the project, I suggest using the ESRI Add-in
"Compile and Register" under the Add-Ins menu. Selecting the tool
will open a window where you select the "component category" for
each class within the project. Make sure for each "command" that the
"ESRI GX Commands" box is checked. The toolbars clsMetadataToolBar
and clsMetadataMenuDef are a "ESRI GX Command Bars", the extension clsNPSMetadataExt is
a "ESRI GX Extension", and clsXMLMetadataImport is a
"Metadata Importers" (you may have to add this category
using the "Components" menu item). Also, the toolbars clsMetadataToolBar
and clsMetadataMenuDef should be selected as "Premier Toolbar." Click the Compile button
to actually compile the project. If you encounter an error while compiling,
use the File -> Make nps_metadata.dll menu option to locate the
actual error(s). Upon completion, the "Compile and Register" tool
will have created the "nps_metadata.dll" within the project
directory and registered this DLL and its components, i.e. ArcCatalog will
"see" this extension the next time it runs.
Required references
The following references need to be selected in order for the extension
to compile correctly. See specific documentation within the code for which
tools use which references. These are listed in the order used by the
developer.
- Visual Basic For Applications
- Visual Basic runtime objects and procedures
- Visual Basic objects and procedures
- ESRI Object Library
- ESRI ArcCatalog Object Library
- ESRI ArcMap Object Library
- Microsoft Scripting Runtime
- Microsoft ActiveX Data Objects 2.5 Library
- Microsoft ADO Ext. 2.5 for DDL and Security
- ESRI Arc automation server
- ESRIutil automation server
- Microsoft XML, v3.0
- Microsoft Word 10.0 Object Library
Structure of project
The code within the project file is grouped into forms (the windows or
dialogs used in the extenstion), modules (code to do various general
routines), and classes (the command, command bar, and extension classes). Here
is a short description of each (additional information about each is included
within the comments of each component):
Forms
- frmCombo
- General dialog for selecting from a combo box (duplicates the MsgBox.Choice
of Avenue). Called by several routines.
- frmExportSettings
- Settings dialog for clsExportMetadataCommand.
- frmImportSettings
- Settings dialog for clsImportMetadataCommand.
- frmImportXMLTemplate
- Settings dialog for clsXMLImportTemplateCommand.
- frmMetaCombo
- Combo box for import tool to select which metadata format to import.
- frmMetadataSearch
- Dialog for getting query strings from the user. Called
by clsMetadataSearchCommand.
- frmMetadataTemplate
- Dialog for specifying which metadata elements to
include in template. Called by clsMetadataTemplateCommand.
- frmMPSettings
- Dialog for specifying the options to using when using the
MP (metadata parser). Called by clsExportMPCommand.
- frmMsgReport
- General dialog for displaying a message (duplicates the
MsgBox.Report of Avenue). Called by several routines.
- frmProgress
- Progress bar for Metadata Spellchecker (taken from ESRI sample).
- frmResources
- A form to hold the icons used in the extension's toolbar. Referenced by each
"command" class.
- frmSplash
- Splash page for the extension.
- frmTree
- Hidden form used by Metadata Spellchecker (taken from ESRI sample).
- frmXMLEdit
- Simple text editor form for clsManualEditCommand.
- frmYesToAll
- Yes/no dialog that includes a "Yes to all" option. Called by clsImportMetaCommand.
Modules
- adovbs
- Standard Visual Basic constant declarations for Microsoft's ADO (Active
Data Objects). Used by clsMetadataCatalogCommand routines.
- basDebugger
- Routines to display and save debugging messages in VB and VBA. Very
useful for debugging extensions written in VB.
- baxFixMetaAttrib
- Routines specific to fixing problems in ArcCatalog's XML metadata.
- basGXUtility
- Routines for general tasks within ArcCatalog. For example, getting the
current selection, determining license type, and reading metadata
elements.
- basNPSMetadata
- Settings specific to the extension including the version number,
extension name, help file topic IDs (or Context IDs).
- basSpellCheck
- Code for Metadata Spellchecker (taken from ESRI sample).
- basUtility
- Routines for various file and Visual Basic operations. For example,
determining if a file exists, getting file attributes, searching arrays,
and opening generic documents.
- basWin32API
- Visual Basic front-ends for several Win32API calls. Calls for opening
and saving files and reading/writing Window's registry values are
included. These are very useful.
- basXML
- Code specific to directly manipulate XML files using Microsoft's XML
library.
- ErrorHandling
- This code is from the ESRI's Error Handler Add-in. It says don't modify
it, and I've complied.
Classes
- clsDeleteMetadataCommand
- Tool to physically delete metadata from datasets and personal
geodatabase objects.
- clsExportE00Command
- Tool to create ESRI Export files (*.e00). Can be compiled with only an
ArcView license, but requires an ArcInfo license to actually function.
- clsExportMetadataCommand
- Tool to export metadata in SGML, HTML, and XML formats using Arc8's
exporter.
- clsExportMPCommand
- Tool to export and error check metadata using USGS's mp (metadata
parser). Good example of calling a command-line tool and capturing its
output.
- clsFindReplaceCommand
- Tool to search and replace text in multiple metadata files.
- clsImportE00Command
- Tool to batch import E00 files. Good example of iterating over a
specific file type and doing an operation on each.
- clsImportMetaCommand
- Tool to batch import metadata from SGML, TXT, or XML files. Good example
of iterating over datasets and subdirectories and operating on each
dataset.
- clsImportXMLTemplateCommand
- Tool to batch import specific metadata elements from an XML template to
one or more target datasets.
- clsManualEditCommand
- Tool to grab raw XML from a dataset and open it in a simple text editor
to manipulate. Particularly useful for personal geodatabases where the
metadata is stored within a binary field.
- clsMetadataCatalogCommand
- Tool to create an Access 2000/XP (code for Access 97 included) database of
particular metadata values. Good example of working with (creating,
reading, writing, deleting) ODBC and external databases from within
ArcCatalog.
- clsMetadataHelpCommand
- Tool to open extensions help file (NPSMetadata.chm).
- clsMetadataMenuDef
- Menu portion of clsMetadataToolBar.
- clsMetadataSearchCommand
- Tool to search particular metadata elements. Good example of modifying a
front-end for existing ArcCatalog functionality.
- clsMetadataSpellCommand
- Tool (taken almost verbatim from ESRI sample) to spell check metadata
using Word spellchecker.
- clsMetadataToolBar
- The toolbar for the extension that contains splash page button and
clsMetadataMenuDef menu.
- clsMetaTemplateCommand
- Tool to create simple XML template from an existing dataset's metadata.
- clsNPSLogoCommand
- Tool to open extension's splash page.
- clsNPSMetadataExt
- The extension class. Can be copied to another project and modified to
create new extensions. Also, shows how to implement code at ArcCatalog
startup.
- clsNPSMetadataSynchronizer
- Class to capture when user requests the creation of new metadata. Allows
extension to ask user if they would like to use an existing template.
Currently being tested, not yet functional.
- clsXMLMetadataImport
- Another way to access XML template import functionality within
ArcCatalog's metadata import button. Code should be copied from
clsImportXMLTemplateCommand.
Contact
For any questions, comments, and complaints, please email Eric Compas at edcompas@wisc.edu.
Return to Midwest Region GIS
Last Updated: 9/13/2004 http://www.nature.nps.gov/im/units/mwr/gis/metadata_source.htm
|