A Valid XML document is a Well Formed XML document, which also conforms to the rules of a schema which defines the legal elements of an XML document. The schema type can be: XML Schema, Relax NG (full or compact syntax), Schematron, Document Type Definition (DTD), Namespace Routing Language (NRL) or Namespace-based Validation Dispatching Language (NVDL).
The purpose of the schema is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements.
The <oXygen/>
function ensures that your document is compliant with the rules defined by an associated DTD, XML Schema, Relax NG or Schematron schema. XML Schema or Relax NG Schema can embed Schematron rules. For Schematron it is possible to select the validation phase.Validation of an XML document against an XML Schema containing a type definition with a minOccurs or maxOccurs attribute having a value larger than 256 limits the value to 256 and issues a warning about this restriction in the Message panel at the bottom of the <oXygen/> window. Otherwise for large values of the minOccurs and maxOccurs attributes the validator fails with an OutOfMemory error which practically makes <oXygen/> unusable without a restart of the entire application.
A line with a validation error or warning will be marked in the editor panel by underlining the error region with a red color. Also a red sign will mark the position in the document of that line on the right side ruler of the editor panel. The same will happen for a validation warning, only the color will be yellow instead of red.
The ruler on the right of the document is designed to display the errors found during the validation process and also to help the user to locate them more easily. The ruler contains the following areas:
top area containing a success validation indicator that will turn green in case the validation succeeded or red otherwise.
middle area where the errors markers are depicted in red. The number of markers shown can be limited by modifying the setting oXygen/Editor / Document checking+Maximum number of errors reported per document
→ +Clicking on a marker will highlight the corresponding text area in the editor. The error message is displayed both in the tool tip and in the error area on the bottom of the editor panel.
Status messages from every validation action are logged into the Console view.
Example 4.4. Validation error messages
In our example we will use the case where a DocBook listitem element
does not match the rules of the docbookx.dtd
. In
this case running Validate Document will return
the following error:
E The content of element type "listitem" must match"(calloutlist|glosslist|itemizedlist|orderedlist|segmentedlist| simplelist|variablelist| caution|important|note|tip|warning| literallayout|programlisting|programlistingco|screen| screenco|screenshot|synopsis|cmdsynopsis| funcsynopsis|classsynopsis|fieldsynopsis| constructorsynopsis| destructorsynopsis|methodsynopsis|formalpara|para|simpara| address|blockquote|graphic|graphicco|mediaobject| mediaobjectco|informalequation| informalexample| informalfigure|informaltable|equation|example| figure|table|msgset|procedure|sidebar|qandaset|anchor| bridgehead|remark|highlights|abstract|authorblurb|epigraph| indexterm|beginpage)+".
As you can see, this error message is a little more difficult to understand, so understanding of the syntax or processing rules for the Docbook XML DTD's "listitem" element is required. However, the error message does give us a clue as to the source of the problem, but indicating that "The content of element type "listitem" must match".
Luckily most standards based DTD's, XML Schema's and Relax NG schemas are supplied with reference documentation. This enables us to lookup the element and read about it. In this case we would want to learn about the child elements of "listitem" and their nesting rules. Once we have correctly inserted the required child element and nested it in accordance with the XML rules, the document will become valid on the next validation test.