Validating XML Data

Overview

NOTE: You can only use the National Highway Traffic Safety Administration (NHTSA) Early Warning Reporting (EWR) XML Validator with Microsoft® Internet Explorer Version 6.0 or greater.

The NHTSA EWR XML Validator application enables you to validate your XML documents against the specified XML schema before you submit your EWR data to NHTSA. The following topics are discussed:

Using the NHTSA EWR XML Validator

You may submit quarterly reporting data using the eXtensible Markup Language (XML) format. Templates for each of the following reporting types are available on NHTSA's web site:

Follow the Download instructions that are available on NHTSA's web site to download the XML schemas to use for validation.

NOTE: Do not change the name of a schema after you download it. If you change the name of the XML schema, the NHTSA EWR XML Validator will not work.

Once you have downloaded the appropriate XML schemas and the NHTSA EWR XML Validator, use the following procedure to validate your XML data files:

  1. Click on the NHTSAXMLValidator icon. The NHTSA EWR XML Validator appears.

  2. Select the appropriate XML schema by clicking on the Browse button next to the XML Schema field. The Choose File dialog box appears.

    The Choose File dialog box

  3. Select the directory where you have your XML schemas stored by clicking on the down arrow in the Look In field.

  4. Select the appropriate XML schema either by scrolling to the file and double-clicking on it or by clicking on the down arrow in the File Name field, selecting the file, and clicking the Open button. The filename appears in the XML Schema field of the NHTSA EWR XML Validator.

    NOTE: When you select an XML schema file, make sure that it has a valid file extension. XML schema files have the file extension .xsd. If you select a file with an invalid file extension, an error message appears.

  5. Select the appropriate XML data file by clicking on the Browse button next to the XML Document field. The Choose File dialog box appears.

  6. Select the directory where you store your XML data files by clicking on the down arrow in the Look In field.

    NOTE: When you select an XML data file, make sure that it has a valid file extension. XML data files have the file extension .xml. If you select a file with an invalid file extension, an error message appears.

  7. Select the XML data file that you wish to validate either by scrolling to the file and double-clicking on it or by clicking the down arrow in the File Name field, selecting the file, and clicking the Open button. The filename appears in the XML Document field of the NHTSA EWR XML Validator.

  8. Click the Validate button to begin the validation process. A message box similar to the following appears:

    About to validate c:\artemisdocs\help\xml\LightVehicle_Invalid.xml document against c:\artemisdocs\help\xml\LightVehiclesSchema.xsd Schema

    If you selected the incorrect XML schema file for the data file that you want to validate, (for example, you selected the LightVehiclesDI.xsd file for use in validating the LightVehicles.xml data file), the following message will appear in the Reason field on the Validator:

    Validate failed because the root element had no associated DTD/schema

    If you selected the wrong XML schema or data file, click Cancel to return to the NHTSA EWR XML Validator. Follow the previous steps to start the validation process over.

  9. Click OK. The NHTSA EWR XML Validator parses the data file. If the file contains invalid data, a screen similar to the following appears:

    XML Schema: C:\artemisdocs\publicweb\downloads\ewr\ManufaturersXMLValidator\xml\schema\BusesAndMediumHeavyVehicles.xsd XML Document: C:\artemisdocs\publicweb\downloads\ewr\ManufacturersXMLValidator\000060H031001AC.xml Status: Invalid Reason: maxInclusive constraint failed. The element: 'ReportQuarter' has an invalid value according to its data type. Source Line: 12 Source Value: 10

    The following table describes the fields that appear in the Validation Results section:

    Field Name Description
    XML Schema Displays the directory on your local machine where the XML schema is located.
    XML Document Displays the directory on your local machine where the XML file is located.
    Status Displays the status of the file. If the file contains invalid data, the word "Invalid" appears in this field. If the data in the file is valid, the word "Valid" appears in this field.
    Reason Displays the reason why the file is invalid. This field also displays the field name containing the invalid data value.
    Source Line Displays the line number where the invalid data value is located in the XML file.
    Source Value Displays the invalid data value.

    NOTE: If the file passes the validation process, the Reason, Source Line, and Source Value fields do not appear in the NHTSA EWR XML Validator dialog box.

    The screen displays one error message at a time. If the data file contains more than one error, the NHTSA EWR XML Validator will not display the next error until you correct the first error and re-validate the file. For more information about this process, see Correcting Invalid Data.

    If the data in the file is valid, a screen similar to the following appears:

    Validation Results  Status: Valid

    This message indicates that the file content conforms to the XML schema requirements. You can then transmit the data file to NHTSA.

Top of Page

Correcting Invalid Data

If the NHTSA EWR XML Validator finds invalid data in your XML data file, an error message appears on the NHTSA EWR XML Validator screen that indicates the error type, the source of the error, and the line number where the invalid data is located. Use the following procedure to make corrections:

  1. Open the XML data file using any text editor.

  2. Go to the line number indicated in the Source Line field of the NHTSA EWR XML Validator screen to find the invalid data value.

  3. Correct the error.

  4. Re-validate the file using the NHTSA EWR XML Validator. For detailed information about this process, see Using the NHTSA EWR XML Validator. The NHTSA EWR XML Validator parses the file. If it detects other errors in the file, it displays the next error message.

  5. Repeat the previously listed steps to correct the error.

  6. Use the NHTSA EWR XML Validator to re-validate the file. Repeat the previously listed steps for each error that the EWR XML Validator finds. When you correct all of the errors in the file, you are ready to transmit the data file to NHTSA.

Top of Page

End of File