The DTD/Schema | Generate DTD/Schema command generates a new DTD or W3C XML Schema from an XML document (or from a set of XML documents contained in a folder in the project window). This command is useful when you want to generate a DTD or XML Schema from XML documents.
If you generate an XML Schema, the following options are available:
•Elements: The type of elements can be defined locally or globally (Define types for elements). If elements have the same name, a common type can be declared for use in the definition of these elements (Generate one shared type).
•Attributes: The simple types of attributes (Define simple types for attributes) can be defined as (i) common global types; (ii) distinct global types; (iii) local types. Attributes with the same name and type can be defined either locally or globally.
•Simple type recognition: The recognition of types (Simple type recognition) can be set to: (i) best possible; (ii) recognition of number datatypes only; (iii) no datatype recognition, in which case all datatypes are set to xs:string.
•Entity resolution: In the XML document, entities may appear in element content and attribute values. Whether they are resolved or not (Validate and resolve entities) is therefore significant for enumeration values. Furthermore, some entities (especially parsed entities that contain markup) can affect the content model differently depending on whether they are resolved or not. Note that the XML document will be validated for being correct XML before the schema is generated. If the document is invalid, the schema generation process will be discontinued.
•Enumerations: All types of values, or string values only, can be enumerated.
If you generate a DTD, the entity resolution and enumeration options are available.
The Generate DTD/Schema command normally operates on the active main window, but you can also use the Generate DTD/Schema command on any file, folder, or group of files in the active project window.
If elements or attributes in more than one namespace are present, XMLSpy generates a separate XML Schema for each distinct namespace; therefore, multiple files may be created on the disk.