Section 4.3.  Validation

Prev don't be afraid of buying books Next

4.3. Validation

You may have noticed that Word validates your document as you mark it up. Word is constantly checking to make sure that the document conforms to the schema.

4.3.1 Schema rules

Rules that a schema can specify include:

  • The allowed children of an element. For example, according to the article schema, there can be only one article element, which can contain title, author, date and body elements.

  • The order of the children. The children of the article element must appear in the order specified in the schema.

  • The number of occurrences of each child. A section element must contain one and only one header element, but it may contain one or more para elements.

  • The presence or absence of character data content in an element. The title element can contain character data, but a section element cannot.

  • The datatype of an element or attribute. The id attribute of the article element must contain a valid ID.

Using datatypes, you can specify additional rules that limit the length of a string, require that a string match a particular pattern, limit a number to a particular range, specify a list of valid values, and apply various other constraints. For more information on the capabilities of datatypes, see Chapter 21, "Datatypes", on page 442.

4.3.2 Validity errors

When a document (or part of a document) you are editing is invalid according to the schema, Word shows this in two ways:

  • A purple wavy line (similar to the one that shows spelling and grammatical errors). For errors that span multiple lines, it appears down the left side of the document. Otherwise, it underlines the error.

  • The top part of the XML Structure task pane shows icons next to invalid elements, as described in the next section.

Some of the possible errors that could be found are:

  • The element has invalid content. For example, character data appears where it should not, or the character data it contains is invalid according to its datatype.

  • The element is not expected to appear here. This could be because it is not a valid child, it does not appear in the correct sequence, or a required element that should appear before it is missing.

  • The element is empty, but according to the schema, it should have children, or some required content is missing.

  • One or more of the element's attributes is missing or invalid.

Amazon


XML in Office 2003. Information Sharing with Desktop XML
XML in Office 2003: Information Sharing with Desktop XML
ISBN: 013142193X
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net