Marshall an numberPresented QTI element in its NumberPresented object equivalent.

@param \DOMElement A DOMElement object.
@return \qtism\data\QtiComponent The corresponding NumberPresented object.
975474
protected function unmarshall(DOMElement $element)
    {
        $baseComponent = parent::unmarshall($element);
        $object = new NumberPresented();
        $object->setSectionIdentifier($baseComponent->getSectionIdentifier());
        $object->setIncludeCategories($baseComponent->getIncludeCategories());
        $object->setExcludeCategories($baseComponent->getExcludeCategories());

        return $object;
    }
1291355
protected function toXML(DOMElement $parent) : DOMElement
    {
        $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, $this->elementName);
        $parent->appendChild($e);

        if ($this->ID !== null) {
            $e->setAttribute('ID', $this->ID);
        }

        if ($this->validUntil !== null) {
            $e->setAttribute('validUntil', gmdate('Y-m-d\TH:i:s\Z', $this->validUntil));
        }

        if ($this->cacheDuration !== null) {
            $e->setAttribute('cacheDuration', $this->cacheDuration);
        }

        $e->setAttribute('protocolSupportEnumeration', implode(' ', $this->protocolSupportEnumeration));

        if ($this->errorURL !== null) {
            $e->setAttribute('errorURL', $this->errorURL);
        }

        Extensions::addList($e, $this->Extensions);

        foreach ($this->KeyDescriptor as $kd) {
            $kd->toXML($e);
        }

        if ($this->Organization !== null) {
            $this->Organization->toXML($e);
        }

        foreach ($this->ContactPerson as $cp) {
            $cp->toXML($e);
        }

        return $e;
    }
968971
protected function unmarshall(DOMElement $element)
    {
        $version = $this->getVersion();
        
        if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) {
            $component = new PrintedVariable($identifier);

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

            if (Version::compare($version, '2.1.0', '>=') === true && ($powerForm = $this->getDOMElementAttributeAs($element, 'powerForm', 'boolean')) !== null) {
                $component->setPowerForm($powerForm);
            }

            if (($base = $this->getDOMElementAttributeAs($element, 'base')) !== null) {
                $component->setBase((Format::isInteger($base) === true) ? intval($base) : $base);
            }

            if (($index = $this->getDOMElementAttributeAs($element, 'index')) !== null) {
                $component->setIndex((Format::isInteger($index) === true) ? intval($index) : $base);
            }

            if (Version::compare($version, '2.1.0', '>=') === true && ($delimiter = $this->getDOMElementAttributeAs($element, 'delimiter')) !== null) {
                $component->setDelimiter($delimiter);
            }

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

            if (Version::compare($version, '2.1.0', '>=') === true && ($mappingIndicator = $this->getDOMElementAttributeAs($element, 'mappingIndicator')) !== null) {
                $component->setMappingIndicator($mappingIndicator);
            }

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

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

            return $component;
        } else {
            $msg = "The mandatory 'identifier' attribute is missing from the 'printedVariable' element.";
            throw new UnmarshallingException($msg, $element);
        }
    }
800688
public function toXML(DOMElement $parent = null) : DOMElement
    {
        $element = parent::toXML($parent);

        if ($this->Format !== null) {
            $element->setAttribute('Format', $this->Format);
        }

        if ($this->SPProvidedID !== null) {
            $element->setAttribute('SPProvidedID', $this->SPProvidedID);
        }

        $value = $element->ownerDocument->createTextNode($this->value);
        $element->appendChild($value);

        return $element;
    }
842359
protected function marshall(QtiComponent $component)
    {
        return self::getDOMCradle()->importNode($component->getXml()->documentElement, true);
    }
831572
public function processElement(\DOMElement $element, ContextInterface $context)
    {
        // Create a property
        $propertyContext = $this->processProperty($element, $context);

        // Process the element in case it's an anonymous thing with no children
        if (!$element->childNodes->length) {
            $this->processChild($element, $context);
        }

        return $propertyContext;
    }
600354
public static function fromEncryptedKeyElement(DOMElement $element)
    {
        $objenc = new XMLSecEnc();
        $objenc->setNode($element);
        if (!$objKey = $objenc->locateKey()) {
            throw new Exception("Unable to locate algorithm for this Encrypted Key");
        }
        $objKey->isEncrypted = true;
        $objKey->encryptedCtx = $objenc;
        XMLSecEnc::staticLocateKeyInfo($objKey, $element);
        return $objKey;
    }
1320105
public static function getElementId(\DOMElement $node)
    {
        if ($node->hasAttribute('dqn_tmp_id')) {
            return $node->getAttribute('dqn_tmp_id');
        }

        $node_id = md5(mt_rand());
        $node->setAttribute('dqn_tmp_id', $node_id);
        return $node_id;
    }
391336
protected function unmarshall(DOMElement $element)
    {
        if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) {

            if (($autostart = $this->getDOMElementAttributeAs($element, 'autostart', 'boolean')) !== null) {

                $objectElts = $this->getChildElementsByTagName($element, 'object');
                if (count($objectElts) > 0) {
                    $objectElt = $objectElts[0];
                    $object = $this->getMarshallerFactory()->createMarshaller($objectElt)->unmarshall($objectElt);

                    $component = new MediaInteraction($responseIdentifier, $autostart, $object);

                    $promptElts = $this->getChildElementsByTagName($element, 'prompt');
                    if (count($promptElts) > 0) {
                        $promptElt = $promptElts[0];
                        $prompt = $this->getMarshallerFactory()->createMarshaller($promptElt)->unmarshall($promptElt);
                        $component->setPrompt($prompt);
                    }

                    if (($minPlays = $this->getDOMElementAttributeAs($element, 'minPlays', 'integer')) !== null) {
                        $component->setMinPlays($minPlays);
                    }

                    if (($maxPlays = $this->getDOMElementAttributeAs($element, 'maxPlays', 'integer')) !== null) {
                        $component->setMaxPlays($maxPlays);
                    }

                    if (($loop = $this->getDOMElementAttributeAs($element, 'loop', 'boolean')) !== null) {
                        $component->setLoop($loop);
                    }

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

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

                    return $component;
                } else {
                    $msg = "A 'mediaInteraction' element must contain exactly one 'object' element, none given.";
                    throw new UnmarshallingException($msg, $element);
                }
            } else {
                $msg = "The mandatory 'autostart' attribute is missing from the 'mediaInteraction' element.";
                throw new UnmarshallingException($msg, $element);
            }
        } else {
            $msg = "The mandatory 'responseIdentifier' attribute is missing from the 'mediaInteraction' element.";
            throw new UnmarshallingException($msg, $element);
        }
    }
483858
private function buildObject(DOMElement $data){

        $attributes = $this->extractAttributes($data);
        $returnValue = new QtiObject($attributes);

        if($data->hasChildNodes()){
            $nonEmptyChild = $this->getNonEmptyChildren($data);
            if(count($nonEmptyChild) == 1 && reset($nonEmptyChild)->nodeName == 'object'){
                $alt = $this->buildObject(reset($nonEmptyChild));
                $returnValue->setAlt($alt);
            }else{
                //get the node xml content
                $pattern = array("/^<{$data->nodeName}([^>]*)?>/i", "/<\/{$data->nodeName}([^>]*)?>$/i");
                $content = preg_replace($pattern, '', trim($this->saveXML($data)));
                $returnValue->setAlt($content);
            }
        }else{
            $alt = trim($data->nodeValue);
            if(!empty($alt)){
                $returnValue->setAlt($alt);
            }
        }

        return $returnValue;
    }
263127
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());
        $this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
        
        foreach ($component->getShufflingGroups() as $shufflingGroup) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($shufflingGroup);
            $element->appendChild($marshaller->marshall($shufflingGroup));
        }

        return $element;
    }
446169
protected function unmarshall(DOMElement $element)
    {
        if (($identifiers = $this->getDOMElementAttributeAs($element, 'identifiers')) !== null) {
            $identifiers = explode("\x20", $identifiers);
            $component = new ShufflingGroup(new IdentifierCollection($identifiers));
            
            if (($fixedIdentifiers = $this->getDOMElementAttributeAs($element, 'fixedIdentifiers')) !== null) {
                $fixedIdentifiers = explode("\x20", $fixedIdentifiers);
                $component->setFixedIdentifiers(new IdentifierCollection($fixedIdentifiers));
            }

            return $component;
        } else {
            $msg = "The mandatory attribute 'identifiers' is missing from element '" . $element->localName . "'.";
            throw new UnmarshallingException($msg, $element);
        }
    }
675021
public function toXML(DOMElement $parent) : DOMElement
    {
        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:X509Data');
        $parent->appendChild($e);

        /** @var \SAML2\XML\Chunk|\SAML2\XML\ds\X509Certificate $n */
        foreach ($this->getData() as $n) {
            $n->toXML($e);
        }

        return $e;
    }
1208755
public function toUnsignedXML() : DOMElement
    {
        $root = parent::toUnsignedXML();

        /** @var \SAML2\Assertion|\SAML2\EncryptedAssertion $assertion */
        foreach ($this->assertions as $assertion) {
            $assertion->toXML($root);
        }

        return $root;
    }
63433
protected function unmarshall(DOMElement $element)
    {
        $object = new Ordering();

        if (($value = $this->getDOMElementAttributeAs($element, 'shuffle', 'boolean')) !== null) {
            $object->setShuffle($value);
        }

        return $object;
    }
150236
protected function unmarshall(DOMElement $element)
    {
        $baseComponent = parent::unmarshall($element);
        $identifier = $baseComponent->getIdentifier();
        $href = $baseComponent->getHref();

        $compactAssessmentItemRef = new ExtendedAssessmentItemRef($identifier, $href);
        $compactAssessmentItemRef->setRequired($baseComponent->isRequired());
        $compactAssessmentItemRef->setFixed($baseComponent->isFixed());
        $compactAssessmentItemRef->setPreConditions($baseComponent->getPreConditions());
        $compactAssessmentItemRef->setBranchRules($baseComponent->getBranchRules());
        $compactAssessmentItemRef->setItemSessionControl($baseComponent->getItemSessionControl());
        $compactAssessmentItemRef->setTimeLimits($baseComponent->getTimeLimits());
        $compactAssessmentItemRef->setTemplateDefaults($baseComponent->getTemplateDefaults());
        $compactAssessmentItemRef->setWeights($baseComponent->getWeights());
        $compactAssessmentItemRef->setVariableMappings($baseComponent->getVariableMappings());
        $compactAssessmentItemRef->setCategories($baseComponent->getCategories());

        // ResponseDeclarations.
        $responseDeclarationElts = $this->getChildElementsByTagName($element, 'responseDeclaration');
        $responseDeclarations = new ResponseDeclarationCollection();
        foreach ($responseDeclarationElts as $responseDeclarationElt) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($responseDeclarationElt);
            $responseDeclarations[] = $marshaller->unmarshall($responseDeclarationElt);
        }
        $compactAssessmentItemRef->setResponseDeclarations($responseDeclarations);

        // OutcomeDeclarations.
        $outcomeDeclarationElts = $this->getChildElementsByTagName($element, 'outcomeDeclaration');
        $outcomeDeclarations = new OutcomeDeclarationCollection();
        foreach ($outcomeDeclarationElts as $outcomeDeclarationElt) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($outcomeDeclarationElt);
            $outcomeDeclarations[] = $marshaller->unmarshall($outcomeDeclarationElt);
        }
        $compactAssessmentItemRef->setOutcomeDeclarations($outcomeDeclarations);
        
        // TemplateDeclarations.
        $templateDeclarationElts = $this->getChildElementsByTagName($element, 'templateDeclaration');
        $templateDeclarations = new TemplateDeclarationCollection();
        foreach ($templateDeclarationElts as $templateDeclarationElt) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($templateDeclarationElt);
            $templateDeclarations[] = $marshaller->unmarshall($templateDeclarationElt);
        }
        $compactAssessmentItemRef->setTemplateDeclarations($templateDeclarations);
        
        // TemplateProcessing.
        $templateProcessingElts = $this->getChildElementsByTagName($element, 'templateProcessing');
        if (count($templateProcessingElts) === 1) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($templateProcessingElts[0]);
            $compactAssessmentItemRef->setTemplateProcessing($marshaller->unmarshall($templateProcessingElts[0]));
        }
        
        // ResponseProcessing.
        $responseProcessingElts = $this->getChildElementsByTagName($element, 'responseProcessing');
        if (count($responseProcessingElts) === 1) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($responseProcessingElts[0]);
            $compactAssessmentItemRef->setResponseProcessing($marshaller->unmarshall($responseProcessingElts[0]));
        }
        
        // ModalFeedbacks (transformed in ModalFeedbackRules).
        $modalFeedbackElts = $this->getChildElementsByTagName($element, 'modalFeedbackRule');
        $modalFeedbackRules = new ModalFeedbackRuleCollection();
        foreach ($modalFeedbackElts as $modalFeedbackElt) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($modalFeedbackElt);
            $modalFeedbackRules[] = $marshaller->unmarshall($modalFeedbackElt);
        }
        $compactAssessmentItemRef->setModalFeedbackRules($modalFeedbackRules);
        
        // Shufflings.
        $shufflingElts = $this->getChildElementsByTagName($element, 'shuffling');
        $shufflings = new ShufflingCollection();
        foreach ($shufflingElts as $shufflingElt) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($shufflingElt);
            $shufflings[] = $marshaller->unmarshall($shufflingElt);
        }
        $compactAssessmentItemRef->setShufflings($shufflings);
        
        // ResponseValidityConstraints.
        $responseValidityConstraintElts = $this->getChildElementsByTagName($element, 'responseValidityConstraint');
        $responseValidityConstraints = new ResponseValidityConstraintCollection();
        foreach ($responseValidityConstraintElts as $responseValidityConstraintElt) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($responseValidityConstraintElt);
            $responseValidityConstraints[] = $marshaller->unmarshall($responseValidityConstraintElt);
        }
        $compactAssessmentItemRef->setResponseValidityConstraints($responseValidityConstraints);

        if (($adaptive = $this->getDOMElementAttributeAs($element, 'adaptive', 'boolean')) !== null) {
            $compactAssessmentItemRef->setAdaptive($adaptive);
        }

        if (($timeDependent = $this->getDOMElementAttributeAs($element, 'timeDependent', 'boolean')) !== null) {
            $compactAssessmentItemRef->setTimeDependent($timeDependent);
        } else {
            $msg = "The mandatory attribute 'timeDependent' is missing from element '" . $element->localName . "'.";
            throw new UnmarshallingException($msg, $element);
        }
        
        if (($endAttemptIdentifiers = $this->getDOMElementAttributeAs($element, 'endAttemptIdentifiers')) !== null) {
            $identifiersArray = explode("\x20", $endAttemptIdentifiers);
            if (count($identifiersArray) > 0) {
                $compactAssessmentItemRef->setEndAttemptIdentifiers(new IdentifierCollection($identifiersArray));
            }
        }

        return $compactAssessmentItemRef;
    }
1188306
protected function marshall(QtiComponent $component)
    {
        $version = $this->getVersion();
        $element = $this->createElement($component);
        $this->setDOMElementAttribute($element, 'identifier', $component->getIdentifier());

        if ($component->isFixed() === true) {
            $this->setDOMElementAttribute($element, 'fixed' , true);
        }

        if (Version::compare($version, '2.1.0', '>=') === true && $component->hasTemplateIdentifier() === true) {
            $this->setDOMElementAttribute($element, 'templateIdentifier', $component->getTemplateIdentifier());
        }

        if (Version::compare($version, '2.1.0', '>=') === true && $component->getShowHide() === ShowHide::HIDE) {
            $this->setDOMElementAttribute($element, 'showHide', ShowHide::getNameByConstant(ShowHide::HIDE));
        }

        if (Version::compare($version, '2.1.0', '>=') === true && $component->isRequired() === true) {
            $this->setDOMElementAttribute($element, 'required', true);
        }
        
        if (Version::compare($version, '2.1.0', '<') === true) {
            $matchGroup = $component->getMatchGroup();
            if (count($matchGroup) > 0) {
                $this->setDOMElementAttribute($element, 'matchGroup', implode(' ', $matchGroup->getArrayCopy()));
            }
        }

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

        return $element;
    }