/**
  * Fill $bodyElement with the following bodyElement:
  *
  * * id
  * * class
  * * lang
  * * label
  *
  * @param BodyElement $bodyElement The bodyElement to fill.
  * @param DOMElement $element The DOMElement object from where the attribute values must be retrieved.
  * @throws UnmarshallingException If one of the attributes of $element is not valid.
  */
 protected static function fillBodyElement(BodyElement $bodyElement, DOMElement $element)
 {
     try {
         $bodyElement->setId($element->getAttribute('id'));
         $bodyElement->setClass($element->getAttribute('class'));
         $bodyElement->setLang($element->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang'));
         $bodyElement->setLabel($element->getAttribute('label'));
     } catch (InvalidArgumentException $e) {
         $msg = "An error occured while filling the bodyElement attributes (id, class, lang, label).";
         throw new UnmarshallingException($msg, $element, $e);
     }
 }
Example #2
0
 /**
  * Fill $bodyElement with the following bodyElement attributes:
  *
  * * id
  * * class
  * * lang
  * * label
  * * dir (QTI 2.2)
  *
  * @param BodyElement $bodyElement The bodyElement to fill.
  * @param DOMElement $element The DOMElement object from where the attribute values must be retrieved.
  * @throws UnmarshallingException If one of the attributes of $element is not valid.
  */
 protected function fillBodyElement(BodyElement $bodyElement, DOMElement $element)
 {
     try {
         $bodyElement->setId($element->getAttribute('id'));
         $bodyElement->setClass($element->getAttribute('class'));
         $bodyElement->setLang($element->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang'));
         $bodyElement->setLabel($element->getAttribute('label'));
         $version = $this->getVersion();
         if (Version::compare($version, '2.2.0', '>=') === true && ($dir = self::getDOMElementAttributeAs($element, 'dir')) !== null && in_array($element->localName, self::$dirClasses) === true) {
             $bodyElement->setDir(Direction::getConstantByName($dir));
         }
     } catch (InvalidArgumentException $e) {
         $msg = "An error occured while filling the bodyElement attributes (id, class, lang, label, dir).";
         throw new UnmarshallingException($msg, $element, $e);
     }
 }