Verarbeitet die in der Konfiguration definierten ActionMappings.

@param  \SimpleXMLElement $xml - XML-Konfiguration

@throws StrutsConfigException on configuration errors
772565
protected function processMappings(\SimpleXMLElement $xml) {
        if ($this->configured) throw new IllegalStateException('Configuration is frozen');
        $elements = $xml->xpath('/struts-config/action-mappings/mapping') ?: [];

        foreach ($elements as $tag) {
            /** @var ActionMapping $mapping */
            $mapping = new $this->mappingClass($this);


            // process attributes
            // ------------------
            // attribute path="%RequestPath" #REQUIRED
            $path = (string) $tag['path'];                      // TODO: URL validieren
            $mapping->setPath($path);


            // attribute name="%LogicalName" #IMPLIED
            $sName = '';
            if (isset($tag['name'])) {
                $name  = (string) $tag['name'];
                $sName = ' name="'.$name.'"';
                $mapping->setName($name);
            }


            // attribute include="%ResourcePath" #IMPLIED
            if (isset($tag['include'])) {
                if ($mapping->getForward()) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": Only one of "action", "include", "forward" or "redirect" can be specified.');

                $this->tilesContext = [];
                $include = (string) $tag['include'];
                if (!$this->isIncludable($include, $xml)) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'" include="'.$include.'": '.(strStartsWith($include, '.') ? 'Tile definition':'File').' not found.');

                $forward = null;

                if ($this->isTileDefinition($include, $xml)) {
                    $tile = $this->getTile($include, $xml);
                    if ($tile->isAbstract()) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'" include="'.$include.'": The included tile is a template and cannot be used in a "mapping" definition.');
                    /** @var ActionForward $forward */
                    $forward = new $this->forwardClass('generic', $include, false);
                }
                else {
                    /** @var ActionForward $forward */
                    $forward = new $this->forwardClass('generic', $this->findFile($include), false);
                    $forward->setLabel(strLeftTo($include, '.', -1));
                }
                $mapping->setForward($forward);
            }


            // attribute redirect="%RequestPath" #IMPLIED
            if (isset($tag['redirect'])) {
                if ($mapping->getForward()) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": Only one of "action", "include", "forward" or "redirect" can be specified');
                $redirect     = (string) $tag['redirect'];      // TODO: URL validieren
                $redirectType = isset($tag['redirect-type']) ? (string) $tag['redirect-type'] : 'temporary';
                $redirectType = $redirectType=='temporary' ? HttpResponse::SC_MOVED_TEMPORARILY : HttpResponse::SC_MOVED_PERMANENTLY;

                /** @var ActionForward $forward */
                $forward = new $this->forwardClass('generic', $redirect, true, $redirectType);
                $mapping->setForward($forward);
            }
            else if (isset($tag['redirect-type'])) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": The "redirect-type" attribute can only be specified together with the "redirect" attribute.');


            // attribute forward="%LogicalName" #IMPLIED
            if (isset($tag['forward'])) {
                if ($mapping->getForward()) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": Only one of "action", "include", "forward" or "redirect" can be specified.');
                $forwardAttr = (string) $tag['forward'];

                /** @var ActionForward $forward */
                $forward = $this->findForward($forwardAttr);
                if (!$forward)              throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": Forward "'.$forwardAttr.'" not found.');
                $mapping->setForward($forward);
            }
            if ($mapping->getForward() && sizeof($tag->xpath('./forward'))) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": Only an "include", "forward" or "redirect" attribute *or* nested <forward> elements must be specified.');


            // attribute action="%ClassName" #IMPLIED
            if (isset($tag['action'])) {
                if ($mapping->getForward())  throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": Only one of "action", "include", "forward" or "redirect" can be specified.');
                $name = trim((string) $tag['action']);
                $classNames = $this->resolveClassName($name);
                if (!$classNames)            throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'" action="'.$tag['action'].'": Class not found.');
                if (sizeof($classNames) > 1) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'" action="'.$tag['action'].'": Ambiguous class name, found "'.join('", "', $classNames).'".');
                $mapping->setActionClassName($classNames[0]);
            }


            // attribute form="%ClassName" #IMPLIED
            if (isset($tag['form'])) {
                $name = trim((string) $tag['form']);
                $classNames = $this->resolveClassName($name);
                if (!$classNames)            throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'" form="'.$tag['form'].'": Class not found.');
                if (sizeof($classNames) > 1) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'" form="'.$tag['form'].'": Ambiguous class name, found "'.join('", "', $classNames).'".');
                $mapping->setFormClassName($classNames[0]);
            }


            // attribute form-scope="(request|session)" "request"
            if (isset($tag['form-scope'])) {
                if (!isset($tag['form']))    throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": A "form" attribute must be specified if "form-scope" is defined.');
                $mapping->setFormScope((string) $tag['form-scope']);
            }


            // attribute form-validate-first="%Boolean" "true"
            $formValidateFirst = false;
            if ($mapping->getFormClassName()) {
                $action = $mapping->getActionClassName();
                if ($action || $mapping->getForward()) {
                    $formValidateFirst = isset($tag['form-validate-first']) ? ($tag['form-validate-first']=='true') : !$action;
                }
                else {
                    if ($tag['form-validate-first']=='false') throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": An "action", "include", "redirect" or "forward" attribute is required if "form-validate-first" is set to "false"');
                    $formValidateFirst = true;
                    // Pruefung auf 'success' und 'error' Forward erfolgt in ActionMapping:freeze()
                }
            }
            elseif ($tag['form-validate-first'] == 'true') {
                throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'": A "form" attribute must be specified if "form-validate-first" is set to "true"');
            }
            $mapping->setFormValidateFirst($formValidateFirst);


            // attribute methods="CDATA" "get"
            if (isset($tag['methods'])) {
                $methods = explode(',', (string) $tag['methods']);
                foreach ($methods as $method) {
                    $mapping->setMethod(trim($method));
                }
            }
            else {
                $mapping->setMethod('GET');
            }


            // attribute roles="CDATA" #IMPLIED
            if (isset($tag['roles'])) {
                if (!$this->roleProcessorClass) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'" roles="'.$tag['roles'].'": RoleProcessor configuration not found');
                $mapping->setRoles((string) $tag['roles']);
            }


            // attribute default="%Boolean" "false"
            if ($tag['default']) {
                $mapping->setDefault($tag['default']=='true');
            }


            // process child nodes
            // -------------------
            // local 'include' and 'redirect' forwards
            $subElements = $tag->xpath('./forward[@include] | ./forward[@redirect]') ?: [];

            foreach ($subElements as $forwardTag) {
                $name = (string) $forwardTag['name'];
                if (strCompareI($name, ActionForward::SELF)) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'"> <forward name="'.$name.'": Can not use reserved name "'.$name.'".');

                $include  = isset($forwardTag['include' ]) ? (string)$forwardTag['include' ] : null;
                $redirect = isset($forwardTag['redirect']) ? (string)$forwardTag['redirect'] : null;
                $alias    = isset($forwardTag['alias'   ]) ? (string)$forwardTag['alias'   ] : null;

                if (is_string($include)) {
                    if (is_string($redirect) || is_string($alias)) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'"> <forward name="'.$name.'": Only one of "include", "redirect" or "alias" can be specified.');

                    $this->tilesContext = [];
                    if (!$this->isIncludable($include, $xml)) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'"> <forward name="'.$name.'" include="'.$include.'": '.(strStartsWith($include, '.') ? 'Tiles definition':'File').' not found.');

                    $forward = null;

                    if ($this->isTileDefinition($include, $xml)) {
                        $tile = $this->getTile($include, $xml);
                        if ($tile->isAbstract()) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'"> <forward name="'.$name.'" include="'.$include.'": The included tile is a template and cannot be used in a "forward".');
                        /** @var ActionForward $forward */
                        $forward = new $this->forwardClass($name, $include, false);
                    }
                    else {
                        /** @var ActionForward $forward */
                        $forward = new $this->forwardClass($name, $this->findFile($include), false);
                        $forward->setLabel(substr($include, 0, strrpos($include, '.')));
                    }
                    $mapping->addForward($name, $forward);
                }

                if (is_string($redirect)) {
                    if (is_string($include) || is_string($alias)) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'"> <forward name="'.$name.'": Only one of "include", "redirect" or "alias" can be specified.');

                    /** @var ActionForward $forward */
                    $forward = new $this->forwardClass($name, $redirect, true);     // TODO: URL validieren
                    $mapping->addForward($name, $forward);
                }
            }

            // local 'alias' forwards (parsed after all other local forwards to be able to access them)
            $subElements = $tag->xpath('./forward[@alias]') ?: [];

            foreach ($subElements as $forwardTag) {
                $name  = (string) $forwardTag['name' ];
                $alias = (string) $forwardTag['alias'];
                if (isset($forwardTag['include' ]) || isset($forwardTag['redirect' ])) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'"> <forward name="'.$name.'": Only one of "include", "redirect" or "alias" can be specified.');

                $forward = $mapping->findForward($alias);
                if (!$forward) throw new StrutsConfigException('<mapping'.$sName.' path="'.$path.'"> <forward name="'.$name.'" alias="'.$alias.'": Alias forward not found');

                $mapping->addForward($name, $forward);
            }

            // done
            $this->addMapping($mapping);
        }
    }
600301
protected function parseFilters(SimpleXMLElement $xml)
    {
        if (false === $filters = $xml->xpath('//config:filters/config:filter')) {
            return;
        }
        try {
            $filterConfig = $this->container->getParameter("Thelia.parser.filters");
        } catch (ParameterNotFoundException $e) {
            $filterConfig = array();
        }

        foreach ($filters as $filter) {
            $filterConfig[$this->getAttributeAsPhp($filter, "name")] = $this->getAttributeAsPhp($filter, "class");
        }

        $this->container->setParameter("Thelia.parser.filters", $filterConfig);
    }
1025162
protected function setAttributes(SimpleXMLElement $element)
    {
        $nb_parent = $this->nb_data_object->getTranslatedObject();
        if ($nb_parent !== null) {
            $nb_language = $nb_parent->getLanguage($this->nb_data_object->getLanguageId());
            $element->addAttribute('lang', $nb_language->grantHash(true));
            $this->putAttributesFromList($element, array(
                'nb_site_target_section_main_image' => 'image'
            ), false);
        }
    }
1361182
public function setAttributes(
        SimpleXMLElement $element,
        array $attributes
    ) {
        $storage = $element->attributes();
        foreach ($attributes as $key => $value) {
            if (isset($storage->{$key})) {
                $storage->{$key} = $value;
            } else {
                $element->addAttribute($key, $value);
            }
        }
    }
430387
public function parse( $xml, $validateRules = TRUE )
	{
		$this->language		= "en";
		$this->channelData	= $this->emptyChannelData;
		$this->entries		= array();
			
		$root		= new XML_Element( $xml );
		if( $validateRules )
		{
			$validator	= new XML_Atom_Validator();
			if( !$validator->isValid( $root ) )	
				throw new Exception( $validator->getFirstError() );
		}

		$this->language		= $this->getNodeLanguage( $root );
		$this->channelData	= $this->parseNodes( $root, $this->emptyChannelData );
	}
473943
protected function setResourceBase(\SimpleXMLElement $xml) {
        if ($this->configured) throw new IllegalStateException('Configuration is frozen');

        /** @var ConfigInterface $config */
        $config = $this->di('config');
        $rootDirectory = $config['app.dir.root'];

        if (!isset($xml['file-base'])) {
            // not specified, apply global configuration
            $location = $config->get('app.dir.view', null);
            if (!$location) throw new StrutsConfigException('Missing view directory configuration: '
                .'Neither $config[app.dir.view] nor <struts-config file-base="{base-directory}" are specified'.NL
                .'config: '.NL.$config->dump());
            isRelativePath($location) && $location = $rootDirectory.DIRECTORY_SEPARATOR.$location;
            if (!is_dir($location)) throw new StrutsConfigException('Resource location $config[app.dir.view]="'.$config['app.dir.view'].'" not found');

            $this->resourceLocations[] = realpath($location);
            return;
        }

        $locations = explode(',', (string) $xml['file-base']);

        foreach ($locations as $i => $location) {
            $location = trim($location);
            if (!strlen($location)) continue;

            isRelativePath($location) && $location = $rootDirectory.DIRECTORY_SEPARATOR.$location;
            if (!is_dir($location)) throw new StrutsConfigException('<struts-config file-base="'.$locations[$i].'": Resource location not found');

            $this->resourceLocations[] = realpath($location);
        }
    }
690642
public function setXML($xml, $isFile = false)
    {
        $this->_xml = ($isFile ? file_get_contents($xml) : $xml);
    }
1349990
public static function parseExpressionXml(SimpleXMLElement $xml){
        $returnValue = self::parseElementXml($xml);
        $value = trim($xml);
        $expressions = array();
        foreach($xml->children() as $child){
            $expressions[] = self::parseExpressionXml($child);
        }
        if(count($expressions)){
            $returnValue['expressions'] = $expressions;
        }
        if(strlen($value)){
            $returnValue['value'] = $value;
        }
        return $returnValue;
    }
61529
private function parseSubject(DOMElement $xml) : void
    {
        /** @var \DOMElement[] $subject */
        $subject = Utils::xpQuery($xml, './saml_assertion:Subject');
        if (empty($subject)) {
            /* No Subject node. */

            return;
        } elseif (count($subject) > 1) {
            throw new \Exception('More than one <saml:Subject> in <saml:Assertion>.');
        }
        $subject = $subject[0];

        /** @var \DOMElement[] $nameId */
        $nameId = Utils::xpQuery(
            $subject,
            './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData'
        );
        if (count($nameId) > 1) {
            throw new \Exception('More than one <saml:NameID> or <saml:EncryptedID> in <saml:Subject>.');
        } elseif (!empty($nameId)) {
            $nameId = $nameId[0];
            if ($nameId->localName === 'EncryptedData') {
                /* The NameID element is encrypted. */
                $this->encryptedNameId = $nameId;
            } else {
                $this->nameId = new NameID($nameId);
            }
        }

        /** @var \DOMElement[] $subjectConfirmation */
        $subjectConfirmation = Utils::xpQuery($subject, './saml_assertion:SubjectConfirmation');
        if (empty($subjectConfirmation) && empty($nameId)) {
            throw new \Exception('Missing <saml:SubjectConfirmation> in <saml:Subject>.');
        }

        foreach ($subjectConfirmation as $sc) {
            $this->SubjectConfirmation[] = new SubjectConfirmation($sc);
        }
    }
453498
protected function handleXml(\SimpleXMLElement $xml)
    {
        $this->name = XmlHelper::get($xml, 'name');
        $this->label = XmlHelper::get($xml, 'label');

        $this->attributes = XmlHelper::getAttributes($xml);

        $form = $xml;

        $group = [];

        while ($parent = $form->xpath('..')) {
            $parent = $parent[0];

            $name = $parent->getName();

            if ($name === 'fieldset') {
                $this->fieldset = $this->fieldset ?: (string) $parent['name'];
            } elseif ($name === 'group') {
                array_unshift($group, (string) $parent['name']);
            }

            $form = $parent;
        }

        $this->group = implode('/', $group);
    }
55944
private function setSecurity(SimpleXMLElement $element)
    {
        $security = $element->addChild('security');

        $xml_roles = new CNabuXMLSiteMapRoleList($this->nb_data_object->getRoles());
        $xml_roles->build($security);
    }
744343
private function parseLinkInput (SimpleXMLElement $xml)
    {
        return (new ReflectionClass(Input\Link::class))->newInstanceArgs(
            array_merge(
                $this->getCommonMessageProperties($xml),
                [
                    (string)$xml->Url,
                    (string)$xml->Title,
                    (string)$xml->Description,
                ]
            )
        );
    }
1041868
protected function validateCategoryLinks(SimpleXMLElement $xml)
    {
        $categoryIdElements = $xml->xpath('/tweakwise/categories/category/categoryid');
        $categoryIds = array();
        foreach ($categoryIdElements as $id) {
            $categoryIds[] = (string) $id;
        }
        $categoryIds = array_flip($categoryIds);

        foreach ($xml->xpath('/tweakwise/categories/category/parents/categoryid') as $categoryIdElement) {
            $categoryId = (string) $categoryIdElement;
            if (!isset($categoryIds[$categoryId])) {
                throw new ValidationException(__(sprintf('Category parent reference %s not found', $categoryId)));
            }
        }

        foreach ($xml->xpath('/tweakwise/items/item/categories/categoryid') as $categoryIdElement) {
            $categoryId = (string) $categoryIdElement;
            if (!isset($categoryIds[$categoryId])) {
                throw new ValidationException(__(sprintf('Product category reference %s not found', $categoryId)));
            }
        }
    }
1259344
private function validateConfiguration(DOMDocument $dom)
    {
        if (is_file($this->xsdSchemaFile)) {
            libxml_use_internal_errors(true);
            if (@$dom->schemaValidate($this->xsdSchemaFile/*, LIBXML_SCHEMA_CREATE*/)) {
                $this->dom = $dom;
                $this->xpath = new DOMXPath($dom);

                $this->cleanupDOMDocument();

                $this->cache = array('alwaysArray' => array(), 'optionalArray' => array());
            } else {
                $this->triggerHumanReadableErrors();
                if (realpath(parse_url($dom->documentURI, PHP_URL_PATH)) !== realpath($this->defaultConfigurationFile)) {
                    $this->loadConfiguration($this->defaultConfigurationFile);
                }
            }

            libxml_use_internal_errors(false);
        } else {
            trigger_error('A valid schema file must be provided.', E_USER_WARNING);
        }
    }
332159
public function appendChildFromXmlString($xml)
    {
        $dom = new \DOMDocument;
        $dom->loadXML($xml);

        $element = simplexml_import_dom($dom);

        $this->appendChildNode($element);
    }
1344222
private function parseAttributes(DOMElement $xml) : void
    {
        $firstAttribute = true;
        /** @var \DOMElement[] $attributes */
        $attributes = Utils::xpQuery($xml, './saml_assertion:AttributeStatement/saml_assertion:Attribute');
        foreach ($attributes as $attribute) {
            if (!$attribute->hasAttribute('Name')) {
                throw new \Exception('Missing name on <saml:Attribute> element.');
            }
            $name = $attribute->getAttribute('Name');

            if ($attribute->hasAttribute('NameFormat')) {
                $nameFormat = $attribute->getAttribute('NameFormat');
            } else {
                $nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
            }

            if ($firstAttribute) {
                $this->nameFormat = $nameFormat;
                $firstAttribute = false;
            } else {
                if ($this->nameFormat !== $nameFormat) {
                    $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
                }
            }

            if (!array_key_exists($name, $this->attributes)) {
                $this->attributes[$name] = [];
                $this->attributesValueTypes[$name] = [];
            }

            $this->parseAttributeValue($attribute, $name);
        }
    }
73694
public function MakePred($xml) {
      $baml = new BaML;
      $baml->values = $xml;

      self::make($baml);
    }