/** * Unmarshall a DOMElement object corresponding to a QTI templateDeclaration element. * * @param \DOMElement $element A DOMElement object. * @return \qtism\data\QtiComponent A TemplateDeclaration object. * @throws \qtism\data\storage\xml\marshalling\UnmarshallingException */ protected function unmarshall(DOMElement $element) { try { $baseComponent = parent::unmarshall($element); $object = new TemplateDeclaration($baseComponent->getIdentifier()); $object->setBaseType($baseComponent->getBaseType()); $object->setCardinality($baseComponent->getCardinality()); $object->setDefaultValue($baseComponent->getDefaultValue()); $version = $this->getVersion(); if (($paramVariable = self::getDOMElementAttributeAs($element, 'paramVariable', 'boolean')) !== null) { $object->setParamVariable($paramVariable); } elseif (Version::compare($version, '2.0.0', '==') === true) { $msg = "The mandatory attribute 'paramVariable' is missing from element '" . $element->localName . "'."; throw new UnmarshallingException($msg, $element); } if (($mathVariable = self::getDOMElementAttributeAs($element, 'mathVariable', 'boolean')) !== null) { $object->setMathVariable($mathVariable); } elseif (Version::compare($version, '2.0.0', '==') === true) { $msg = "The mandatory attribute 'mathVariable' is missing from element '" . $element->localName . "'."; throw new UnmarshallingException($msg, $element); } return $object; } catch (InvalidArgumentException $e) { $msg = "An unexpected error occured while unmarshalling the templateDeclaration."; throw new UnmarshallingException($msg, $element, $e); } }
/** * Unmarshall a DOMElement object corresponding to a QTI templateDeclaration element. * * @param DOMElement $element A DOMElement object. * @return QtiComponent A TemplateDeclaration object. * @throws UnmarshallingException */ protected function unmarshall(DOMElement $element) { try { $baseComponent = parent::unmarshall($element); $object = new TemplateDeclaration($baseComponent->getIdentifier()); $object->setBaseType($baseComponent->getBaseType()); $object->setCardinality($baseComponent->getCardinality()); $object->setDefaultValue($baseComponent->getDefaultValue()); if (($paramVariable = self::getDOMElementAttributeAs($element, 'paramVariable', 'boolean')) !== null) { $object->setParamVariable($paramVariable); } if (($mathVariable = self::getDOMElementAttributeAs($element, 'mathVariable', 'boolean')) !== null) { $object->setMathVariable($mathVariable); } return $object; } catch (InvalidArgumentException $e) { $msg = "An unexpected error occured while unmarshalling the templateDeclaration."; throw new UnmarshallingException($msg, $element, $e); } }