XML Schema Validation (Conversion)

Summary

Uses the .NET 3.5 Framework's XML software to validate an ArcGIS item's metadata or any XML file. The XML is checked to see if it follows the structure and content rules outlined by an XML schema. Schemas written using the DTD or W3C XML Schema languages may be used with this tool.

ArcGIS metadata is not formatted in a manner that can be directly validated against an XML schema. However, other metadata geoprocessing tools can export ArcGIS metadata to XML files that are formatted to follow a metadata standard's XML Schema or DTD; use this tool to validate the exported XML file or a stand-alone metadata XML file that is already formatted correctly for a metadata standard's XML schema.

If the metadata or XML file is not valid for the specified XML Schema or DTD, the warnings or errors returned by the XML software will appear in the tool's messages.

Usage

Syntax

XMLSchemaValidator_conversion (source, schemaurl, {nsuri})
ParameterExplanationData Type
source

The item whose metadata will be validated or a stand-alone XML file that will be validated.

Data Element; Layer
schemaurl

The XML Schema or XML DTD that describes the structure and content of a valid XML document.

String
nsuri
(Optional)

The XML namespace that will be validated for an XML Schema, if appropriate, or the root element of the document for an XML DTD.

If this value is inappropriate for the XML Schema being used, provide the pound sign (#) instead of a namespace URI.

String

Code Sample

Validate an ISO 19139 metadata XML file using an XML Schema

Validates a stand-alone XML file containing ISO 19139-formatted metadata using the online ISO 19139 XML Schema. These XML Schemas require you to specify the XML namespace you want to validate.

import arcpy
from arcpy import env
env.workspace = "C:/data"
#set local variables
schema = "http://www.isotc211.org/schemas/2005/gmd/metadataEntity.xsd"
namespace = "http://www.isotc211.org/2005/gmd"
arcpy.XMLSchemaValidator_conversion("metadata_19139.xml", schema, namespace)
Validate an FGDC metadata XML file using an XML Schema

Validates a stand-alone XML file containing FGDC CSDGM-formatted metadata using a local copy of the FGDC XML Schema files. These can be downloaded from the FGDC metadata standards Web site. These XML Schemas don't require you to specify the XML namespace you want to validate.

import arcpy
from arcpy import env
env.workspace = "C:/data"
#set local variables
schema = "c:/metadata/FGDCxsd/non-annotated/fgdc-std-001-1998.xsd"
arcpy.XMLSchemaValidator_conversion("metadata_fgdc.xml", schema, "#")

Environments

Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes

11/14/2011