PHP xml_set_notation_decl_handler() function

Definition and Usage

The xml_set_notation_decl_handler() function specifies the function called when the parser finds a symbol declaration in the XML document.

If the processor is successfully established, this function will return true; otherwise, it will return false.

Note:Symbol declaration, in English, also known as notation declaration, and some literature translates it as 'comment declaration'.

Syntax

xml_set_notation_decl_handler(parser,handler)
Parameters Description
parser Mandatory. The variable specifies the XML parser to be used.
handler Mandatory. The function called when the parser finds a symbol declaration.

By handler The function specified by the parameter must have six parameters:

Parameters Description
parser Mandatory. The variable contains the XML parser that calls the processor.
name Mandatory. The variable contains the entity name.
base

Mandatory. The variable contains the base for the system identifier (system_id) of the entity to be parsed.

Currently, this parameter is usually set to an empty string.

system_id Mandatory. The variable specifies the system identifier of the entity.
public_id Mandatory. The variable contains the public identifier of the entity.
notation Required. Specifies a variable containing the symbol that identifies the data type of the entity.

Description

handler The parameter can also be an array containing object references and method names.

Examples

<?php
$parser=xml_parser_create();
function char($parser,$data)
  {
  echo $data;
  }
function not_decl_handler($parser,$not,$base,$sysID,$pubID)
  {
  echo "$not<br />";
  echo "$sysID<br />";
  echo "$pubID<BR />";
  }
xml_set_character_data_handler($parser,"char");
xml_set_notation_decl_handler($parser, "not_decl_handler");
$fp=fopen("test.xml","r");
while ($data=fread($fp,4096))
  {
  xml_parse($parser,$data,feof($fp)) or 
  die (sprintf("XML Error: %s at line %d", 
  xml_error_string(xml_get_error_code($parser)),
  xml_get_current_line_number($parser)));
  }
xml_parser_free($parser);
?>