Source for file States.php
Documentation is available at States.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Alexander Zhukov <alex@veresk.ru> Original port from Python |
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> Port to PEAR + more |
// | Authors: Many @ Sitepointforums Advanced PHP Forums |
// +----------------------------------------------------------------------+
// $Id: States.php 22138 2007-06-01 10:19:14Z markwest $
* @version $Id: States.php 22138 2007-06-01 10:19:14Z markwest $
define('XML_HTMLSAX3_STATE_STOP', 0);
define('XML_HTMLSAX3_STATE_START', 1);
define('XML_HTMLSAX3_STATE_TAG', 2);
define('XML_HTMLSAX3_STATE_OPENING_TAG', 3);
define('XML_HTMLSAX3_STATE_CLOSING_TAG', 4);
define('XML_HTMLSAX3_STATE_ESCAPE', 6);
define('XML_HTMLSAX3_STATE_JASP', 7);
define('XML_HTMLSAX3_STATE_PI', 8);
* StartingState searches for the start of any XML tag
* @param XML_HTMLSax3_StateParser subclass
* @return constant XML_HTMLSAX3_STATE_TAG
function parse(&$context) {
$data = $context->scanUntilString('<');
$context->handler_object_data->
{$context->handler_method_data}($context->htmlsax, $data);
$context->IgnoreCharacter();
* Decides which state to move one from after StartingState
* @param XML_HTMLSax3_StateParser subclass
* @return constant the next state to move into
function parse(&$context) {
switch($context->ScanCharacter()) {
$context->unscanCharacter();
* Dealing with closing XML tags
* @param XML_HTMLSax3_StateParser subclass
* @return constant XML_HTMLSAX3_STATE_START
function parse(&$context) {
$tag = $context->scanUntilCharacters('/>');
$char = $context->scanCharacter();
$char = $context->scanCharacter();
$context->unscanCharacter();
$context->handler_object_element->
{$context->handler_method_closing}($context->htmlsax, $tag, FALSE);
* Dealing with opening XML tags
* @param string attribute name
* @param string attribute value
* @see XML_HTMLSax3_AttributeStartState
$context->ignoreWhitespace();
$attributename = $context->scanUntilCharacters("=/> \n\r\t");
while ($attributename != '') {
$context->ignoreWhitespace();
$char = $context->scanCharacter();
$context->ignoreWhitespace();
$char = $context->ScanCharacter();
$attributevalue= $context->scanUntilString('"');
$context->IgnoreCharacter();
} else if ($char == "'") {
$attributevalue = $context->scanUntilString("'");
$context->IgnoreCharacter();
$context->unscanCharacter();
$context->scanUntilCharacters("> \n\r\t");
} else if ($char !== NULL) {
$context->unscanCharacter();
$Attributes[$attributename] = $attributevalue;
$context->ignoreWhitespace();
$attributename = $context->scanUntilCharacters("=/> \n\r\t");
* @param XML_HTMLSax3_StateParser subclass
* @return constant XML_HTMLSAX3_STATE_START
function parse(&$context) {
$tag = $context->scanUntilCharacters("/> \n\r\t");
$char = $context->scanCharacter();
$char = $context->scanCharacter();
$context->unscanCharacter();
$context->handler_object_element->
{$context->handler_method_opening}($context->htmlsax, $tag,
$context->handler_object_element->
{$context->handler_method_closing}($context->htmlsax, $tag,
$context->handler_object_element->
{$context->handler_method_opening}($context->htmlsax, $tag,
* Deals with XML escapes handling comments and CDATA correctly
* @param XML_HTMLSax3_StateParser subclass
* @return constant XML_HTMLSAX3_STATE_START
function parse(&$context) {
$char = $context->ScanCharacter();
$char = $context->ScanCharacter();
$context->unscanCharacter();
$context->unscanCharacter();
$text = $context->scanUntilString('-->');
$text .= $context->scanCharacter();
$text .= $context->scanCharacter();
$context->unscanCharacter();
$text = $context->scanUntilString('>');
} else if ( $char == '[') {
$context->unscanCharacter();
$text = $context->scanUntilString(']>');
$text.= $context->scanCharacter();
$context->unscanCharacter();
$text = $context->scanUntilString('>');
$context->IgnoreCharacter();
$context->handler_object_escape->
{$context->handler_method_escape}($context->htmlsax, $text);
* Deals with JASP/ASP markup
* @param XML_HTMLSax3_StateParser subclass
* @return constant XML_HTMLSAX3_STATE_START
function parse(&$context) {
$text = $context->scanUntilString('%>');
$context->handler_object_jasp->
{$context->handler_method_jasp}($context->htmlsax, $text);
$context->IgnoreCharacter();
$context->IgnoreCharacter();
* Deals with XML processing instructions
* @param XML_HTMLSax3_StateParser subclass
* @return constant XML_HTMLSAX3_STATE_START
function parse(&$context) {
$target = $context->scanUntilCharacters(" \n\r\t");
$data = $context->scanUntilString('?>');
$context->handler_object_pi->
{$context->handler_method_pi}($context->htmlsax, $target, $data);
$context->IgnoreCharacter();
$context->IgnoreCharacter();
|