本文整理汇总了PHP中xml_set_unparsed_entity_decl_handler函数的典型用法代码示例。如果您正苦于以下问题:PHP xml_set_unparsed_entity_decl_handler函数的具体用法?PHP xml_set_unparsed_entity_decl_handler怎么用?PHP xml_set_unparsed_entity_decl_handler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xml_set_unparsed_entity_decl_handler函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AbstractSAXParser
function AbstractSAXParser()
{
// create a parser
$this->parserResource = xml_parser_create();
if (isset($this->parserResource)) {
// allowing object instance to use the xml parser
xml_set_object($this->parserResource, $this);
// set tag event handler
xml_set_element_handler($this->parserResource, "startTagElement", "endTagElement");
// set CDATA event handler
xml_set_character_data_handler($this->parserResource, "cdataElement");
// set processing instruction handler
xml_set_processing_instruction_handler($this->parserResource, "instructionElement");
// set undeclare entity
xml_set_unparsed_entity_decl_handler($this->parserResource, "undeclaredEntityElement");
// set notation delcaration handler
xml_set_notation_decl_handler($this->parserResource, "notationDeclarationElement");
// set external entity handler
xml_set_external_entity_ref_handler($this->parserResource, "externalEntityElement");
// seat default parser option
xml_parser_set_option($this->parserResource, XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($this->parserResource, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($this->parserResource, XML_OPTION_TARGET_ENCODING, 'UTF-8');
}
}
示例2: __construct
public function __construct($input, $maxDepth = 20)
{
if (!is_string($input)) {
throw new XmlToArrayException('No valid input.');
}
$this->_maxDepth = $maxDepth;
$XMLParser = xml_parser_create();
xml_parser_set_option($XMLParser, XML_OPTION_SKIP_WHITE, false);
xml_parser_set_option($XMLParser, XML_OPTION_CASE_FOLDING, false);
xml_parser_set_option($XMLParser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
xml_set_character_data_handler($XMLParser, array($this, '_contents'));
xml_set_default_handler($XMLParser, array($this, '_default'));
xml_set_element_handler($XMLParser, array($this, '_start'), array($this, '_end'));
xml_set_external_entity_ref_handler($XMLParser, array($this, '_externalEntity'));
xml_set_notation_decl_handler($XMLParser, array($this, '_notationDecl'));
xml_set_processing_instruction_handler($XMLParser, array($this, '_processingInstruction'));
xml_set_unparsed_entity_decl_handler($XMLParser, array($this, '_unparsedEntityDecl'));
if (!xml_parse($XMLParser, $input, true)) {
$errorCode = xml_get_error_code($XMLParser);
$message = sprintf('%s. line: %d, char: %d' . ($this->_tagStack ? ', tag: %s' : ''), xml_error_string($errorCode), xml_get_current_line_number($XMLParser), xml_get_current_column_number($XMLParser) + 1, implode('->', $this->_tagStack));
xml_parser_free($XMLParser);
throw new XmlToArrayException($message, $errorCode);
}
xml_parser_free($XMLParser);
}
示例3: parse
function parse($data)
{
$parser = xml_parser_create();
xml_set_object($parser, $this);
xml_set_notation_decl_handler($parser, "notation_decl_handler");
xml_set_unparsed_entity_decl_handler($parser, "unparsed_entity_decl_handler");
xml_parse($parser, $data, true);
xml_parser_free($parser);
}
示例4: SaxParser
function SaxParser(&$input)
{
$this->level = 0;
$this->parser = xml_parser_create('UTF-8');
xml_set_object($this->parser, $this);
$this->input =& $input;
$this->setCaseFolding(false);
$this->useUtfEncoding();
xml_set_element_handler($this->parser, 'handleBeginElement', 'handleEndElement');
xml_set_character_data_handler($this->parser, 'handleCharacterData');
xml_set_processing_instruction_handler($this->parser, 'handleProcessingInstruction');
xml_set_default_handler($this->parser, 'handleDefault');
xml_set_unparsed_entity_decl_handler($this->parser, 'handleUnparsedEntityDecl');
xml_set_notation_decl_handler($this->parser, 'handleNotationDecl');
xml_set_external_entity_ref_handler($this->parser, 'handleExternalEntityRef');
}
示例5: init
protected final function init()
{
if ($this instanceof Features\IXmlNamespaceParser) {
$this->parser = xml_parser_create_ns('UTF-8');
// Set up start namespace declaration handler
xml_set_start_namespace_decl_handler($this->parser, 'ns_start');
// Set up end namespace declaration handler
xml_set_end_namespace_decl_handler($this->parser, 'ns_end');
} elseif ($this instanceof Features\IXmlBasicParser) {
$this->parser = xml_parser_create('UTF-8');
} else {
throw new \BadMethodCallException('This class does not implements the XML Parser capabilities. Please implement either IXmlBasicParser or IXmlNamespaceParser.');
}
xml_set_object($this->parser, $this);
foreach ($this->options as $option => $value) {
xml_parser_set_option($this->parser, $option, $value);
}
if ($this instanceof Features\IXmlProcessorParser) {
// Set up processing instruction (PI) handler
xml_set_processing_instruction_handler($this->parser, 'pi_handler');
}
if ($this instanceof Features\IXmlEntityHandler) {
// Set up external entity reference handler
xml_set_external_entity_ref_handler($this->parser, 'entity_handler');
}
if ($this instanceof Features\IXmlNdataHandler) {
// Set up notation declaration handler
xml_set_notation_decl_handler($this->parser, 'notation_handler');
// Set up unparsed entity declaration handler
xml_set_unparsed_entity_decl_handler($this->parser, 'ndata_handler');
}
xml_set_element_handler($this->parser, "element_start", "element_end");
xml_set_character_data_handler($this->parser, "cdata_handler");
if ($this instanceof Features\IXmlDefaultHandler) {
if (!defined('ACTIVATE_XML_PARSER_DEFAULT_HANDLER_I_KNOW_WHAT_AM_I_DOING')) {
trigger_error('Active default handler interferes with many XML features like internal parsable entities.', E_USER_WARNING);
}
// Set up default (fallback) handler.
// Warning: Interferes with INTERNAL ENTITY declarations like
// <!ENTITY a 'b'>
xml_set_default_handler($this->parser, "default_handler");
}
}
示例6: runtest
function runtest($num, $i)
{
$this->readfile($num);
echo "parsing xml data file {$this->currentFile} iteration {$i}\n";
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1);
xml_set_object($xml_parser, $this);
xml_set_element_handler($xml_parser, 'startElement', 'endElement');
xml_set_character_data_handler($xml_parser, 'cDataHandler');
xml_set_external_entity_ref_handler($xml_parser, 'externalEntityRefHandler');
xml_set_processing_instruction_handler($xml_parser, 'piHandler');
xml_set_unparsed_entity_decl_handler($xml_parser, 'unparsedEntityDeclHandler');
xml_set_notation_decl_handler($xml_parser, 'entityDeclHandler');
xml_set_default_handler($xml_parser, 'defaultHandler');
if (!xml_parse($xml_parser, $this->contentBuffer, true)) {
$this->currentFile != '' ? $inFile = "in file {$this->currentFile}" : ($inFile = '');
$this->fatalErrorPage(sprintf(get_class($this) . ": XML error: %s at line %d {$inFile}", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
}
示例7: register
/**
* Register this class with a parser
*
* @param string $namespace (optional)
* @param string $encoding (optional) default into to autodetect based on env
* @param string $separator (optional) the seperator to use for namespace
* @return resource the parser
*/
public function register($encoding = '', $namespace = false, $separator = null)
{
if ($this->parser === null) {
if ($namespace !== null) {
$this->parser = xml_parser_create_ns($encoding, $separator);
} else {
$this->parser = xml_parser_create($encoding);
}
if (!$this->parser) {
throw new RegisterParserFailure('call to xml_parser_create() failed');
}
# set element handler
xml_set_element_handler($this->parser, array($this, "xmlStartTag"), array($this, "xmlEndTag"));
# set CDATA hander
xml_set_character_data_handler($this->parser, array($this, "xmlTagContent"));
# set processing instructions handler
xml_set_processing_instruction_handler($this->parser, array($this, "xmlPI"));
# set the unparsed entity declaration handler
xml_set_unparsed_entity_decl_handler($this->parser, array($this, "xmlUnparsedEntity"));
# set the notation declaration handler function
xml_set_notation_decl_handler($this->parser, array($this, "xmlNotation"));
# set the external entity reference handler function
xml_set_external_entity_ref_handler($this->parser, array($this, "xmlEentityRef"));
# Sets the default handler function
xml_set_default_handler($this->parser, array($this, "xmlDefault"));
# Set a handler to be called when a namespace is declared.
xml_set_start_namespace_decl_handler($this->parser, array($this, "xmlNSStart"));
# Set a handler to be called when leaving the scope of a namespace declaration
xml_set_end_namespace_decl_handler($this->parser, array($this, "xmlNSEnd"));
# turn off case folding to stop element names from being uppercased;
$this->setOption(XML_OPTION_CASE_FOLDING, false);
//$this->setOption(XML_OPTION_SKIP_WHITE, true);
} else {
throw new ParserException('Parser already registered call XML::unregister() first');
}
return $this->parser;
}
示例8: register
/**
*
* @access protected
*/
function register()
{
xml_set_character_data_handler($this->parser, 'character_data');
xml_set_default_handler($this->parser, 'default_data');
xml_set_element_handler($this->parser, 'tag_open', 'tag_close');
xml_set_end_namespace_decl_handler($this->parser, 'end_namespace_decl');
xml_set_external_entity_ref_handler($this->parser, 'external_entity_ref');
xml_set_notation_decl_handler($this->parser, 'notation_decl');
xml_set_processing_instruction_handler($this->parser, 'processing_instruction');
xml_set_start_namespace_decl_handler($this->parser, 'start_namespace_decl');
xml_set_unparsed_entity_decl_handler($this->parser, 'unparsed_entity');
return $this->registered = 1;
}
示例9: _initParser
/**
* @internal
* Init the XML parser
* @param $ns
* @param $encoding
* @param $separator
* @private
*/
function _initParser($ns = false, $encoding = 'UTF-8', $separator = null)
{
$this->_p = $ns ? xml_parser_create_ns($encoding, $separator) : xml_parser_create($encoding);
xml_set_object($this->_p, $this);
xml_set_default_handler($this->_p, '_default');
xml_set_element_handler($this->_p, '_tagOpen', '_tagClose');
xml_set_character_data_handler($this->_p, '_cdata');
xml_set_start_namespace_decl_handler($this->_p, '_nsStart');
xml_set_end_namespace_decl_handler($this->_p, '_nsEnd');
xml_set_external_entity_ref_handler($this->_p, '_entityRef');
xml_set_processing_instruction_handler($this->_p, '_pi');
xml_set_notation_decl_handler($this->_p, '_notation');
xml_set_unparsed_entity_decl_handler($this->_p, '_unparsedEntity');
$this->setOption(XML_OPTION_CASE_FOLDING, false);
}
示例10: Aspis_xml_set_unparsed_entity_decl_handler
function Aspis_xml_set_unparsed_entity_decl_handler($parser, $handler)
{
global $Aspis_xml_objects;
if (!empty($Aspis_xml_objects)) {
$c = count($Aspis_xml_objects);
for ($i = $c - 1; $i >= 0; $i--) {
$e = $Aspis_xml_objects[$i];
if ($e[0] === $parser[0]) {
$handler[0] = AspisInternalCallback(array(array(array($e[1], false), array($handler[0], false)), false));
break;
}
}
}
return array(xml_set_unparsed_entity_decl_handler($parser[0], $handler[0]), false);
}
示例11: xml_set_unparsed_entity_decl_handler
* Description: Set up unparsed entity declaration handler
* Source code: ext/xml/xml.c
* Alias to functions:
*/
echo "*** Testing xml_set_unparsed_entity_decl_handler() : usage variations ***\n";
error_reporting(E_ALL & ~E_NOTICE);
class aClass
{
function __toString()
{
return "Some Ascii Data";
}
}
function validHandler(resource $parser, string $data)
{
}
// Initialise function arguments not being substituted (if any)
$hdl = 'validHandler';
//get an unset variable
$unset_var = 10;
unset($unset_var);
$fp = fopen(__FILE__, "r");
//array of values to iterate over
$values = array(0, 1, 12345, -2345, 10.5, -10.5, 101234567000.0, 1.07654321E-9, 0.5, array(), array(0), array(1), array(1, 2), array('color' => 'red', 'item' => 'pen'), NULL, null, true, false, TRUE, FALSE, "", '', "string", 'string', new aClass(), $fp, $undefined_var, $unset_var);
// loop through each element of the array for parser
foreach ($values as $value) {
echo @"\nArg value {$value} \n";
var_dump(xml_set_unparsed_entity_decl_handler($value, $hdl));
}
fclose($fp);
echo "Done";
示例12: xml_parser_create
require_once '../../includes/header.php';
?>
<pre>
<?php
//We firstly need to create the parser
$parser = xml_parser_create();
/**
* When the parser reads the XML it can call functions that we can then add code to handle.
* The code below makes the parser call function when a new element is found within an XML document,
* and when the end of an element is detected
*/
xml_set_element_handler($parser, "startElement", "stopElement");
xml_set_character_data_handler($parser, "characterData");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_set_default_handler($parser, 'functionName');
xml_set_unparsed_entity_decl_handler($parser, 'functionNameUnparsed');
/**
* Callback functions
* The parser will call the functions we have defined when parsing the XML so we now need to create those functions
*/
function startElement($parser, $name, $attrs)
{
echo "Start [{$name}] -> Attributes = ";
print_r($attrs);
}
function stopElement($parser, $name)
{
echo "End [{$name}] \n";
}
function characterData($parser, $data)
{
示例13: resetParser
/**
* Resets internal XML Parser instance
*/
protected function resetParser()
{
if (is_resource($this->parser)) {
xml_parser_free($this->parser);
$this->parser = null;
}
$this->documentNode = null;
$this->nodeStack = array(new $this->params['nodeClass'](VIVVO_XML_DOCUMENT_NODE));
$this->parser = xml_parser_create($this->params['encoding']);
xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
xml_set_element_handler($this->parser, array(&$this, 'handlerNodeStart'), array(&$this, 'handlerNodeEnd'));
xml_set_character_data_handler($this->parser, array(&$this, 'handlerTextNode'));
xml_set_default_handler($this->parser, array(&$this, 'handlerDefault'));
xml_set_end_namespace_decl_handler($this->parser, false);
xml_set_external_entity_ref_handler($this->parser, false);
xml_set_notation_decl_handler($this->parser, false);
xml_set_processing_instruction_handler($this->parser, false);
xml_set_start_namespace_decl_handler($this->parser, false);
xml_set_unparsed_entity_decl_handler($this->parser, false);
VivvoXMLNode::$counter = 0;
}
示例14: notation
print "external: [{$names}] [{$sysid}] [{$pubid}]\n";
}
function notation($parser, $name, $base, $sysid, $pubid)
{
print "notation: [{$names}] [{$sysid}] [{$pubid}]\n";
}
function pi_h($parser, $target, $data)
{
print "pi: [{$target}] [{$data}]";
}
function unparsed($parser, $name, $base, $sysid, $pubid, $notation)
{
print "unparsed: [{$names}] [{$sysid}] [{$pubid}] [{$notation}]\n";
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, 'startElement', 'endElement');
xml_set_character_data_handler($xml_parser, 'cdata');
xml_set_default_handler($xml_parser, 'default_h');
xml_set_external_entity_ref_handler($xml_parser, 'ext_ent');
xml_set_notation_decl_handler($xml_parser, 'notation');
xml_set_processing_instruction_handler($xml_parser, 'pi_h');
xml_set_unparsed_entity_decl_handler($xml_parser, 'unparsed');
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
示例15: xml_set_unparsed_entity_decl_handler
<?php
/* Prototype : proto int xml_set_unparsed_entity_decl_handler(resource parser, string hdl)
* Description: Set up unparsed entity declaration handler
* Source code: ext/xml/xml.c
* Alias to functions:
*/
echo "*** Testing xml_set_unparsed_entity_decl_handler() : error conditions ***\n";
//Test xml_set_unparsed_entity_decl_handler with one more than the expected number of arguments
echo "\n-- Testing xml_set_unparsed_entity_decl_handler() function with more than expected no. of arguments --\n";
$hdl = 'string_val';
$extra_arg = 10;
var_dump(xml_set_unparsed_entity_decl_handler(null, $hdl, $extra_arg));
// Testing xml_set_unparsed_entity_decl_handler with one less than the expected number of arguments
echo "\n-- Testing xml_set_unparsed_entity_decl_handler() function with less than expected no. of arguments --\n";
var_dump(xml_set_unparsed_entity_decl_handler(null));
echo "Done";