Replace an expression with a literal value in given attribute

@param  DOMAttr $attribute
@param  string  $expr
@param  string  $value
@return void
175486
protected function replaceAttribute(DOMAttr $attribute, $expr, $value)
	{
		AVTHelper::replace(
			$attribute,
			function ($token) use ($expr, $value)
			{
				// Test whether this expression is the one we're looking for
				if ($token[0] === 'expression' && $token[1] === $expr)
				{
					// Replace the expression with the value (as a literal)
					$token = ['literal', $value];
				}

				return $token;
			}
		);
	}
39557
public function setAttribute($name, $attribute, $value)
    {
        $this->getField($name)->setAttribute($attribute, $value);
    }
798834
public function setAttribute($attribute, $value) {
		if (!array_key_exists($attribute, $this->_readonlyAttributes)) {
			$this->_attributes[$attribute] = $value;
			return true;
		}

		return false;
	}
86738
public function def($attr, $value)
    {
        $this->attributes[$attr] = isset($this->attributes[$attr]) ? $this->attributes[$attr] : (string) $value;
    }
284432
public function addAttribute($attribute, $value)
    {
        $this->attributes[$attribute] = (string) $value;
        $this->eventHandler->attributeAdded($this, $attribute, $value);
    }
398227
protected function takeAttributeFromDOM($attribute)
    {
        switch ($attribute->localName) {
        case 'type':
            $this->_type = $attribute->nodeValue;
            break;
        case 'lang':
            $this->_lang = $attribute->nodeValue;
            break;
        case 'start':
            $this->_start = $attribute->nodeValue;
            break;
        case 'end':
            $this->_end = $attribute->nodeValue;
            break;
        default:
            parent::takeAttributeFromDOM($attribute);
        }
    }
742925
protected function appendConditionalAttributes(DOMElement $parentNode, $expr)
	{
		preg_match_all('(@([-\\w]+))', $expr, $matches);
		foreach ($matches[1] as $attrName)
		{
			// Create a switch element in the IR
			$switch = $this->appendElement($parentNode, 'switch');
			$case   = $this->appendElement($switch, 'case');
			$case->setAttribute('test', '@' . $attrName);

			// Append an attribute element
			$attribute = $this->appendElement($case, 'attribute');
			$attribute->setAttribute('name', $attrName);

			// Set the attribute's content, which is simply the copied attribute's value
			$this->appendXPathOutput($attribute, '@' . $attrName);
		}
	}
688306
protected function takeAttributeFromDOM($attribute)
    {
        switch ($attribute->localName) {
        case 'relationship':
            $this->_relationship = $attribute->nodeValue;
            break;
        case 'type':
            $this->_type = $attribute->nodeValue;
            break;
        default:
            parent::takeAttributeFromDOM($attribute);
        }
    }
1106645
public function setAttribute($attribute, $value)
    {
        Arr::set($this->attributes, $attribute, $value);

        return $this;
    }
268073
private static void updateAttribute(Element parent, String attrName, String value) {

        if (parent != null) {
            Attribute attribute = parent.attribute(attrName);
            if (value != null) {
                if (attribute == null) {
                    parent.addAttribute(attrName, value);
                } else {
                    attribute.setValue(value);
                }
            } else {
                // remove only if exists
                if (attribute != null) {
                    parent.remove(attribute);
                }
            }
        }
    }
584745
private function setTranslation($locale, $attribute, $value)
    {
        $this->validateLocale($locale);

        $this->translateOrNew($locale)->$attribute = $value;
    }
955407
private static void addAttribute(Element element, Set<Attr> attributes, Object value) {
		Attr attr = (Attr) value;
		if (!attributes.add(attr)) {
			throw new TemplateException("Invalid element |%s|. It has both static attribute |%s| and attribute operator.", element, attr.getName());
		}
	}
225603
protected function takeAttributeFromDOM($attribute)
    {
        switch ($attribute->localName) {
        case 'state':
            $this->_state = $attribute->nodeValue;
            break;
        default:
            parent::takeAttributeFromDOM($attribute);
        }
    }
1324899
public function setAttr($attribute, $value = null)
    {
        if (is_array($attribute) && is_null($value)) {
            foreach ($attribute as $k => $v) {
                $this->setAttr($k, $v);
            }

            return $this;
        }
        $this->template->appendHTML('attributes', ' '.$attribute.'="'.$value.'"');

        return $this;
    }
914314
public function setExpression(string $expr) {
		$this->expression = $expr;
		$this->hasExpression = true;

		return $this;
	}
999000
public function attribute($attribute, $value = null)
    {
        $element = clone $this;

        $element->attributes->setAttribute($attribute, (string) $value);

        return $element;
    }
1292589
public function removeAttributeValue(string $attribute, string $value): self
    {
        // Only remove value if attribute is present
        if (! array_key_exists($attribute, $this->attributes)) {
            return $this;
        }

        // Remove the value from the attribute
        $values = array_filter(
            $this->getAttribute($attribute),
            function ($attributeValue) use ($value) {
                return $attributeValue !== $value;
            }
        );

        // Stores the new values
        $this->setAttribute($attribute, $values);

        return $this;
    }