Unmarshall a DOMElement object corresponding to a SliderInteraction element.

@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent A SliderInteraction object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException
8113
protected function unmarshall(DOMElement $element)
    {
        if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) {

            if (($lowerBound = $this->getDOMElementAttributeAs($element, 'lowerBound', 'float')) !== null) {

                if (($upperBound = $this->getDOMElementAttributeAs($element, 'upperBound', 'float')) !== null) {

                    $component = new SliderInteraction($responseIdentifier, $lowerBound, $upperBound);

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

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

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

                    if (($orientation = $this->getDOMElementAttributeAs($element, 'orientation')) !== null) {
                        try {
                            $component->setOrientation(Orientation::getConstantByName($orientation));
                        } catch (InvalidArgumentException $e) {
                            $msg = "The value of the 'orientation' attribute of the 'sliderInteraction' is invalid.";
                            throw new UnmarshallingException($msg, $element, $e);
                        }
                    }

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

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

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

                    return $component;
                } else {
                    $msg = "The mandatory 'upperBound' attribute is missing from the 'sliderInteraction' element.";
                    throw new UnmarshallingException($msg, $element);
                }
            } else {
                $msg = "The mandatory 'lowerBound' attribute is missing from the 'sliderInteraction' element.";
                throw new UnmarshallingException($msg, $element);
            }
        } else {
            $msg = "The mandatory 'responseIdentifier' attribute is missing from the 'sliderInteraction' element.";
            throw new UnmarshallingException($msg, $element);
        }
    }
1093879
public static function fromXml(\DOMElement $xml)
    {
        $static = new static();
        $static->libraryItemMetadata = LibraryItemMetadata::fromXml($xml);
        $static->pickupLocation = PickupLocation::fromXml($xml);

        $requestStartDate = $xml->getElementsByTagName('requestDate');
        $requestEndDate = $xml->getElementsByTagName('endRequestDate');
        $static->requestDateRange = DateTimeRange::fromXml($requestStartDate, $requestEndDate);

        $holdStartDate = $xml->getElementsByTagName('holdDate');
        $holdEndDate = $xml->getElementsByTagName('endHoldDate');
        $static->holdDateRange = DateTimeRange::fromXml($holdStartDate, $holdEndDate);

        $cancelable = $xml->getElementsByTagName('cancelable');
        $static->cancelable = BoolLiteral::fromXml($cancelable);

        $stringLiterals = array(
            'requestNumber' => $xml->getElementsByTagName('requestNumber'),
            'sequence' => $xml->getElementsByTagName('sequence'),
            'queuePosition' => $xml->getElementsByTagName('queuePosition'),
            'itemSequence' => $xml->getElementsByTagName('itemSequence'),
            'status' => $xml->getElementsByTagName('status'),
        );
        foreach ($stringLiterals as $propertyName => $xmlTag) {
            $static->$propertyName = StringLiteral::fromXml($xmlTag);
        }

        return $static;
    }
414151
protected function unmarshall(DOMElement $element)
    {
        $version = $this->getVersion();
        if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) {

            $component = new Gap($identifier);

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

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

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

            if (Version::compare($version, '2.1.0', '>=') === true && ($required = $this->getDOMElementAttributeAs($element, 'required', 'boolean')) !== null) {
                $component->setRequired($required);
            }
            
            if (Version::compare($version, '2.1.0', '<') === true && ($matchGroup = $this->getDOMElementAttributeAs($element, 'matchGroup')) !== null) {
                $component->setMatchGroup(new IdentifierCollection(explode("\x20", $matchGroup)));
            }

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

            return $component;

        } else {
            $msg = "The mandatory 'identifier' attribute is missing from the 'gap' element.";
            throw new UnmarshallingException($msg, $element);
        }
    }
990708
public static function copyElement(DOMElement $element, DOMElement $parent = null) : DOMElement
    {
        if ($parent === null) {
            $document = DOMDocumentFactory::create();
        } else {
            $document = $parent->ownerDocument;
        }

        $namespaces = [];
        for ($e = $element; $e instanceof DOMNode; $e = $e->parentNode) {
            foreach (Utils::xpQuery($e, './namespace::*') as $ns) {
                $prefix = $ns->localName;
                if ($prefix === 'xml' || $prefix === 'xmlns') {
                    continue;
                }
                $uri = $ns->nodeValue;
                if (!isset($namespaces[$prefix])) {
                    $namespaces[$prefix] = $uri;
                }
            }
        }

        /** @var \DOMElement $newElement */
        $newElement = $document->importNode($element, true);
        if ($parent !== null) {
            /* We need to append the child to the parent before we add the namespaces. */
            $parent->appendChild($newElement);
        }

        foreach ($namespaces as $prefix => $uri) {
            $newElement->setAttributeNS($uri, $prefix.':__ns_workaround__', 'tmp');
            $newElement->removeAttributeNS($uri, '__ns_workaround__');
        }

        return $newElement;
    }
1320875
static public function changeElementName(DOMElement $element, $name)
    {
        $newElement = $element->ownerDocument->createElement($name);

        foreach ($element->childNodes as $child) {
            $child = $element->ownerDocument->importNode($child, true);
            $newElement->appendChild($child);
        }

        foreach ($element->attributes as $attrName => $attrNode) {
            if ($attrNode->namespaceURI === null) {
                $newElement->setAttribute($attrName, $attrNode->value);
            } else {
                $newElement->setAttributeNS($attrNode->namespaceURI, $attrNode->prefix . ':' . $attrName, $attrNode->value);
            }

        }

        $newElement->ownerDocument->replaceChild($newElement, $element);

        return $newElement;
    }
494893
public function remove($element)
    {
        if ($this->count() > 0) {
            foreach ($this->elements as $index => $existing) {
                if ($element === $existing) {
                    unset($this->elements[$index]);

                    break;
                }
            }
        }

        return $this;
    }
1071571
private function getFieldElement($element)
    {
        $element = $this->getElement($element);
        while (null !== $element && !$element->hasClass('field')) {
            $element = $element->getParent();
        }

        return $element;
    }
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;
    }
1098320
public function setDOM(DOMElement $element)
    {
        $this->_element = $this->_element->ownerDocument->importNode($element, true);
    }
1264271
protected function unmarshall(DOMElement $element)
    {
        $areaMapEntries = new AreaMapEntryCollection();
        $areaMapEntryElts = $this->getChildElementsByTagName($element, 'areaMapEntry');

        foreach ($areaMapEntryElts as $areaMapEntryElt) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($areaMapEntryElt);
            $areaMapEntries[] = $marshaller->unmarshall($areaMapEntryElt);
        }

        $object = new AreaMapping($areaMapEntries);

        if (($defaultValue = $this->getDOMElementAttributeAs($element, 'defaultValue', 'float')) !== null) {
            $object->setDefaultValue($defaultValue);
        }

        if (($lowerBound = $this->getDOMElementAttributeAs($element, 'lowerBound', 'float')) !== null) {
            $object->setLowerBound($lowerBound);
        }

        if (($upperBound = $this->getDOMElementAttributeAs($element, 'upperBound', 'float')) !== null) {
            $object->setUpperBound($upperBound);
        }

        return $object;
    }
346204
protected function cleanHrefs(\DOMElement $element)
    {
        $href = $element->getAttribute('href');
        if (preg_match(self::SCRIPT_REGEX, $href) === 1) {
            $element->removeAttribute('href');
            $this->xmlIssues[] = array(
                'message' => 'Suspicious attribute \'href\'',
                'line' => $element->getLineNo(),
            );
        }
    }
957191
public function toUnsignedXML() : DOMElement
    {
        $root = parent::toUnsignedXML();
        $artifactelement = $this->document->createElementNS(Constants::NS_SAMLP, 'Artifact', $this->artifact);
        $root->appendChild($artifactelement);

        return $root;
    }
1211108
public function setData($element)
	{
		$rules = $this->processRules($element);

		$this->ruleProvider->setData($rules);

		return $this;
	}
607319
public function setDOMElementPayload(DOMElement $element)
    {
        $this->setPayload($element->ownerDocument->saveXML($element));

        return $this;
    }
539073
public function unmarshall(DOMElement $element)
    {
        if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) {
            
            if (($minConstraint = $this->getDOMElementAttributeAs($element, 'minConstraint', 'integer')) !== null) {
                
                if (($maxConstraint = $this->getDOMElementAttributeAs($element, 'maxConstraint', 'integer')) !== null) {
                    
                    if (($patternMask = $this->getDOMElementAttributeAs($element, 'patternMask')) === null) {
                        $patternMask = '';
                    }
                    try {
                        $component = new ResponseValidityConstraint($responseIdentifier, $minConstraint, $maxConstraint, $patternMask);
                    
                        // Find child associationValidityConstraint elements if any.
                        $associationValidityConstraintElts = $this->getChildElementsByTagName($element, 'associationValidityConstraint');
                            
                        foreach ($associationValidityConstraintElts as $associationValidityConstraintElt) {
                            $marshaller = $this->getMarshallerFactory()->createMarshaller($associationValidityConstraintElt);
                            $component->addAssociationValidityConstraint($marshaller->unmarshall($associationValidityConstraintElt));
                        }
                        
                        return $component;
                    } catch (InvalidArgumentException $e) {
                        throw new UnmarshallingException(
                            "An error occured while unmarshalling a 'responseValidityConstraint'. See chained exceptions for more information.",
                            $element,
                            $e
                        );
                    }
                    
                } else {
                    throw new UnmarshallingException(
                        "The mandatory 'maxConstraint' attribute is missing from element 'responseValididtyConstraint'.",
                        $element
                    );
                }
            } else {
                throw new UnmarshallingException(
                    "The mandatory 'minConstraint' attribute is missing from element 'responseValididtyConstraint'.",
                    $element
                );
            }
        } else {
            throw new UnmarshallingException(
                "The mandatory 'responseIdentifier' attribute is missing from element 'responseValididtyConstraint'.",
                $element
            );
        }
    }
183512
public function retriveAttributeVisibility(\DOMElement $element)
    {
        $name = $this->engine->query($element->getNodePath() . '/dia:attribute[@name="visibility"]/dia:enum');
        $propertyVisibility = $name->item(0)->attributes->getNamedItem('val')->nodeValue;

        return self::$propertyVisibilityTypes[$propertyVisibility];
    }
35942
protected function elementHasSafeUrl(DOMElement $element)
	{
		return $element->firstChild instanceof DOMText && $this->isSafeUrl($element->firstChild->textContent);
	}