Altova XMLSpy 2024 Professional Edition

Assigning Schemas and Validating

Home Prev Top Next

Altova website: AltovaWebLink XML Validator, XML Validation

 

A schema (DTD or XML Schema) can be assigned to an XML document when it is first created. A schema can also be assigned, or changed, at any subsequent time using the Assign DTD or Assign Schema commands in the DTD/Schema menu.

SchemaAssign

The path to the schema file that is inserted in the XML document can be made relative by checking the relative path check box in the dialog.

 

Global resources for schemas

A global resource is an alias for a file or folder. The target file or folder can be changed within the GUI by changing the active configuration of the global resource (via the menu command Tools | Active Configuration). Global resources therefore enable the assigned schema to be switched among multiple schemas, which can be useful for testing. How to use global resources is described in the section Altova Global Resources.

 

XML Schema plus DTD

One very useful DTD feature that XML Schema does not have is the use of entities. However, if you wish to use entities in your XML-Schema-validated XML document, you can add a DOCTYPE declaration to the XML document and include your entity declarations in it.

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE OrgChart [

 <!ENTITY name-int "value">

 <!ENTITY name-ext SYSTEM "extfile.xml">

]>

<OrgChart xmlns="http://www.xs.com/org"

         xsi:schemaLocation="http://www.xs.com/org OrgChart.xsd">

 ...

</OrgChart>

 

After declaring the entities in the DTD, they can be used in the XML document. The document will be well-formed and valid. Note, however, that external parsed entities are not supported in Authentic View..

 

Going to schema definitions

With the XML document open, you can directly open the DTD or XML Schema on which it is based by clicking the Go to DTD or Go to Schema commands in the DTD/Schema menu. Additionally, you can place the cursor within a node in the XML document and go to the schema definition of that node via the Go to Definition command in the DTD/Schema menu.

 

Validating and checking well-formedness

To validate and/or check for well-formedness, use the Validate XML (F8) and Check Well-Formedness (F7) commands in the XML menu or the corresponding commands in the toolbar. Any error is reported in the Messages window. If an XML document is invalid, the XML validator provides smart fixes to correct the error based on the information in the schema.

 

You can also use a RaptorXML Server to validate XML documents.

 

© 2017-2023 Altova GmbH