src/XML/Element.php
public function addAttribute( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL )
	{
		$key	= $nsPrefix ? $nsPrefix.':'.$name : $name;
		if( $nsPrefix )
		{
			$namespaces	= $this->getDocNamespaces();
			$key		= $nsPrefix ? $nsPrefix.':'.$name : $name;
			if( $this->hasAttribute( $name, $nsPrefix ) )
				throw new RuntimeException( 'Attribute "'.$key.'" is already set' );
			if( array_key_exists( $nsPrefix, $namespaces ) )
				return parent::addAttribute( $key, $value, $namespaces[$nsPrefix] );
			if( $nsURI )
				return parent::addAttribute( $key, $value, $nsURI );
			throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' );
		}
		if( $this->hasAttribute( $name ) )
			throw new RuntimeException( 'Attribute "'.$name.'" is already set' );
		parent::addAttribute( $name, $value );
	}
public function addAttribute( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL )
	{
		$key	= $nsPrefix ? $nsPrefix.':'.$name : $name;
		if( $nsPrefix )
		{
			$namespaces	= $this->getDocNamespaces();
			$key		= $nsPrefix ? $nsPrefix.':'.$name : $name;
			if( $this->hasAttribute( $name, $nsPrefix ) )
				throw new RuntimeException( 'Attribute "'.$key.'" is already set' );
			if( array_key_exists( $nsPrefix, $namespaces ) )
				return parent::addAttribute( $key, $value, $namespaces[$nsPrefix] );
			if( $nsURI )
				return parent::addAttribute( $key, $value, $nsURI );
			throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' );
		}
		if( $this->hasAttribute( $name ) )
			throw new RuntimeException( 'Attribute "'.$name.'" is already set' );
		parent::addAttribute( $name, $value );
	}
public function addAttribute ( $ name , $ value = NULL , $ nsPrefix = NULL , $ nsURI = NULL ) { $ key = $ nsPrefix ? $ nsPrefix . ':' . $ name : $ name ; if ( $ nsPrefix ) { $ namespaces = $ this -> getDocNamespaces ( ) ; $ key = $ nsPrefix ? $ nsPrefix . ':' . $ name : $ name ; if ( $ this -> hasAttribute ( $ name , $ nsPrefix ) ) throw new RuntimeException ( 'Attribute "' . $ key . '" is already set' ) ; if ( array_key_exists ( $ nsPrefix , $ namespaces ) ) return parent :: addAttribute ( $ key , $ value , $ namespaces [ $ nsPrefix ] ) ; if ( $ nsURI ) return parent :: addAttribute ( $ key , $ value , $ nsURI ) ; throw new RuntimeException ( 'Namespace prefix is not registered and namespace URI is missing' ) ; } if ( $ this -> hasAttribute ( $ name ) ) throw new RuntimeException ( 'Attribute "' . $ name . '" is already set' ) ; parent :: addAttribute ( $ name , $ value ) ; }
Adds an attributes.
@access		public
@param		string		$name		Name of attribute
@param		string		$value		Value of attribute
@param		string		$nsPrefix	Namespace prefix of attribute
@param		string		$nsURI		Namespace URI of attribute
@return		void
@throws		RuntimeException		if attribute is already set
@throws		RuntimeException		if namespace prefix is neither registered nor given
Adds an attributes .