Altova XMLSpy 2025 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.

XSFileNewAssignSchema

The following options are available:

 

Assign Schema/DTD File: Browse for the XML Schema or DTD file you want to assign. Note that you can make the assignment in the document a relative or absolute path.

Assign Packaged Schema: Some schemas are each actually a package of schema files rather than a single schema file. The Assign Packaged Schema option opens a dialog that lists the schema packages supported by Altova's Schema Manager. In this dialog, schemas listed in black have already been installed on your machine, those in blue have not been installed and can be installed by Schema Manager. When you select a schema package or one of its schema entry points and click OK, the following happens: The schema package will be installed if it has not already been installed. The selected schema package (previously installed or newly installed) will be assigned to the document and will be used from this point onwards for document validation.

Cancel: If a new file is being created, then it is created with no XML Schema or DTD assignment. If the schema assignment is for an already existing document, then the dialog is exited.

 

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.

 

© 2018-2024 Altova GmbH