XML - DTD handler function

DTD handler function

!function func_id(event_code, arg1, arg2, arg3, arg4)

The DTD handler receives information from notations and unparsed entities defined in the DTD. Notations and unparsed entities are specialised facilities in XML, and are not used by most applications. Definition of a DTD handler function is optional.

The DTD handler function is set with xml_set_DTD_handler. See Registration of handler functions.

The arguments sent to the function vary according to the event code. Event codes are defined in xml.h,

XML_EV_NOTATION_DECL

arg1 = name; arg2 = pub_id; arg3 = sys_id

A notation declaration has been found. A notation declares external, non-XML content, and the external application that handles that content. For example, the notation:

<!NOTATION q SYSTEM “http://www.sculptor.co.uk/Programs/nph-srep.exe”>

would send the values:

name

q

pub_id

(empty)

sys_id

http://www.sculptor.co.uk/Programs/nph-srep.exe


XML_EV_UNPARSED_ENTITY_DECL

arg1 = name; arg2 = pub_id; arg3 = sys_id; arg4 = notation_name

An unparsed entity declaration has been found. The notation_name has been previously reported via XML_EV_NOTATION_DECL. An entity declares special character references, text macros, and other repetitive content from external sources. For example, the entity:

<!ENTITY ScLogo SYSTEM "http://www.sculptor.co.uk/Images/Logo.q NDATA q>

would send the values:

name

ScLogo

pub_id

(empty)

sys_id

http://www.sculptor.co.uk/Images/Logo.q

notation

q


EXAMPLE

     xml_set_DTD_handler(fDTDHandler)

!function fDTDHandler(ev, dec_name, pub_id, sys_id, notation_name) {
!temp evstr,,a30
     switch (ev) {
          case = XML_EV_NOTATION_DECL:
               evstr = "NOTATION_DECL"
               break
          case = XML_EV_UNPARSED_ENTITY_DECL:
               evstr = "UNPARSED_ENTITY_DECL"
               break
     }

     info evstr / "-" + tostr(dec_name) + "-" + tostr(pub_id) + "-" \
          + tostr(sys_id) + "-" + tostr(notation_name)
}

RELATED TOPICS

XML