protected function marshall(QtiComponent $component)
    {
        // Reset.
        $this->resetTrail();
        $this->resetFinal();
        $this->resetMark();
        $this->resetProcessed();

        $this->pushTrail($component);

        while ($this->countTrail() > 0) {

            $node = $this->popTrail();

            if (!$node instanceof DOMElement && !$this->isMarked($node) && !$this->isComponentFinal($node)) {
                // Hierarchical node, 1st pass.
                $this->mark($node);
                $this->pushTrail($node); // repush for a further pass.
                $children = array_reverse($this->getChildrenComponents($node)); // next nodes to explore.

                foreach ($children as $c) {
                    $this->pushTrail($c);
                }
            } elseif ($this->isMarked($node)) {
                // Push the result on the trail.
                $finals = $this->emptyFinal(count($this->getChildrenComponents($node)));
                $marshaller = $this->getMarshallerFactory()->createMarshaller($node);
                $element = $marshaller->marshallChildrenKnown($node, $finals);
                $this->pushProcessed($element);

                if ($node === $component) {
                    // This is our second pass on the root element, the process is finished.
                    return $element;
                } else {
                    $this->pushTrail($element);
                }
            } else {
                // It's a leaf!
                if ($node instanceof DOMElement) {
                    $this->pushFinal($node);
                } else {
                    $marshaller = $this->getMarshallerFactory()->createMarshaller($node);
                    $processed = $marshaller->marshall($node);
                    $this->pushFinal($processed);
                    $this->pushProcessed($processed);
                }
            }
        }
    }
protected function marshall(QtiComponent $component)
    {
        // Reset.
        $this->resetTrail();
        $this->resetFinal();
        $this->resetMark();
        $this->resetProcessed();

        $this->pushTrail($component);

        while ($this->countTrail() > 0) {

            $node = $this->popTrail();

            if (!$node instanceof DOMElement && !$this->isMarked($node) && !$this->isComponentFinal($node)) {
                // Hierarchical node, 1st pass.
                $this->mark($node);
                $this->pushTrail($node); // repush for a further pass.
                $children = array_reverse($this->getChildrenComponents($node)); // next nodes to explore.

                foreach ($children as $c) {
                    $this->pushTrail($c);
                }
            } elseif ($this->isMarked($node)) {
                // Push the result on the trail.
                $finals = $this->emptyFinal(count($this->getChildrenComponents($node)));
                $marshaller = $this->getMarshallerFactory()->createMarshaller($node);
                $element = $marshaller->marshallChildrenKnown($node, $finals);
                $this->pushProcessed($element);

                if ($node === $component) {
                    // This is our second pass on the root element, the process is finished.
                    return $element;
                } else {
                    $this->pushTrail($element);
                }
            } else {
                // It's a leaf!
                if ($node instanceof DOMElement) {
                    $this->pushFinal($node);
                } else {
                    $marshaller = $this->getMarshallerFactory()->createMarshaller($node);
                    $processed = $marshaller->marshall($node);
                    $this->pushFinal($processed);
                    $this->pushProcessed($processed);
                }
            }
        }
    }
protected function marshall ( QtiComponent $ component ) { // Reset. $ this -> resetTrail ( ) ; $ this -> resetFinal ( ) ; $ this -> resetMark ( ) ; $ this -> resetProcessed ( ) ; $ this -> pushTrail ( $ component ) ; while ( $ this -> countTrail ( ) > 0 ) { $ node = $ this -> popTrail ( ) ; if ( ! $ node instanceof DOMElement && ! $ this -> isMarked ( $ node ) && ! $ this -> isComponentFinal ( $ node ) ) { // Hierarchical node, 1st pass. $ this -> mark ( $ node ) ; $ this -> pushTrail ( $ node ) ; // repush for a further pass. $ children = array_reverse ( $ this -> getChildrenComponents ( $ node ) ) ; // next nodes to explore. foreach ( $ children as $ c ) { $ this -> pushTrail ( $ c ) ; } } elseif ( $ this -> isMarked ( $ node ) ) { // Push the result on the trail. $ finals = $ this -> emptyFinal ( count ( $ this -> getChildrenComponents ( $ node ) ) ) ; $ marshaller = $ this -> getMarshallerFactory ( ) -> createMarshaller ( $ node ) ; $ element = $ marshaller -> marshallChildrenKnown ( $ node , $ finals ) ; $ this -> pushProcessed ( $ element ) ; if ( $ node === $ component ) { // This is our second pass on the root element, the process is finished. return $ element ; } else { $ this -> pushTrail ( $ element ) ; } } else { // It's a leaf! if ( $ node instanceof DOMElement ) { $ this -> pushFinal ( $ node ) ; } else { $ marshaller = $ this -> getMarshallerFactory ( ) -> createMarshaller ( $ node ) ; $ processed = $ marshaller -> marshall ( $ node ) ; $ this -> pushFinal ( $ processed ) ; $ this -> pushProcessed ( $ processed ) ; } } } }
Marshall a QtiComponent that might contain instances of the same class as itself.

@param \qtism\data\QtiComponent $component The QtiComponent object to marshall.
@return \DOMElement A DOMElement corresponding to the QtiComponent to marshall.
@throws \qtism\data\storage\xml\marshalling\MarshallingException If an error occurs during the marshalling process.
Marshall a QtiComponent that might contain instances of the same class as itself .