Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## How errors are handled when STRICT is TRUE

> 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 it finds an incorrect method call then:

> - The method fails and returns `FALSE`

> - It generates an error message.

> - The SAX-writer changes the `WRITE-STATUS` to `SAX-WRITE-ERROR`

> - The SAX-writer closes the document stream.

> Table 21–3: Common error messages
> 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 will fail and generate an error message. See "Errors raised by invalid method calls during SAX-writer states" section.
>     END-DOCUMENT
> | If the root tag has not been closed and `END-DOCUMENT` is called, the method fails and generates the following message: `END-DOCUMENT attempted to close the document before the root tag was closed.` You must close the root tag with `END-ELEMENT` before closing the document
>     START-ELEMENT
>     WRITE-EMPTY-ELEMENT
>     WRITE-DATA-ELEMENT
> | 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: `<method> attempted to create a second a document level node in the document.` You must limit each XML document to one document-level node.
> `END-ELEMENT` | For each `START-ELEMENT` call, you must have a corresponding and matching `END-ELEMENT` 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/prefix then it will fail and generate the message: `END-ELEMENT attempted to close the tag <qname> when the current tag to close was <qname>.` Do not interweave different start and end tags,
> `WRITE-CHARACTERS` | 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: `WRITE-CHARACTERS attempted to write character data at the document level.`
> `INSERT-ATTRIBUTE` `DECLARE-NAMESPACE` | 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: `<method> attempted to create a second instance of the name <name>.` Also, these methods can only be called when the `WRITE-STATUS` is `SAX-WRITE-TAG` or they fail and generate an error message as describe in "Errors raised by invalid method calls during SAX-writer states" section. For example:
>     hSAXWriter:STRICT = TRUE.
>     hSAXWriter:START-DOCUMENT().
>     hSAXWriter:START-ELEMENT("root","").
>     hSAXWriter:START-ELEMENT("name","").
>     hSAXWriter:WRITE-CHARACTER("Alex
>     Herbstritt", 16).
>     hSAXWriter:END-ELEMENT("root",""). /*
>     method fails */
>     hSAXWriter:END-DOCUMENT().
> This code fragment would generate an error because “root” was closed before “name”.

> The following conditions generate an error message when `STRICT` is set to `TRUE`:

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095