In case you are editing document fragments, for instance the chapters from a book each one in a separate file, you can activate the Content Completion for these fragments in two ways:
The list of document types available at → -> Document Type Association contains a set of rules for associating a schema with the current document when no schema is specified within the document. The schema is one of the types: XML Schema, XML Schema with embedded Schematron rules, Relax NG (XML syntax or compact syntax), Relax NG (XML syntax) with embedded Schematron rules, Schematron, DTD, NRL, NVDL.
The rules are applied in the order they appear in the table and take into account the local name of the root element, the default namespace and the file name of the document.
The same effect is obtained by configuring a processing instruction that specifies the schema to be used. The advantage of this method is that you can configure the Content Completion for each file. The processing instruction must be added at the beginning of the document, just after the XML prologue:
<?oxygen RNGSchema="file:/C:/work/relaxng/personal.rng" type="xml"?>
Select menu Content Completion and document validation. The schema is one of the types: XML Schema (with or without embedded Schematron rules), DTD, Relax NG - XML syntax (with or without embedded Schematron rules), Relax NG - compact syntax, NRL, NVDL, Schematron.
+ → or click the toolbar button to open a dialog for selecting a schema used forThis is a dialog helping the user to easily associate a schema file with the edited document . Enables definition of a XML Document Prolog using the system identifier of a XML Schema, DTD, Relax NG (full or compact syntax) schema, NRL (Namespace Routing Language) schema, NVDL (Namespace-based Validation Dispatching Language) schema or Schematron schema. If you associate an XML Schema with embedded Schematron rules or a Relax NG schema (XML syntax) with embedded Schematron rules you have to check the Embedded Schematron rules checkbox available for these two types of schemas. Embedded Schematron rules are not supported in Relax NG schema with compact syntax.
When associating a XML Schema to the edited document if the root element of the document defines a default namespace URI with a "xmlns" attribute the "Associate schema" action adds a xsi:schemaLocation attribute. Otherwise it adds a xsi:noNamespaceSchemaLocation attribute.
The URL combo box contains a predefined set of schemas that are used more often and it also keeps a history of the last used schemas.
<oXygen/> logs the URL of the detected schema in the Information view.
The oxygen processing instruction has the following attributes:
specifies the path to the Relax NG schema associated with the current document
specifies the type of Relax NG schema, is used together with the RNGSchema attribute and can have the value "xml" or "compact".
specifies the path to the NRL schema associated with the current document
specifies the path to the NVDL schema associated with the current document
specifies the path to the SCH schema associated with the current document
The namespace of the root element of an XML document can be associated with an XML Schema using an XML catalog. If there is no xsi:schemaLocation attribute on the root element and the XML document is not matched with a document type the namespace of the root element is searched in the XML catalogs set in Preferences. If there is an element uri or rewriteUri or delegateUri in the XML catalog that associates the namespace with a schema that schema will be associated with the XML document.
When working with documents that do not specify a schema, or for which the schema is not known or does not exist, <oXygen/> is able to learn and translate it to a DTD, which in turn can be saved to a file in order to provide a DTD for Content Completion and document validation. In addition to being useful for quick creation of a DTD that will be capable of providing an initialization source for the Content Completion assistant. This feature can also be used to produce DTDs for documents containing personal or custom element types.
When it is opened a document that does not specify a schema <oXygen/> automatically learns the document structure and uses it for Content Completion. To disable this feature uncheck the checkbox Learn on open document from Preferences.
Procedure 4.4. To create a DTD:
Open the structured document from which a DTD will be created.
Select menu Ctrl+Shift+L) to read the mark-up structure of the current document so that it can be saved as a DTD using the option. <oXygen/> will learn the document structure, when finished displaying words Learn Complete in the Message Pane of the Editor Status bar.
+ → (Select menu Ctrl+Shift+S) to display the Save Structure dialog, used to name and create DTD documents learnt by the Learn Structure function.
+ → (![]() | Note |
---|---|
The resulting DTD is only valid for documents containing the elements and structures defined by the document used as the input for creating the DTD. If new element types or structures are defined in a document, they must be added to the DTD in order for successful validation. |