protected function unmarshall(DOMElement $element)
    {
        if (($src = $this->getDOMElementAttributeAs($element, 'src')) !== null) {

            if (($alt = $this->getDOMElementAttributeAs($element, 'alt')) === null) {
                // The XSD does not force the 'alt' attribute to be non-empty,
                // thus we consider the 'alt' attribute value as an empty string ('').
                $alt = '';
            }

            $component = new Img($src, $alt);

            if (($longdesc = $this->getDOMElementAttributeAs($element, 'longdesc')) !== null) {
                $component->setLongdesc($longdesc);
            }

            if (($height = $this->getDOMElementAttributeAs($element, 'height', 'string')) !== null) {
                if (stripos($height, '%') === false) {
                    $component->setHeight(intval($height));
                } else {
                    $component->setHeight($height);
                }
            }

            if (($width = $this->getDOMElementAttributeAs($element, 'width', 'string')) !== null) {
                if (stripos($width, '%') === false) {
                    $component->setWidth(intval($width));
                } else {
                    $component->setWidth($width);
                }
            }

            if (($xmlBase = self::getXmlBase($element)) !== false) {
                $component->setXmlBase($xmlBase);
            }

            $this->fillBodyElement($component, $element);

            return $component;
        } else {
            $msg = "The 'mandatory' attribute 'src' is missing from element 'img'.";
            throw new UnmarshallingException($msg, $element);
        }
    }
protected function unmarshall(DOMElement $element)
    {
        if (($src = $this->getDOMElementAttributeAs($element, 'src')) !== null) {

            if (($alt = $this->getDOMElementAttributeAs($element, 'alt')) === null) {
                // The XSD does not force the 'alt' attribute to be non-empty,
                // thus we consider the 'alt' attribute value as an empty string ('').
                $alt = '';
            }

            $component = new Img($src, $alt);

            if (($longdesc = $this->getDOMElementAttributeAs($element, 'longdesc')) !== null) {
                $component->setLongdesc($longdesc);
            }

            if (($height = $this->getDOMElementAttributeAs($element, 'height', 'string')) !== null) {
                if (stripos($height, '%') === false) {
                    $component->setHeight(intval($height));
                } else {
                    $component->setHeight($height);
                }
            }

            if (($width = $this->getDOMElementAttributeAs($element, 'width', 'string')) !== null) {
                if (stripos($width, '%') === false) {
                    $component->setWidth(intval($width));
                } else {
                    $component->setWidth($width);
                }
            }

            if (($xmlBase = self::getXmlBase($element)) !== false) {
                $component->setXmlBase($xmlBase);
            }

            $this->fillBodyElement($component, $element);

            return $component;
        } else {
            $msg = "The 'mandatory' attribute 'src' is missing from element 'img'.";
            throw new UnmarshallingException($msg, $element);
        }
    }
protected function unmarshall ( DOMElement $ element ) { if ( ( $ src = $ this -> getDOMElementAttributeAs ( $ element , 'src' ) ) !== null ) { if ( ( $ alt = $ this -> getDOMElementAttributeAs ( $ element , 'alt' ) ) === null ) { // The XSD does not force the 'alt' attribute to be non-empty, // thus we consider the 'alt' attribute value as an empty string (''). $ alt = '' ; } $ component = new Img ( $ src , $ alt ) ; if ( ( $ longdesc = $ this -> getDOMElementAttributeAs ( $ element , 'longdesc' ) ) !== null ) { $ component -> setLongdesc ( $ longdesc ) ; } if ( ( $ height = $ this -> getDOMElementAttributeAs ( $ element , 'height' , 'string' ) ) !== null ) { if ( stripos ( $ height , '%' ) === false ) { $ component -> setHeight ( intval ( $ height ) ) ; } else { $ component -> setHeight ( $ height ) ; } } if ( ( $ width = $ this -> getDOMElementAttributeAs ( $ element , 'width' , 'string' ) ) !== null ) { if ( stripos ( $ width , '%' ) === false ) { $ component -> setWidth ( intval ( $ width ) ) ; } else { $ component -> setWidth ( $ width ) ; } } if ( ( $ xmlBase = self :: getXmlBase ( $ element ) ) !== false ) { $ component -> setXmlBase ( $ xmlBase ) ; } $ this -> fillBodyElement ( $ component , $ element ) ; return $ component ; } else { $ msg = "The 'mandatory' attribute 'src' is missing from element 'img'." ; throw new UnmarshallingException ( $ msg , $ element ) ; } }
Unmarshall a DOMElement object corresponding to an XHTML img element.

@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent n Img object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException
Unmarshall a DOMElement object corresponding to an XHTML img element .