public function validate($schema = ''){
        
        if (empty($schema)) {
            
            // Let's detect NS in use...
            $dom = new DOMDocument('1.0', 'UTF-8');

            switch($this->sourceType){
                case self::SOURCE_FLYFILE:
                    if ($this->source->exists()) {
                        $dom->load($this->source->read());
                    }
                    break;
                case self::SOURCE_FILE:
                    $dom->load($this->source);
                    break;
                case self::SOURCE_URL:
                    $xmlContent = tao_helpers_Request::load($this->source, true);
                    $dom->loadXML($xmlContent);
                    break;
                case self::SOURCE_STRING:
                    $dom->loadXML($this->source);
                    break;
            }

            // Retrieve Root's namespace.
            if( $dom->documentElement == null ){
                $this->addError('dom is null and could not be validate');
                $returnValue = false;
            } else {
                $ns = $dom->documentElement->lookupNamespaceUri(null);
                $servicemanager = $this->getServiceManager();
                $validationService = $servicemanager->get(ValidationService::SERVICE_ID);
                $schemas = $validationService->getContentValidationSchema($ns);
                $this->logDebug("The following schema will be used to validate: '" . $schemas[0] . "'.");

                $validSchema = $this->validateMultiple($schemas);
                $returnValue = $validSchema !== '';
            }
        } elseif(!file_exists($schema)) {
            throw new \common_Exception('no schema found in the location '.$schema);
        } else {
            $returnValue = parent::validate($schema);
        }

        return (bool) $returnValue;
    }
public function validate($schema = ''){
        
        if (empty($schema)) {
            
            // Let's detect NS in use...
            $dom = new DOMDocument('1.0', 'UTF-8');

            switch($this->sourceType){
                case self::SOURCE_FLYFILE:
                    if ($this->source->exists()) {
                        $dom->load($this->source->read());
                    }
                    break;
                case self::SOURCE_FILE:
                    $dom->load($this->source);
                    break;
                case self::SOURCE_URL:
                    $xmlContent = tao_helpers_Request::load($this->source, true);
                    $dom->loadXML($xmlContent);
                    break;
                case self::SOURCE_STRING:
                    $dom->loadXML($this->source);
                    break;
            }

            // Retrieve Root's namespace.
            if( $dom->documentElement == null ){
                $this->addError('dom is null and could not be validate');
                $returnValue = false;
            } else {
                $ns = $dom->documentElement->lookupNamespaceUri(null);
                $servicemanager = $this->getServiceManager();
                $validationService = $servicemanager->get(ValidationService::SERVICE_ID);
                $schemas = $validationService->getContentValidationSchema($ns);
                $this->logDebug("The following schema will be used to validate: '" . $schemas[0] . "'.");

                $validSchema = $this->validateMultiple($schemas);
                $returnValue = $validSchema !== '';
            }
        } elseif(!file_exists($schema)) {
            throw new \common_Exception('no schema found in the location '.$schema);
        } else {
            $returnValue = parent::validate($schema);
        }

        return (bool) $returnValue;
    }
public function validate ( $ schema = '' ) { if ( empty ( $ schema ) ) { // Let's detect NS in use... $ dom = new DOMDocument ( '1.0' , 'UTF-8' ) ; switch ( $ this -> sourceType ) { case self :: SOURCE_FLYFILE : if ( $ this -> source -> exists ( ) ) { $ dom -> load ( $ this -> source -> read ( ) ) ; } break ; case self :: SOURCE_FILE : $ dom -> load ( $ this -> source ) ; break ; case self :: SOURCE_URL : $ xmlContent = tao_helpers_Request :: load ( $ this -> source , true ) ; $ dom -> loadXML ( $ xmlContent ) ; break ; case self :: SOURCE_STRING : $ dom -> loadXML ( $ this -> source ) ; break ; } // Retrieve Root's namespace. if ( $ dom -> documentElement == null ) { $ this -> addError ( 'dom is null and could not be validate' ) ; $ returnValue = false ; } else { $ ns = $ dom -> documentElement -> lookupNamespaceUri ( null ) ; $ servicemanager = $ this -> getServiceManager ( ) ; $ validationService = $ servicemanager -> get ( ValidationService :: SERVICE_ID ) ; $ schemas = $ validationService -> getContentValidationSchema ( $ ns ) ; $ this -> logDebug ( "The following schema will be used to validate: '" . $ schemas [ 0 ] . "'." ) ; $ validSchema = $ this -> validateMultiple ( $ schemas ) ; $ returnValue = $ validSchema !== '' ; } } elseif ( ! file_exists ( $ schema ) ) { throw new \ common_Exception ( 'no schema found in the location ' . $ schema ) ; } else { $ returnValue = parent :: validate ( $ schema ) ; } return ( bool ) $ returnValue ; }
Run the validation process

@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>

@param  string $schema

@return bool
@throws \Exception
@throws \common_Exception
Run the validation process