Summary
Validates an ArcGIS item's metadata or any XML file using the .NET 3.5 Framework's XML software. 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
Some XML Schemas require you to specify the XML namespace you want to validate, while others do not. If a value is provided in the Namespace URI parameter when none is required, any warnings or errors reported will be related to not finding the correct information in the XML Schema and won't identify whether the XML document is valid.
For example, if you try to validate an XML document that follows the Federal Geographic Data Committee (FGDC) Content Standard for Digital Geospatial Metadata (CSDGM) using the XML Schema http://www.fgdc.gov/schemas/metadata/fgdc-std-001-1998.xsd, you should not provide a value in the Namespace URI parameter.
When validating an XML document using a DTD, the name of the element that will be validated must be provided in the Namespace URI parameter. For example, if a DOCTYPE declaration were added to an XML document referencing an external DTD, that syntax might look like this: <!DOCTYPE metadata SYSTEM "http://www.fgdc.gov/schemas/metadata/fgdc-std-001-1998.dtd">. To validate an XML document using this same external DTD with this tool, you would provide the value http://www.fgdc.gov/schemas/metadata/fgdc-std-001-1998.dtd in the Schema URL parameter. Provide the name of the root element in the XML document in the Namespace URI parameter: metadata. The root element's content is validated.
If the XML document being validated contains an embedded reference to an external XML Schema or XML DTD, that schema will not be used for validation. The schema to use for validation and the namespace or root element to validate must be explicitly specified in this tool's Schema URL and Namespace URI parameters.
The message Adding schemas... indicates the schema is loading. All errors or warnings found in the schema will be reported here.
The message Reading document... indicates when validation of the metadata or XML file begins. All errors or warnings found in the metadata or XML file are reported here.
If you have metadata XML files formatted to follow the ISO 19139 metadata standard, Geographic information — Metadata — XML schema implementation, and you validate them against the 2005 version of the XML Schemas provided with this standard, the tool reports an issue with the XML Schema files. This warning is only reported by the .NET 3.5 Framework's XML software and appears in the tool's messages as follows: validation warning (423:8): Empty choice cannot be satisfied if 'minOccurs' is not equal to 0. The warning indicates there is a problem in the 8th character on line 423; it occurs in the coverage.xsd XML Schema. Other XML parsers don't report any problems with the same XML Schemas.
The Source Metadata parameter has a complex data type. If you use this tool in a model, create a variable for the Source Metadata parameter in ModelBuilder by right-clicking the tool, pointing to Make Variable, pointing to From Parameter, and then clicking Source Metadata.
When using this tool in ModelBuilder, the Output Metadata parameter is derived from the Source Metadata parameter.
Syntax
arcpy.conversion.XMLSchemaValidator(source, schemaurl, {nsuri})
Parameter | Explanation | Data 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, use 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
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes