The mode of operation depends on the file’s last OPEN DOCUMENT statement for which no CLOSE DOCUMENT statement has yet been provided:
If the last OPEN DOCUMENT statement contained no STACK phrase, all entries in the EPV are set to invalid, the values are removed from the document’s internal tree structure, and the working memory used for this is released.
If the last OPEN DOCUMENT statement contained a STACK phrase, the EPV is reset to the status which it had before this OPEN statement was executed.
CLOSE DOCUMENT modifies the EPV only, but leaves data unchanged.
A CLOSE DOCUMENT statement need not be specified: if it is missing, it is implied by a CLOSE statement or an OPEN DOCUMENT statement without a STACK phrase (for the same file).
Example 12-41 CLOSE DOCUMENT and OPEN DOCUMENT with STACK
XML document | Pos | COBOL data structure | OPEN | OPEN | CLOSE | CLOSE DOCU- |
<a> | 1 | FD xml-fil | | | | |
Comments:
Information on the presentation of this example is provided on Statements for XML processing .
The STACK phrase in the OPEN DOCUMENT statement does not immediately have an effect on the EPV’s current contents after this statement (cf. the example 12-40 in section "OPEN DOCUMENT" ).
The first CLOSE DOCUMENT statement restores the EPV with the status before the associated (second) OPEN DOCUMENT statement because the STACK phrase was specified there.
The (first) OPEN DOCUMENT statement associated with the second CLOSE DOCUMENT statement contained no STACK phrase. Consequently all EPV entries are set to 'invalid'.