Creates a HTMLPurifier_Token_Start.
@param string $name Tag name
@param array $attr Associative array of attributes
@return HTMLPurifier_Token_Start Generated HTMLPurifier_Token_Start
182927
public function createStart($name, $attr = array())
    {
        $p = clone $this->p_start;
        $p->__construct($name, $attr);
        return $p;
    }
991180
public function startXML($parser, $name, $attr)
    {
        ++$this->xml_depth;
        if (array_key_exists('XMLNS', $attr)) {
            $this->current_ns[$this->xml_depth] = $attr['XMLNS'];
        } else {
            $this->current_ns[$this->xml_depth] = $this->current_ns[$this->xml_depth - 1];
            if (!$this->current_ns[$this->xml_depth]) {
                $this->current_ns[$this->xml_depth] = $this->default_ns;
            }
        }
        $ns = $this->current_ns[$this->xml_depth];
        foreach ($attr as $key => $value) {
            if (mb_orig_strpos($key, ':') !== false) {
                $key = explode(':', $key);
                $key = $key[1];
                $this->ns_map[$key] = $value;
            }
        }
        if (mb_orig_strpos($name, ':') !== false) {
            $name = explode(':', $name);
            $ns = $this->ns_map[$name[0]];
            $name = $name[1];
        }
        $obj = new XMLStreamObject($name, $ns, $attr);
        if ($this->xml_depth > 1) {
            $this->xmlobj[$this->xml_depth - 1]->subs[] = $obj;
        }
        $this->xmlobj[$this->xml_depth] = $obj;
    }
1185484
public function inlineCaptureStart(array $attr = null, $position = 1000)
    {
        $this->capture[] = [
            'func' => 'addInline',
            'args' => [
                'style' => '',
                $attr,
                $position
            ]
        ];

        ob_start();
        return $this;
    }
414319
protected function addAttribute(Tag $tag, $attrName)
	{
		$isUrl = false;
		$exprs = [];
		foreach ($this->captures as $key => $capture)
		{
			if ($capture['name'] !== $attrName)
			{
				continue;
			}
			$exprs[] = $capture['expr'];
			if (isset($this->references['asUrl'][$key]))
			{
				$isUrl = true;
			}
		}
		$exprs = array_unique($exprs);

		$regexp = $this->delimiter . '^';
		$regexp .= (count($exprs) === 1) ? $exprs[0] : '(?:' . implode('|', $exprs) . ')';
		$regexp .= '$' . $this->delimiter . 'D' . $this->modifiers;

		$attribute = $tag->attributes->add($attrName);

		$filter = $this->configurator->attributeFilters['#regexp'];
		$filter->setRegexp($regexp);
		$attribute->filterChain[] = $filter;

		if ($isUrl)
		{
			$filter = $this->configurator->attributeFilters['#url'];
			$attribute->filterChain[] = $filter;
		}
	}
103183
public function createTag($tag, $attr = NULL, $content = NULL)
    {
        $temp = '<'.$tag;
        if($attr != NULL) {
            $attr = (array) $attr;
            foreach($attr as $key => $val) {
                if(is_numeric($key)) {
                    $val = strtolower(trim($val));
                    if(isset($this->attr[$tag][$val])) {
                        $args[$val] = $this->attr[$tag][$val];
                        //$args[] = $val.($this->attr[$tag][$val] == NULL ? '' : "=\"{$this->attr[$tag][$val]}\"");
                    }
                    else {
                        $args[$val] = NULL;
                    }
                }
                else {
                    if(!isset($args[$key])) {
                        $args[$key] = $val;
                    }
                }
                if(isset($this->attr[$tag][$key])) {
                    if(is_array($this->attr[$tag][$key])) {
                        foreach($this->attr[$tag][$key] as $k => $v) {
                            if(isset($v[$val]) && !isset($args[$val])) {
                                $args[$k] = $v[$val];
                            }
                        }
                    }
                    else {
                        if(!isset($args[$val])) {
                            $args[$key] = $this->attr[$tag][$key];
                        }
                    }
                }
            }
            unset($attr);
            foreach($args as $key => $val) {
                $attr[] = $key.($val == NULL ? '' : "=\"$val\"");
            }
            unset($args);
            $args = array_unique($attr);
            $args = implode(' ', $args);
        }
        $temp .= isset($args) ? ' '.$args.'>' : '>'; 
        if($content != NULL) {
            if(is_array($content)) {
                array_walk($content, function(&$val, $key) { $val = trim($val); } );//5.3
                $content = implode("\n",$content);
                $content = explode("\n", $content);
                $content = preg_replace('/^/', "\t", $content);
                #$content = preg_filter('/^/', "@", $content);
                $content = rtrim("\n".implode("\n", $content), "\n")."\n";
            }
            $temp .= $content;
        }
        if($this->tags[$tag] === true) {
            $temp .= '</'.$tag.'>';
        }
        return $temp;
    }
1099511
public function startXML($parser, $name, $attr) {
		if($this->been_reset) {
			$this->been_reset = false;
			$this->xml_depth = 0;
		}
		$this->xml_depth++;
		if(array_key_exists('XMLNS', $attr)) {
			$this->current_ns[$this->xml_depth] = $attr['XMLNS'];
		} else {
			$this->current_ns[$this->xml_depth] = $this->current_ns[$this->xml_depth - 1];
			if(!$this->current_ns[$this->xml_depth]) $this->current_ns[$this->xml_depth] = $this->default_ns;
		}
		$ns = $this->current_ns[$this->xml_depth];
		foreach($attr as $key => $value) {
			if(strstr($key, ":")) {
				$key = explode(':', $key);
				$key = $key[1];
				$this->ns_map[$key] = $value;
			}
		}
		if(!strstr($name, ":") === false)
		{
			$name = explode(':', $name);
			$ns = $this->ns_map[$name[0]];
			$name = $name[1];
		}
		$obj = new XMPPHP_XMLObj($name, $ns, $attr);
		if($this->xml_depth > 1) {
			$this->xmlobj[$this->xml_depth - 1]->subs[] = $obj;
		}
		$this->xmlobj[$this->xml_depth] = $obj;
	}
306518
public function addLabel($name, $label = '', $attr = [] )
    {
        $e = new \FrenchFrogs\Form\Element\Label($name, $label, $attr);
        $this->addElement($e);
        return $e;
    }
1091520
public function loadOrCreateTag($name)
    {
        $tag = $this->loadTag($name);
        if (null === $tag) {
            $tag = $this->createTag($name);
        }

        return $tag;
    }
780097
public function startAttribute($name, $value)
    {
        $this->checkStartAttribute($name);

        $this->xmlWriter->startAttribute($name);
        $this->xmlWriter->text($value);
    }
848975
public function addTitle($name, $attr = [])
    {
        $e = new \FrenchFrogs\Form\Element\Title($name, $attr);
        $this->addElement($e);
        return $e;
    }
493852
public function startTag($name, $attributes = array(), $selfClosing = false) {
        // fprintf(STDOUT, $name);
        $lname = $this->normalizeTagName($name);

        // Make sure we have an html element.
        if (!$this->doc->documentElement && $name !== 'html' && !$this->frag) {
            $this->startTag('html');
        }

        // Set quirks mode if we're at IM_INITIAL with no doctype.
        if ($this->insertMode == static::IM_INITIAL) {
            $this->quirks = true;
            $this->parseError("No DOCTYPE specified.");
        }

        // SPECIAL TAG HANDLING:
        // Spec says do this, and "don't ask."
        if ($name == 'image') {
            $name = 'img';
        }

        // Autoclose p tags where appropriate.
        if ($this->insertMode >= static::IM_IN_BODY && HTML5_Elements::isA($name, HTML5_Elements::AUTOCLOSE_P)) {
            $this->autoclose('p');
        }

        // Set insert mode:
        switch ($name) {
            case 'html':
                $this->insertMode = static::IM_BEFORE_HEAD;
                break;
            case 'head':
                if ($this->insertMode > static::IM_BEFORE_HEAD) {
                    $this->parseError("Unexpected head tag outside of head context.");
                } else {
                    $this->insertMode = static::IM_IN_HEAD;
                }
                break;
            case 'body':
                $this->insertMode = static::IM_IN_BODY;
                break;
            case 'svg':
                $this->insertMode = static::IM_IN_SVG;
                break;
            case 'math':
                $this->insertMode = static::IM_IN_MATHML;
                break;
            case 'noscript':
                if ($this->insertMode == static::IM_IN_HEAD) {
                    $this->insertMode = static::IM_IN_HEAD_NOSCRIPT;
                }
                break;
        }

        // Special case handling for SVG.
        if ($this->insertMode == static::IM_IN_SVG) {
            $lname = HTML5_Elements::normalizeSvgElement($lname);
        }

        $pushes = 0;
        // when we found a tag thats appears inside $nsRoots, we have to switch the defalut namespace
        if (isset($this->nsRoots[$lname]) && $this->nsStack[0][''] !== $this->nsRoots[$lname]) {
            array_unshift($this->nsStack, array(
                '' => $this->nsRoots[$lname]
                    ) + $this->nsStack[0]);
            $pushes ++;
        }
        $needsWorkaround = false;
        if (isset($this->options["xmlNamespaces"]) && $this->options["xmlNamespaces"]) {
            // when xmlNamespaces is true a and we found a 'xmlns' or 'xmlns:*' attribute, we should add a new item to the $nsStack
            foreach ($attributes as $aName => $aVal) {
                if ($aName === 'xmlns') {
                    $needsWorkaround = $aVal;
                    array_unshift($this->nsStack, array(
                        '' => $aVal
                            ) + $this->nsStack[0]);
                    $pushes ++;
                } elseif ((($pos = strpos($aName, ':')) ? substr($aName, 0, $pos) : '') === 'xmlns') {
                    array_unshift($this->nsStack, array(
                        substr($aName, $pos + 1) => $aVal
                            ) + $this->nsStack[0]);
                    $pushes ++;
                }
            }
        }

        try {
            $prefix = ($pos = strpos($lname, ':')) ? substr($lname, 0, $pos) : '';


            if ($needsWorkaround !== false) {

                $xml = "<$lname xmlns=\"$needsWorkaround\" " . (strlen($prefix) && isset($this->nsStack[0][$prefix]) ? ("xmlns:$prefix=\"" . $this->nsStack[0][$prefix] . "\"") : "") . "/>";

                $frag = new \DOMDocument('1.0', 'UTF-8');
                $frag->loadXML($xml);

                $ele = $this->doc->importNode($frag->documentElement, true);
            } else {
                if (!isset($this->nsStack[0][$prefix]) || ($prefix === "" && isset($this->options['disableHtmlNsInDom']) && $this->options['disableHtmlNsInDom'])) {
                    $ele = $this->doc->createElement($lname);
                } else {
                    $ele = $this->doc->createElementNS($this->nsStack[0][$prefix], $lname);
                }
            }
        } catch (\DOMException $e) {
            $this->parseError("Illegal tag name: <$lname>. Replaced with <invalid>.");
            $ele = $this->doc->createElement('invalid');
        }

        // When we add some namespacess, we have to track them. Later, when "endElement" is invoked, we have to remove them.
        // When we are on a void tag, we do not need to care about namesapce nesting.
        if ($pushes > 0 && !HTML5_Elements::isA($name, HTML5_Elements::VOID_TAG)) {
            // PHP tends to free the memory used by DOM,
            // to avoid spl_object_hash collisions whe have to avoid garbage collection of $ele storing it into $pushes
            // see https://bugs.php.net/bug.php?id=67459
            $this->pushes[spl_object_hash($ele)] = array($pushes, $ele);

            // SEE https://github.com/facebook/hhvm/issues/2962
            if (defined('HHVM_VERSION')) {
                $ele->setAttribute('html5-php-fake-id-attribute', spl_object_hash($ele));
            }
        }

        foreach ($attributes as $aName => $aVal) {
            // xmlns attributes can't be set
            if ($aName === 'xmlns') {
                continue;
            }

            if ($this->insertMode == static::IM_IN_SVG) {
                $aName = HTML5_Elements::normalizeSvgAttribute($aName);
            } elseif ($this->insertMode == static::IM_IN_MATHML) {
                $aName = HTML5_Elements::normalizeMathMlAttribute($aName);
            }

            try {
                $prefix = ($pos = strpos($aName, ':')) ? substr($aName, 0, $pos) : false;

                if ($prefix === 'xmlns') {
                    $ele->setAttributeNs(self::NAMESPACE_XMLNS, $aName, $aVal);
                } elseif ($prefix !== false && isset($this->nsStack[0][$prefix])) {
                    $ele->setAttributeNs($this->nsStack[0][$prefix], $aName, $aVal);
                } else {
                    $ele->setAttribute($aName, $aVal);
                }
            } catch (\DOMException $e) {
                $this->parseError("Illegal attribute name for tag $name. Ignoring: $aName");
                continue;
            }

            // This is necessary on a non-DTD schema, like HTML5.
            if ($aName == 'id') {
                $ele->setIdAttribute('id', true);
            }
        }

        // Some elements have special processing rules. Handle those separately.
        if ($this->rules->hasRules($name) && $this->frag !== $this->current) {
            $this->current = $this->rules->evaluate($ele, $this->current);
        }         // Otherwise, it's a standard element.
        else {
            $this->current->appendChild($ele);

            // XXX: Need to handle self-closing tags and unary tags.
            if (!HTML5_Elements::isA($name, HTML5_Elements::VOID_TAG)) {
                $this->current = $ele;
            }
        }

        // This is sort of a last-ditch attempt to correct for cases where no head/body
        // elements are provided.
        if ($this->insertMode <= static::IM_BEFORE_HEAD && $name != 'head' && $name != 'html') {
            $this->insertMode = static::IM_IN_BODY;
        }

        // When we are on a void tag, we do not need to care about namesapce nesting,
        // but we have to remove the namespaces pushed to $nsStack.
        if ($pushes > 0 && HTML5_Elements::isA($name, HTML5_Elements::VOID_TAG)) {
            // remove the namespaced definded by current node
            for ($i = 0; $i < $pushes; $i ++) {
                array_shift($this->nsStack);
            }
        }
        // Return the element mask, which the tokenizer can then use to set
        // various processing rules.
        return HTML5_Elements::element($name);
    }
615006
public function start_element($parser, $name, $attrs)
    {
        if ($this->status == 'schema') {
            $this->currentSchema->schemaStartElement($parser, $name, $attrs);
            $this->appendDebug($this->currentSchema->getDebug());
            $this->currentSchema->clearDebug();
        } elseif (preg_match('/schema$/', $name)) {
            $this->debug('Parsing WSDL schema');
            // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
            $this->status = 'schema';
            $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
            $this->currentSchema->schemaStartElement($parser, $name, $attrs);
            $this->appendDebug($this->currentSchema->getDebug());
            $this->currentSchema->clearDebug();
        } else {
            // position in the total number of elements, starting from 0
            $pos = $this->position++;
            $depth = $this->depth++;
            // set self as current value for this depth
            $this->depth_array[$depth] = $pos;
            $this->message[$pos] = array('cdata' => '');
            // process attributes
            if (count($attrs) > 0) {
                // register namespace declarations
                foreach ($attrs as $k => $v) {
                    if (preg_match('/^xmlns/', $k)) {
                        if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
                            $this->namespaces[$ns_prefix] = $v;
                        } else {
                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
                        }
                        if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
                            $this->XMLSchemaVersion = $v;
                            $this->namespaces['xsi'] = $v . '-instance';
                        }
                    }
                }
                // expand each attribute prefix to its namespace
                foreach ($attrs as $k => $v) {
                    $k = strpos($k, ':') ? $this->expandQname($k) : $k;
                    if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
                        $v = strpos($v, ':') ? $this->expandQname($v) : $v;
                    }
                    $eAttrs[$k] = $v;
                }
                $attrs = $eAttrs;
            } else {
                $attrs = array();
            }
            // get element prefix, namespace and name
            if (preg_match('/:/', $name)) {
                // get ns prefix
                $prefix = substr($name, 0, strpos($name, ':'));
                // get ns
                $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
                // get unqualified name
                $name = substr(strstr($name, ':'), 1);
            }
            // process attributes, expanding any prefixes to namespaces
            // find status, register data
            switch ($this->status) {
                case 'message':
                    if ($name == 'part') {
                        if (isset($attrs['type'])) {
                            $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
                        }
                        if (isset($attrs['element'])) {
                            $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
                        }
                    }
                    break;
                case 'portType':
                    switch ($name) {
                        case 'operation':
                            $this->currentPortOperation = $attrs['name'];
                            $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
                            if (isset($attrs['parameterOrder'])) {
                                $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
                            }
                            break;
                        case 'documentation':
                            $this->documentation = true;
                            break;
                        // merge input/output data
                        default:
                            $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
                            $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
                            break;
                    }
                    break;
                case 'binding':
                    switch ($name) {
                        case 'binding':
                            // get ns prefix
                            if (isset($attrs['style'])) {
                                $this->bindings[$this->currentBinding]['prefix'] = $prefix;
                            }
                            $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
                            break;
                        case 'header':
                            $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
                            break;
                        case 'operation':
                            if (isset($attrs['soapAction'])) {
                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
                            }
                            if (isset($attrs['style'])) {
                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
                            }
                            if (isset($attrs['name'])) {
                                $this->currentOperation = $attrs['name'];
                                $this->debug("current binding operation: $this->currentOperation");
                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
                            }
                            break;
                        case 'input':
                            $this->opStatus = 'input';
                            break;
                        case 'output':
                            $this->opStatus = 'output';
                            break;
                        case 'body':
                            if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
                            } else {
                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
                            }
                            break;
                    }
                    break;
                case 'service':
                    switch ($name) {
                        case 'port':
                            $this->currentPort = $attrs['name'];
                            $this->debug('current port: ' . $this->currentPort);
                            $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);

                            break;
                        case 'address':
                            $this->ports[$this->currentPort]['location'] = $attrs['location'];
                            $this->ports[$this->currentPort]['bindingType'] = $namespace;
                            $this->bindings[$this->ports[$this->currentPort]['binding']]['bindingType'] = $namespace;
                            $this->bindings[$this->ports[$this->currentPort]['binding']]['endpoint'] = $attrs['location'];
                            break;
                    }
                    break;
            }
            // set status
            switch ($name) {
                case 'import':
                    if (isset($attrs['location'])) {
                        $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
                        $this->debug('parsing import ' . $attrs['namespace'] . ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]) . ')');
                    } else {
                        $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
                        if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace'];
                        }
                        $this->debug('parsing import ' . $attrs['namespace'] . ' - [no location] (' . count($this->import[$attrs['namespace']]) . ')');
                    }
                    break;
                //wait for schema
                //case 'types':
                //	$this->status = 'schema';
                //	break;
                case 'message':
                    $this->status = 'message';
                    $this->messages[$attrs['name']] = array();
                    $this->currentMessage = $attrs['name'];
                    break;
                case 'portType':
                    $this->status = 'portType';
                    $this->portTypes[$attrs['name']] = array();
                    $this->currentPortType = $attrs['name'];
                    break;
                case "binding":
                    if (isset($attrs['name'])) {
                        // get binding name
                        if (strpos($attrs['name'], ':')) {
                            $this->currentBinding = $this->getLocalPart($attrs['name']);
                        } else {
                            $this->currentBinding = $attrs['name'];
                        }
                        $this->status = 'binding';
                        $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
                        $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
                    }
                    break;
                case 'service':
                    $this->serviceName = $attrs['name'];
                    $this->status = 'service';
                    $this->debug('current service: ' . $this->serviceName);
                    break;
                case 'definitions':
                    foreach ($attrs as $name => $value) {
                        $this->wsdl_info[$name] = $value;
                    }
                    break;
            }
        }
    }
265329
public static function tag($tag, $attr = [], $html = '')
    {
        // Build attributes
        $attributes = [];
        foreach ($attr as $name => $value) {
            $attributes[] = $name.'="'.$value.'"';
        }

        if (in_array($tag, self::$voidElements)) {
            return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>';
        } else {
            return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'.$html.'</'.$tag.'>';
        }
    }
1297596
public function getAttribute($name)
    {
        if (!\array_key_exists($name, $this->attributes)) {
            throw new \InvalidArgumentException(sprintf('This token has no "%s" attribute.', $name));
        }

        return $this->attributes[$name];
    }
340225
public function legend($name, $legend, array $attr = null)
    {
        return $this->input($name, [ 'type' => 'legend', 'legend' => $legend, 'attr' => $attr ]);
    }
128608
public function label($name, $label, array $attr = null)
    {
        return $this->input($name, [ 'type' => 'label', 'label' => $label, 'attr' => $attr ]);
    }
688125
public static function create($name, $content = '', $attribs = [], $forcePair = false)
    {
        $name = trim($name);

        $tag = '<' . $name;

        $tag .= static::buildAttributes($attribs);

        if ($content !== null) {
            $tag .= '>' . $content . '</' . $name . '>';
        } else {
            $tag .= $forcePair ? '></' . $name . '>' : ' />';
        }

        return $tag;
    }