XML events
An XML event results when the
XML parser detects various conditions (such as END-OF-INPUT
or EXCEPTION
)
or encounters document fragments (such as CONTENT-CHARACTERS
or START-OF-CDATA-SECTION
)
while processing an XML document.
For each event that occurs during XML parsing, the parser sets
the associated event name in the XML-EVENT
special
register, and passes the XML-EVENT
special register
to the processing procedure. Depending on the event, the parser sets
other special registers to contain additional information about the
event.
In most cases, the parser sets the XML-TEXT
or XML-NTEXT
special
register to the XML fragment that caused the event:
- If the
XMLPARSE(COMPAT)
compiler option is in effect, the parser setsXML-NTEXT
if the XML document is in a national data item, or if the parser finds a character reference; otherwise, the parser setsXML-TEXT
. - If
XMLPARSE(XMLSS)
is in effect, the parser setsXML-NTEXT
if theRETURNING NATIONAL
phrase is specified in theXML PARSE
statement, or if the XML document is in a national data item; otherwise, the parser setsXML-TEXT
.
If XMLPARSE(XMLSS)
is
in effect, the parser sets the namespace special registers for a NAMESPACE-DECLARATION
event,
or if it encounters a name that is in a namespace.
When the parser detects an encoding conflict or a well-formedness or validation error in the document, it sets XML-EVENT
to 'EXCEPTION'
and
provides additional information about the exception in the XML-CODE
special
register. You can parse with validation
only if XMLPARSE(XMLSS)
is in effect. For further
details, see the related task about parsing with validation.
For
a detailed description of the set of XML events, see the related
reference about XML-EVENT
.
Example: parsing a simple document
XML parser in COBOL
XML-CODE
XML-INFORMATION
XML-TEXT and XML-NTEXT
XML-NAMESPACE and XML-NNAMESPACE
XML-NAMESPACE-PREFIX and XML-NNAMESPACE-PREFIX
XMLPARSE (compiler option)
XML PARSE exceptions with XMLPARSE(XMLSS) in effect
XML PARSE exceptions with XMLPARSE(COMPAT) in effect
XML-EVENT (Enterprise COBOL for z/OS Language Reference)