Configuring a SAX-writer
Next, you configure the values that control how the write occurs. Below are some steps you might want to consider:
![*](bullet.png)
If you are reusing a SAX-writer object for multiple writes, call the
RESET method to clear the object and reset the default values.
![*](bullet.png)
Use the
SET-OUTPUT-DESTINATION method to declare the output destination and its type (
file,
longchar,
memptr,
stream).
![*](bullet.png)
Set the
VERSION,
ENCODING, and
STANDALONE attributes to ensure that the XML documents prolog is correctly configured.
![*](bullet.png)
Set the
FRAGMENT attribute if you are writing XML content that is not a complete XML document.
![*](bullet.png)
Set the
FORMATTED attribute if you want the XML output to have extra whitespace for easy readability.
![*](bullet.png)
Set the
STRICT attribute to
FALSE if you do not want the write to fail if the parser detects invalid XML.
Here is an example:
DEFINE VARIABLE hSAXWriter AS HANDLE NO-UNDO.
DEFINE VARIABLE lok AS LOGICAL NO-UNDO.
CREATE SAX-WRITER hSAXWriter.
hSAXWriter:FORMATTED = TRUE.
lok = hSAXWriter:SET-OUTPUT-DESTINATION("file", "sw-example.xml").
|