How errors are handled when STRICT is TRUE
- Last Updated: July 25, 2014
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
If STRICT is set to TRUE,
then the writer will validate the structure of the XML document
as it writes it out. With this attribute, the SAX-writer attempts
to keep the developer from creating invalid XML documents. It does
this by ensuring that the methods are called in correct order.
If SAX-writer finds an incorrect method call:
- The method fails and returns
FALSE - It generates an error message
- The SAX-writer changes the
WRITE-STATUStoSAX-WRITE-ERROR - The SAX-writer closes the document stream
The following table describes the conditions that generate an
error message when STRICT is set to TRUE.
| Methods effected | Description |
|---|---|
| All | If a particular method is called when the WRITE-STATUS attribute
status value is an illegal value for the method, the method fails
and generates an error message. See Errors raised by invalid method calls during SAX-writer states for more information. |
|
If the root tag is not closed and END-DOCUMENT is
called, the method fails and generates the following message:You must close the root
tag with END-ELEMENT before closing the document |
|
If FRAGMENT is FALSE,
then there may be only one root node, that is, the document-level
node. If a call to one of these methods would result in a second
document-level node then the following error message is generated:You
must limit each XML document to one document-level node. |
|
For each START-ELEMENT method
call, you must have a corresponding and matching END-ELEMENT method
call. Start and end all nodes to properly form parent and child relationships.
All nodes must be started and ended (excluding empty nodes). If END-ELEMENT is
called with the incorrect name and prefix, then it fails and generates
the message:Do not interweave different
start and end tags. |
|
Only call WRITE-CHARACTERS from
within the document. That is, call it from within the root node.
If it is called at the document level, it will fail and generate
the following error: |
|
Attribute names must be unique. If a call to
either of these methods results in a repeated instance of a name, then the methods
fail and the following error message will be
generated:
Also, these methods can only be called when the WRITE-STATUS is
SAX-WRITE-TAG or they fail and generate an error message as
described in Errors raised by invalid method calls during SAX-writer states. For
example:This
code fragment would generate an error because root was closed before
name. |