Include an external schema into a database element.
@param \DOMElement $externalDatabaseElement External schema database element to include.
481821
protected function includeExternalSchema(\DOMElement $externalDatabaseElement)
    {
        $database = $this->getDatabaseFromDatabaseElement($externalDatabaseElement);

        $this->initGlobalDatabaseElement($database);

        $globalDatabaseElement = $this->globalDatabaseElements[$database];

        // add an inclusion notice
        $externalSchemaIncludeComment = $globalDatabaseElement->ownerDocument->createComment(
            "External schema included in the combining process"
        );
        $globalDatabaseElement->appendChild($externalSchemaIncludeComment);

        // include the external schema
        $externalSchemaInclude = $globalDatabaseElement->ownerDocument->createElement(
            'external-schema',
            $externalDatabaseElement->ownerDocument->baseURI
        );
        $globalDatabaseElement->appendChild($externalSchemaInclude);

        $this->externalSchemaDatabaseElements[$database][] = $externalDatabaseElement;
    }
1163539
public void addDataElement(String elemName, String content, Attributes attrs) {
        writeDataElement(elemName, attrs, content);
    }
66149
public function processRecord(NodeTemplate $nodeTemplate, array $data)
    {
        $this->unsetAllNodeTemplateProperties($nodeTemplate);

        $externalIdentifier = $this->getExternalIdentifierFromRecordData($data);
        $nodeName = $this->renderNodeName($externalIdentifier);
        if (!isset($data['uriPathSegment'])) {
            $data['uriPathSegment'] = Slug::create($this->getLabelFromRecordData($data))->getValue();
        }

        $recordMapping = $this->getNodeProcessing($externalIdentifier);
        if ($recordMapping !== null) {
            $node = $this->storageNode->getContext()->getNodeByIdentifier($recordMapping->getNodeIdentifier());
            if ($node === null) {
                throw new \Exception(sprintf('Failed retrieving existing node for update. External identifier: %s Node identifier: %s. Maybe the record mapping in the database does not match the existing (imported) nodes anymore.', $externalIdentifier, $recordMapping->getNodeIdentifier()), 1462971366085);
            }
            $this->applyProperties($this->getPropertiesFromDataProviderPayload($data), $node);

        } else {
            $nodeTemplate->setNodeType($this->nodeType);
            $nodeTemplate->setName($nodeName);
            $this->applyProperties($this->getPropertiesFromDataProviderPayload($data), $nodeTemplate);

            $node = $this->createNodeFromTemplate($nodeTemplate, $data);
            $this->registerNodeProcessing($node, $externalIdentifier);
        }

        $this->dimensionsImporter->process($node, $this->getPropertiesFromDataProviderPayload($data), $this->currentEvent);

        return $node;
    }
717501
public function appendChildNode(\SimpleXMLElement $element)
    {
        $target  = dom_import_simplexml($this);
        $insert = $target->ownerDocument->importNode(dom_import_simplexml($element), true);
        $target->appendChild($insert);
    }
507394
protected function elementHasAttribute(DomElement $element, $attributeName)
    {
        // First try to return for link
        if ($element->localName === 'link' && $element->hasAttribute($attributeName)) {
            return true;
        }

        // Second return for embed
        if ($element->hasAttribute(EmbedLinking::TEMP_PREFIX . $attributeName)) {
            return true;
        }

        return false;
    }
79047
protected function addNode(DOMElement $element, $key, $value): void
    {
        $key   = \str_replace(' ', '-', $key);
        $child = $this->element($key);
        $element->appendChild($child);
        $this->convert($child, $value);
    }
186633
protected function getDatabaseFromDatabaseElement(\DOMElement $databaseElement)
    {
        $database = $databaseElement->getAttribute('name');
        if (empty($database)) {
            throw new \LogicException('Unnamed database node.');
        }

        return $database;
    }
1100545
public function addElement(FieldsetInterface &$form, $name, $data)
    {
        if ($data['type'] == 'fieldset') {
            $fieldset = new Fieldset(['name' => $name]);
            foreach ($data['elements'] as $key => $def) {
                $this->addElement($fieldset, $key, $def);
            }
            $form->add($fieldset);
        } else {
            if (array_key_exists($data['type'], static::$_elementAlias)) {
                $class = static::$_elementAlias[$data['type']];
            } else if (
                is_subclass_of($data['type'], 'Slick\Form\ElementInterface')
            ) {
                $class = $data['type'];
            } else {
                throw new Exception\UnknownElementException(
                    "'{$data['type']}' is not a known alias or an implementation of " .
                    "Slick\\Form\\ElementInterface interface"
                );
            }

            /** @var Element $element */
            $element = new $class(['name' => $name]);

            if (isset($data['input'])) {
                $element->input = InputFilterFactory::createInput(
                    $data['input'],
                    $element->getName()
                );
            }

            if (!empty($data['validate'])) {
                $this->addValidation($element, $data['validate']);
            }

            foreach (array_keys($this->_elementProperties) as $key) {
                if (isset($data[$key])) {
                    $element->$key = $data[$key];
                }
            }

            $form->add($element);
        }
    }
479836
protected function addSequentialNode(DOMElement $element, $value): void
    {
        if (empty($element->nodeValue)) {
            $element->nodeValue = \htmlspecialchars($value);
            return;
        }

        $child = $this->element($element->nodeName);
        $child->nodeValue = \htmlspecialchars($value);
        $element->parentNode->appendChild($child);
    }
794081
private function appendDatabaseNode(Database $database, \DOMNode $parentNode)
    {
        $databaseNode = $parentNode->appendChild($this->document->createElement('database'));
        $databaseNode->setAttribute('name', $database->getName());
        $databaseNode->setAttribute('defaultIdMethod', $database->getDefaultIdMethod());

        if ($package = $database->getPackage()) {
            $databaseNode->setAttribute('package', $package);
        }

        if ($schema = $database->getSchema()) {
            $databaseNode->setAttribute('schema', $schema);
        }

        if ($namespace = $database->getNamespace()) {
            $databaseNode->setAttribute('namespace', $namespace);
        }

        if ($baseClass = $database->getBaseClass()) {
            $databaseNode->setAttribute('baseClass', $baseClass);
        }

        if ($baseQueryClass = $database->getBaseQueryClass()) {
            $databaseNode->setAttribute('baseQueryClass', $baseQueryClass);
        }

        if ($defaultNamingMethod = $database->getDefaultPhpNamingMethod()) {
            $databaseNode->setAttribute('defaultPhpNamingMethod', $defaultNamingMethod);
        }

        $defaultAccessorVisibility = $database->getDefaultAccessorVisibility();
        if ($defaultAccessorVisibility !== Database::VISIBILITY_PUBLIC) {
            $databaseNode->setAttribute('defaultAccessorVisibility', $defaultAccessorVisibility);
        }

        $defaultMutatorVisibility = $database->getDefaultMutatorVisibility();
        if ($defaultMutatorVisibility !== Database::VISIBILITY_PUBLIC) {
            $databaseNode->setAttribute('defaultMutatorVisibility', $defaultMutatorVisibility);
        }

        $defaultStringFormat = $database->getDefaultStringFormat();
        if (Database::DEFAULT_STRING_FORMAT !== $defaultStringFormat) {
            $databaseNode->setAttribute('defaultStringFormat', $defaultStringFormat);
        }

        if ($database->isHeavyIndexing()) {
            $databaseNode->setAttribute('heavyIndexing', 'true');
        }

        if ($tablePrefix = $database->getTablePrefix()) {
            $databaseNode->setAttribute('tablePrefix', $tablePrefix);
        }

        if ($database->isIdentifierQuotingEnabled()) {
            $databaseNode->setAttribute('identifierQuoting', 'true');
        }

        /*
            FIXME - Before we can add support for domains in the schema, we need
            to have a method of the Column that indicates whether the column was mapped
            to a SPECIFIC domain (since Column->getDomain() will always return a Domain object)

            foreach ($this->domainMap as $domain) {
                $this->appendDomainNode($databaseNode);
            }
         */
        foreach ($database->getVendorInformation() as $vendorInformation) {
            $this->appendVendorInformationNode($vendorInformation, $databaseNode);
        }

        foreach ($database->getTables() as $table) {
            $this->appendTableNode($table, $databaseNode);
        }
    }
639058
protected function addAttributes($element, $data)
    {
        foreach ($data as $attrKey => $attrVal) {
            $element->setAttribute($attrKey, $attrVal);
        }
    }
912568
function processBySchemaPresence( $element )
    {
        $parent = $element->parentNode;
        if ( $parent instanceof DOMElement )
        {
            // If this is a foreign element, remove it
            if ( !$this->XMLSchema->exists( $element ) )
            {
                if ( $element->nodeName == 'custom' )
                {
                    $this->handleError( self::ERROR_SCHEMA,
                                        ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "Custom tag '%1' is not allowed.",
                                        false, array( $element->getAttribute( 'name' ) ) ) );
                }
                $element = $parent->removeChild( $element );
                return false;
            }

            // Delete if children required and no children
            // If this is an auto-added element, then do not throw error

            if ( $element->nodeType == XML_ELEMENT_NODE && ( $this->XMLSchema->childrenRequired( $element ) || $element->getAttribute( 'children_required' ) )
                 && !$element->hasChildNodes() )
            {
                $element = $parent->removeChild( $element );
                if ( !$element->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/temporary/', 'new-element' ) )
                {
                    $this->handleError( self::ERROR_SCHEMA, ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "&lt;%1&gt; tag can't be empty.",
                                        false, array( $element->nodeName ) ) );
                    return false;
                }
            }
        }
        // TODO: break processing of any node that doesn't have parent
        //       and is not a root node.
        elseif ( $element->nodeName != 'section' )
        {
            return false;
        }
        return true;
    }
157161
protected function expandTreeInElementLast($element, $width)
    {
        /** @var \T4\Orm\Model $class */
        $class = get_class($element);
        $tableName = $class::getTableName();
        /** @var \T4\Dbal\Connection $connection */
        $connection = $class::getDbConnection();
        $this->expandTreeBeforeRgt($connection, $tableName, $element->__rgt, $width);
    }
365912
function addElement($attrs) {
		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
		$this->schemas[$typens][0]->addElement($attrs);
	}
968417
public static function setDOMElementAttribute(DOMElement $element, $attribute, $value)
    {
        switch (gettype($value)) {
            case 'boolean':
                $element->setAttribute($attribute, ($value === true) ? 'true' : 'false');
                break;
            
            default:
                $element->setAttribute($attribute, '' . $value);
                break;
        }
    }
1002217
private function composeElement($key, $attributes, $extra = [], $hasCloseTag = false)
    {
        $value = (isset($extra['value'])) ? $extra['value'] : $key;
        $type = (isset($extra['type'])) ? $extra['type'] : $key;
        list($elClass, $attributes) = $this->highlightErrorElement($key, $attributes);

        $val = '';
        if ($hasCloseTag) {
            if (is_object($this->entity)) {
                if (method_exists($this->entity, 'get'.Inflector::camelize($key))) {
                    $val = $this->entity->{'get'.Inflector::camelize($key)}();
                } elseif (property_exists($this->entity, $key)) {
                    $property = (new \ReflectionClass($this->entity))->getProperty($key);
                    if ($property->isPublic()) {
                        $val = $property->getValue();
                    }
                } else {
                    $val = $this->entity->{$key};
                }
            }

            $val = (!isset($attributes['value'])) ? (!empty($val)) ? 'value="'.$val.'"' : ''  : '';

            $this->elements[static::$formHolder[static::$formName]][$key] =
                "<$type name='".$key."' $val ".$this->attributes($attributes). ' '.$elClass.' />'.PHP_EOL;

            return $this;
        }

        $this->elements[static::$formHolder[static::$formName]][$key] =
            "<$type for='".$key."' ".$this->attributes($attributes). ' '.$elClass.' >'.$value."</$type>".PHP_EOL;


        return $this;
    }
1098291
protected function appendAttributesToElementToSend(\DOMElement $element)
    {
        if ($this->hasAttributes()) {
            foreach ($this->getAttributes() as $attributeName => $attributeValue) {
                $matches = [];
                if (0 === preg_match(sprintf('/(%s|%s):/', self::NS_WSSU_NAME, self::NS_WSSE_NAME), $attributeName, $matches)) {
                    $element->setAttribute($attributeName, $attributeValue);
                } else {
                    $element->setAttributeNS(self::NS_WSSE_NAME === $matches[1] ? self::NS_WSSE : self::NS_WSSU, $attributeName, $attributeValue);
                }
            }
        }

        return $this;
    }