Render the XML element

@param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered
@return \DOMElement
506624
public function render(\DOMDocument $domDocument)
    {
        $frame = new Frame();
        $frame->setAlign($this->hAlign, $this->vAlign);
        $frame->setPosition($this->posX, $this->posy);
        $frame->addClasses($this->frameClasses);
        $frame->setSize($this->getWidth(), $this->getHeight()+4);
        
        $startY = $this->startY;

        foreach ($this->elements as $idx => $element) {
            $element->setY($startY);
            $startY -= $element->getHeight() + $this->margin;
            $frame->addChild($element);
        }

        return $frame->render($domDocument);
    }
1289669
public function writeXml(DOMDocument $dom = null)
    {
        if (null === $dom) {
            $imp = new DOMImplementation();
            $dtd  = $imp->createDocumentType(
                static::DOCUMENT_TYPE_QUALIFIED_NAME,
                static::DOCUMENT_TYPE_PUBLIC_ID,
                static::DOCUMENT_TYPE_SYSTEM_ID
            );
            $dom = $imp->createDocument('', '', $dtd);
            $dom->encoding = 'UTF-8';
            $dom->xmlVersion = '1.0';
            $dom->formatOutput = true;
        }

        $descriptor = $dom->createElement('workflow');

        $metaAttributes = $this->getMetaAttributes();
        $metaElementBase = $dom->createElement('meta');
        foreach ($metaAttributes as $metaAttributeName => $metaAttributeValue) {
            $metaAttributeNameEncode = XmlUtil::encode($metaAttributeName);
            $metaAttributeValueEnEncode = XmlUtil::encode($metaAttributeValue);

            $metaElement = clone $metaElementBase;
            $metaElement->setAttribute('name', $metaAttributeNameEncode);
            $metaValueElement = $dom->createTextNode($metaAttributeValueEnEncode);
            $metaElement->appendChild($metaValueElement);

            $descriptor->appendChild($metaElement);
        }

        $registers = $this->getRegisters();
        if ($registers->count() > 0) {
            $registersElement = $dom->createElement('registers');
            foreach ($registers as $register) {
                $registerElement = $register->writeXml($dom);
                $registersElement->appendChild($registerElement);
            }

            $descriptor->appendChild($registersElement);
        }


        $timerFunctions = $this->getTriggerFunctions();
        if (count($timerFunctions) > 0) {
            $timerFunctionsElement = $dom->createElement('trigger-functions');
            $timerFunctionElementBase = $dom->createElement('trigger-function');
            foreach ($timerFunctions as $timerFunctionId => $timerFunction) {
                $timerFunctionElement = clone $timerFunctionElementBase;
                $timerFunctionElement->setAttribute('id', $timerFunctionId);

                $functionElement = $timerFunction->writeXml($dom);

                $timerFunctionElement->appendChild($functionElement);

                $timerFunctionsElement->appendChild($timerFunctionElement);
            }
            $descriptor->appendChild($timerFunctionsElement);
        }


        $globalConditions = $this->getGlobalConditions();
        if (null !== $globalConditions) {
            $globalConditionsElement = $dom->createElement('global-conditions');
            $globalConditionElement = $globalConditions->writeXml($dom);
            $globalConditionsElement->appendChild($globalConditionElement);
            $descriptor->appendChild($globalConditionsElement);
        }


        $initialActionsElement = $dom->createElement('initial-actions');
        $initialActions = $this->getInitialActions();
        foreach ($initialActions as $initialAction) {
            $initialActionElement = $initialAction->writeXml($dom);
            $initialActionsElement->appendChild($initialActionElement);
        }
        $descriptor->appendChild($initialActionsElement);


        $globalActions = $this->getGlobalActions();
        if ($globalActions->count() > 0) {
            $globalActionsElement = $dom->createElement('global-actions');
            foreach ($globalActions as $globalAction) {
                $globalActionElement = $globalAction->writeXml($dom);

                $globalActionsElement->appendChild($globalActionElement);
            }

            $descriptor->appendChild($globalActionsElement);
        }

        $commonActions = $this->getCommonActions();
        if (count($commonActions) > 0) {
            $commonActionsElement = $dom->createElement('common-actions');
            foreach ($commonActions as $commonAction) {
                $commonActionElement = $commonAction->writeXml($dom);
                $commonActionsElement->appendChild($commonActionElement);
            }

            $descriptor->appendChild($commonActionsElement);
        }


        $stepsElement = $dom->createElement('steps');
        $steps = $this->getSteps();
        foreach ($steps as $step) {
            $stepElement = $step->writeXml($dom);
            $stepsElement->appendChild($stepElement);
        }

        $descriptor->appendChild($stepsElement);

        $splits = $this->getSplits();
        if ($splits->count() > 0) {
            $splitsElement = $dom->createElement('splits');
            foreach ($splits as $split) {
                $splitElement = $split->writeXml($dom);
                $splitsElement->appendChild($splitElement);
            }

            $descriptor->appendChild($splitsElement);
        }

        $joins = $this->getJoins();
        if ($joins->count() > 0) {
            $joinsElement = $dom->createElement('joins');
            foreach ($joins as $join) {
                $joinElement = $join->writeXml($dom);
                $joinsElement->appendChild($joinElement);
            }

            $descriptor->appendChild($joinsElement);
        }

        $dom->appendChild($descriptor);
        return $dom;
    }
178493
public function toXhtml(\DOMDocument $document, \DOMElement $root)
    {
        $content = '';

        /** @var \ezcDocumentRstToken $token */
        foreach ($this->node->tokens as $token) {
            $content .= $token->content;
        }

        $content = rtrim($content, "\n");

        $pre = $document->createElement('pre');
        $root->appendChild($pre);
        $code = $document->createElement('code', $content);
        $pre->appendChild($code);
    }
155408
public function convert(DOMDocument $xmlDoc)
    {
        $xpath = new DOMXPath($xmlDoc);

        $elements = $xpath->query('//link|//embed|//embed-inline');

        /** @var \DOMElement $element */
        foreach ($elements as $element) {
            $location = null;

            if ($this->elementHasAttribute($element, 'object_id')) {
                try {
                    $contentInfo = $this->contentService->loadContentInfo(
                        $this->getElementAttribute($element, 'object_id')
                    );
                    $location = $this->locationService->loadLocation($contentInfo->mainLocationId);
                } catch (APINotFoundException $e) {
                    if ($this->logger) {
                        $this->logger->warning(
                            'While generating links for xmltext, could not locate ' .
                            'Content object with ID ' . $this->getElementAttribute($element, 'object_id')
                        );
                    }
                } catch (APIUnauthorizedException $e) {
                    if ($this->logger) {
                        $this->logger->notice(
                            'While generating links for xmltext, unauthorized to load ' .
                            'Content object with ID ' . $this->getElementAttribute($element, 'object_id')
                        );
                    }
                }
            }

            if ($this->elementHasAttribute($element, 'node_id')) {
                try {
                    $location = $this->locationService->loadLocation(
                        $this->getElementAttribute($element, 'node_id')
                    );
                } catch (APINotFoundException $e) {
                    if ($this->logger) {
                        $this->logger->warning(
                            'While generating links for xmltext, could not locate ' .
                            'Location with ID ' . $this->getElementAttribute($element, 'node_id')
                        );
                    }
                } catch (APIUnauthorizedException $e) {
                    if ($this->logger) {
                        $this->logger->notice(
                            'While generating links for xmltext, unauthorized to load ' .
                            'Location with ID ' . $this->getElementAttribute($element, 'node_id')
                        );
                    }
                }
            }

            if ($location !== null) {
                $element->setAttribute('url', $this->urlAliasRouter->generate($location));
            }

            // Copy temporary URL if it exists and is not set at this point
            if (!$element->hasAttribute('url') && $element->hasAttribute(EmbedLinking::TEMP_PREFIX . 'url')) {
                $element->setAttribute('url', $element->getAttribute(EmbedLinking::TEMP_PREFIX . 'url'));
            }

            if ($this->elementHasAttribute($element, 'anchor_name')) {
                $anchor = '#' . $this->getElementAttribute($element, 'anchor_name');
                if (strpos($element->getAttribute('url'), $anchor) === false) {
                    $element->setAttribute(
                        'url',
                        $element->getAttribute('url') . '#' .
                        $this->getElementAttribute($element, 'anchor_name')
                    );
                }
            }
        }
    }
1315618
public function process(\DOMDocument $xml)
    {
        $xpath = new \DOMXPath($xml);
        $nodes = $xpath->query('//tag[@name=\'covers\']');

        /** @var \DOMElement $node */
        foreach ($nodes as $node) {
            $refers = $node->getAttribute('refers');
            $refers_array = explode('::', $refers);

            // determine the type so we know where to put the @coveredby tag on
            $type = 'class';
            if (isset($refers_array[1])) {
                // starts with $ = property, ends with () = method,
                // otherwise constant
                $type = $refers_array[1][0] == '$' ? 'property' : 'constant';
                $type = substr($refers_array[1], -2) == '()' ? 'method' : $type;
            }

            switch ($type) {
                case 'class':
                    // escape single quotes in the class name
                    $xpath_refers = 'concat(\''.str_replace(
                        array("'", '"'),
                        array('\', "\'", \'', '\', \'"\' , \''),
                        $refers
                    ) . "', '')";

                    $qry = '/project/file/class[full_name=' . $xpath_refers . ']';
                    break;
                default:
                    $class_name = $refers_array[0];

                    // escape single quotes in the class name
                    $xpath_class_name = 'concat(\''.str_replace(
                        array("'", '"'),
                        array('\', "\'", \'', '\', \'"\' , \''),
                        $class_name
                    ) . "', '')";

                    // escape single quotes in the method name
                    $xpath_method_name = 'concat(\''.str_replace(
                        array("'", '"'),
                        array('\', "\'", \'', '\', \'"\' , \''),
                        rtrim($refers_array[1], '()')
                    ) . "', '')";

                    $qry = '/project/file/class[full_name=' . $xpath_class_name
                        . ']/'.$type.'[name=' . $xpath_method_name .']';
                    break;
            }

            /** @noinspection PhpUsageOfSilenceOperatorInspection as there is no pre-validation possible */
            $referral_nodes = @$xpath->query($qry);

            // if the query is wrong; output a Critical error and continue to
            // the next @covers
            if ($referral_nodes === false) {
                // $this->log(
                //    'An XPath error occurs while processing @covers, the query used was: ' . $qry,
                //    LogLevel::CRITICAL
                // );
                continue;
            }

            // check if the result is unique; if not we error and continue
            // to the next @covers
            if ($referral_nodes->length > 1) {
                continue;
            }

            // if there is one matching element; link them together
            if ($referral_nodes->length > 0) {
                /** @var \DOMElement $referral  */
                $referral = $referral_nodes->item(0);
                $docblock = $referral->getElementsByTagName('docblock');
                if ($docblock->length < 1) {
                    $docblock = new \DOMElement('docblock');
                    $referral->appendChild($docblock);
                } else {
                    $docblock = $docblock->item(0);
                }

                $used_by = new \DOMElement('tag');
                $docblock->appendChild($used_by);
                $used_by->setAttribute('name', 'used_by');
                $used_by->setAttribute('line', '');

                // gather the name of the referring element and set that as refers
                // attribute
                if ($node->parentNode->parentNode->nodeName == 'class') {
                    // if the element where the @covers is in is a class; nothing
                    // more than the class name need to returned
                    $referral_name = $node->parentNode->parentNode
                        ->getElementsByTagName('full_name')->item(0)->nodeValue;
                } else {

                    $referral_class_name = null;
                    if ($node->parentNode->parentNode->nodeName == 'method') {
                        // gather the name of the class where the @covers is in
                        $referral_class_name = $node->parentNode->parentNode
                            ->parentNode->getElementsByTagName('full_name')->item(0)
                            ->nodeValue;
                    }

                    // gather the name of the subelement of the class where
                    // the @covers is in
                    $referral_name = $node->parentNode->parentNode
                        ->getElementsByTagName('name')->item(0)->nodeValue;

                    // if it is a method; suffix with ()
                    if ($node->parentNode->parentNode->nodeName == 'method'
                        || $node->parentNode->parentNode->nodeName == 'function'
                    ) {
                        $referral_name .= '()';
                    }

                    // only prefix class name if this is a class member
                    if ($referral_class_name) {
                        $referral_name = $referral_class_name . '::'
                            . $referral_name;
                    }
                }

                $used_by->setAttribute('description', $referral_name);
                $used_by->setAttribute('refers', $referral_name);
            }
        }

        return $xml;
    }
557416
public function toXML(DOMElement $parent) : DOMElement
    {
        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(EntityAttributes::NS, 'mdattr:EntityAttributes');
        $parent->appendChild($e);

        /** @var \SAML2\XML\saml\Attribute|\SAML2\XML\Chunk $child */
        foreach ($this->children as $child) {
            $child->toXML($e);
        }

        return $e;
    }
263415
public function toXML( DOMDocument $dom )
    {
        if ( !$this->XMLStorable )
        {
            return false;
        }

        $itemNode = $dom->createElement( 'item' );

        foreach ( $this->attributes as $attrName => $attrValue )
        {
            switch ( $attrName )
            {
                case 'id':
                    $itemNode->setAttribute( 'id', $attrValue );
                    break;

                case 'action':
                    $itemNode->setAttribute( 'action', $attrValue );
                    break;

                default:
                    $node = $dom->createElement( $attrName );
                    $nodeValue = $dom->createTextNode( $attrValue );
                    $node->appendChild( $nodeValue );
                    $itemNode->appendChild( $node );
                    break;
            }
        }

        return $itemNode;
    }
1343682
public function render(\DOMDocument $domDocument)
    {
        $domElement = $domDocument->createElement("mood");
        if ($this->lightAmbientColor) {
            $domElement->setAttribute("LAmbient_LinearRgb", $this->lightAmbientColor);
        }
        if ($this->cloudsMinimumColor) {
            $domElement->setAttribute("CloudsRgbMinLinear", $this->cloudsMinimumColor);
        }
        if ($this->cloudsMaximumColor) {
            $domElement->setAttribute("CloudsRgbMaxLinear", $this->cloudsMaximumColor);
        }
        if ($this->light0Color) {
            $domElement->setAttribute("LDir0_LinearRgb", $this->light0Color);
        }
        if ($this->light0Intensity != 1.) {
            $domElement->setAttribute("LDir0_Intens", $this->light0Intensity);
        }
        if ($this->light0PhiAngle) {
            $domElement->setAttribute("LDir0_DirPhi", $this->light0PhiAngle);
        }
        if ($this->light0ThetaAngle) {
            $domElement->setAttribute("LDir0_DirTheta", $this->light0ThetaAngle);
        }
        if ($this->lightBallColor) {
            $domElement->setAttribute("LBall_LinearRgb", $this->lightBallColor);
        }
        if ($this->lightBallIntensity != 1.) {
            $domElement->setAttribute("LBall_Intens", $this->lightBallIntensity);
        }
        if ($this->lightBallRadius) {
            $domElement->setAttribute("LBall_Radius", $this->lightBallRadius);
        }
        if ($this->fogColor) {
            $domElement->setAttribute("FogColorSrgb", $this->fogColor);
        }
        if ($this->selfIlluminationColor) {
            $domElement->setAttribute("SelfIllumColor", $this->selfIlluminationColor);
        }
        if ($this->skyGradientScale != 1.) {
            $domElement->setAttribute("SkyGradientV_Scale", $this->skyGradientScale);
        }
        if ($this->skyGradientKeys) {
            $skyGradientElement = $domDocument->createElement("skygradient");
            $domElement->appendChild($skyGradientElement);
            foreach ($this->skyGradientKeys as $skyGradientKey) {
                $skyGradientKeyElement = $skyGradientKey->render($domDocument);
                $skyGradientElement->appendChild($skyGradientKeyElement);
            }
        }
        return $domElement;
    }
916454
public function convertDOM($domElement) {

        $value = "";

        // Deal with straightforward primitives first.  These occur when a text node is passed
        if ($domElement instanceof \DOMText || $domElement instanceof \DOMAttr) {

            // Get the value
            $value = utf8_decode($domElement->nodeValue);

            // Handle booleans as special case
            if (strtolower($value) == "true") {
                $value = true;
            } elseif (strtolower($value) == "false") {
                $value = false;
            }

        } // Now deal with the inherently more complex element cases
        else if ($domElement instanceof \DOMElement) {

            // Get the name
            $elementName = $domElement->nodeName;

            // Handle the Array case next
            if (strtolower($elementName) == "array" || (isset($this->tagClassMap[$elementName]) && strtolower($this->tagClassMap [$elementName]) == "array")) {

                $value = array();

                // Loop through each child.  If we encounter "Value" elements we find the first child of the value item and pass this off for
                // recursive processing, otherwise we pass the child node off for processing and add the result to the array to return
                $arrayElements = $domElement->childNodes;
                for ($i = 0; $i < $arrayElements->length; $i++) {
                    $arrayElement = $arrayElements->item($i);

                    if ($arrayElement instanceof \DOMElement) {

                        $key = $arrayElement->getAttribute("key");

                        // Convert the value into an object
                        $convertedValue = $this->convertDOM($arrayElement);

                        // Now set the array value either with a key or not depending on whether a key attribute is set.
                        if (isset ($key) && $key) {
                            $value [$key] = $convertedValue;
                        } else {
                            $value [] = $convertedValue;
                        }
                    }
                }

            } // Handle the case where a value node is passed.  This only occurs in the case where a lazy array is defined
            // With a single entry.  Here we simply evaluate and pass back the child entity
            else if (strtolower($elementName) == "value") {

                $valueElements = $domElement->childNodes;

                // Check for the count of child nodes to see whether we need to implicitly create an array wrapper
                if ($valueElements->length == 0) {
                    $value = "";
                } else if ($valueElements->length == 1) {
                    $value = $this->convertDOM($valueElements->item(0));
                } else {
                    $value = array();
                    for ($j = 0; $j < $valueElements->length; $j++) {
                        $currentItem = $valueElements->item($j);
                        if (!($currentItem instanceof \DOMText) && !($currentItem instanceof \DOMComment)) {
                            $key = $currentItem->getAttribute("key");
                            if (isset ($key) && $key) {
                                $value [$key] = $this->convertDOM($currentItem);
                            } else {
                                $value [] = $this->convertDOM($currentItem);
                            }
                        }
                    }
                    // If the result was only in fact a single item, reduce the array to a single value again.
                    if (sizeof($value) == 1) {
                        $value = $value [0];
                    }
                }

            } // Otherwise we must be in the object case
            else {

                // Array of property sets which pertain to set or get methods.  These
                // ensure that we write non accessor members first and prevent
                // ordering problems when we provide custom functionality to write to
                // properties in other get / set methods.
                $deferredPropertySets = array();

                // If a mapping has been defined for this element, use the mapping
                if (isset ($this->tagClassMap [$elementName])) {
                    $elementName = $this->tagClassMap [$elementName];
                }

                // Create the class

                if (strtolower($elementName) == "value") {
                    $value = $this->convertDOM($domElement->childNodes->item(0));
                } else {
                    $value = $this->loadObject($domElement, $elementName);
                }
            }

        }

        return $value;

    }
826414
public function convert(DOMDocument $document)
    {
        $xpath = new DOMXPath($document);
        $xpath->registerNamespace('docbook', 'http://docbook.org/ns/docbook');
        $xpathExpression = '//docbook:eztemplate | //docbook:eztemplateinline';

        $templates = $xpath->query($xpathExpression);
        /** @var \DOMElement[] $templatesSorted */
        $templatesSorted = array();
        $maxDepth = 0;

        foreach ($templates as $template) {
            $depth = $this->getNodeDepth($template);
            if ($depth > $maxDepth) {
                $maxDepth = $depth;
            }
            $templatesSorted[$depth][] = $template;
        }

        ksort($templatesSorted, SORT_NUMERIC);

        foreach ($templatesSorted as $templates) {
            foreach ($templates as $template) {
                $this->processTemplate($document, $template);
            }
        }

        return $document;
    }
493545
public function render(\DOMDocument $domDocument)
    {
        $scriptXml  = $domDocument->createElement("script");
        $scriptText = $this->__toString();

        $scriptComment = $domDocument->createComment($scriptText);
        $scriptXml->appendChild($scriptComment);

        return $scriptXml;
    }
342915
public function toXML(DOMElement $parent) : DOMElement
    {
        Assert::same($this->getElement()->namespaceURI, Constants::NS_SAML);
        Assert::same($this->getElement()->localName, "AttributeValue");

        return Utils::copyElement($this->element, $parent);
    }
1312591
public function getXML(\DOMDocument $document)
    {
        $xml = $document->createElement('ns2:DataStorageItem');

        $ccData = $this->creditCardData->getXML($document);
        $dataId = $document->createElement('ns2:HostedDataID');
        $dataId->textContent = $this->hostedDataId;

        if ($this->function != null) {
            $function = $document->createElement('ns2:Function');
            $function->textContent = $this->function;
            $xml->appendChild($function);
        }
        if ($this->declineHostedDataDuplicates != null) {
            $declineDuplicates = $document->createElement('ns2:DeclineHostedDataDuplicates');
            $declineDuplicates->textContent = $this->declineHostedDataDuplicates;
            $xml->appendChild($declineDuplicates);
        }

        $xml->appendChild($ccData);
        $xml->appendChild($dataId);

        return $xml;
    }
1373092
public function format(\DOMDocument $document) : \DOMDocument
    {
        $rss = $document->createElement(static::ROOT_NODE_TAGNAME);
        $rss->setAttribute('version', static::VERSION);
        $channel = $document->createElement(static::CHANNEL_NODE_TAGNAME);
        $rss->appendChild($channel);
        $document->appendChild($rss);

        return $document;
    }
622549
protected function processTemplate(DOMDocument $document, DOMElement $template)
    {
        $content = null;
        $templateName = $template->getAttribute('name');
        $templateType = $template->hasAttribute('type') ? $template->getAttribute('type') : 'tag';
        $parameters = array(
            'name' => $templateName,
            'params' => $this->extractConfiguration($template),
        );

        if ($template->getElementsByTagName('ezcontent')->length > 0) {
            $contentNode = $template->getElementsByTagName('ezcontent')->item(0);
            switch ($templateType) {
                case 'style':
                    $parameters['content'] = $this->getCustomStyleContent($contentNode);
                    break;
                case 'tag':
                default:
                    $parameters['content'] = $this->getCustomTagContent($contentNode);
                    break;
            }
        }

        if ($template->hasAttribute('ezxhtml:align')) {
            $parameters['align'] = $template->getAttribute('ezxhtml:align');
        }

        $content = $this->renderer->renderTemplate(
            $templateName,
            $templateType,
            $parameters,
            $template->localName === 'eztemplateinline'
        );

        if (isset($content)) {
            // If current tag is wrapped inside another template tag we can't use CDATA section
            // for its content as these can't be nested.
            // CDATA section will be used only for content of root wrapping tag, content of tags
            // inside it will be added as XML fragments.
            if ($this->isWrapped($template)) {
                $fragment = $document->createDocumentFragment();
                $fragment->appendXML($content);
                $template->parentNode->replaceChild($fragment, $template);
            } else {
                $payload = $document->createElement('ezpayload');
                $payload->appendChild($document->createCDATASection($content));
                $template->appendChild($payload);
            }
        }
    }
986805
public function convert(DOMDocument $document)
    {
        foreach ($this->converters as $converter) {
            $converter->convert($document);
        }

        return $document;
    }
1193493
public function render(\DOMDocument $domDocument)
    {
        $quad = Quad::create();
        $quad->setPosition($this->posX, $this->posY)->setZ($this->posZ)
            ->setOpacity(0.4)->setBackgroundColor("000")
            ->setSize($this->width, $this->height);
        if ($this->id) {
            $quad->setId($this->id);
        }
        if ($this->action) {
            $quad->setAction($this->action)->setFocusBackgroundColor("999");
        }

        return $quad->render($domDocument);
    }