Creates object structure from given XML type string

@static
@param string $source
@return eZPage
340813
public static function createFromXML( $source )
    {
        $newObj = new eZPage();

        if ( $source )
        {
            $dom = new DOMDocument( '1.0', 'utf-8' );
            $success = $dom->loadXML( $source );
            $root = $dom->documentElement;

            foreach ( $root->childNodes as $node )
            {
                if ( $node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'zone' )
                {
                    $zoneNode = eZPageZone::createFromXML( $node );
                    $newObj->addZone( $zoneNode );
                }
                elseif ( $node->nodeType == XML_ELEMENT_NODE )
                {
                    $newObj->setAttribute( $node->nodeName, $node->nodeValue );
                }
            }

            if ( $root->hasAttributes() )
            {
                foreach ( $root->attributes as $attr )
                {
                    $newObj->setAttribute( $attr->name, $attr->value );
                }
            }
        }

        $zoneINI = eZINI::instance( 'zone.ini' );
        $layoutName = $newObj->attribute( 'zone_layout' );
        if ( $zoneINI->hasVariable( $layoutName, 'Zones' ) )
        {
            foreach ( $zoneINI->variable( $layoutName, 'Zones' ) as $zoneIdentifier )
            {
                foreach ( $newObj->attribute( 'zones' ) as $inObjectZone )
                {
                    if ( $inObjectZone->attribute( 'zone_identifier' ) === $zoneIdentifier )
                        continue 2;
                }

                $newZone = $newObj->addZone( new eZPageZone() );
                $newZone->setAttribute( 'id', md5( mt_rand() . microtime() . $newObj->getZoneCount() ) );
                $newZone->setAttribute( 'zone_identifier', $zoneIdentifier );
                $newZone->setAttribute( 'action', 'add' );
            }
        }

        return $newObj;
    }
1314244
public static function fromArray( $source )
	{
		try
		{
			$classname = get_called_class();

			if ( ! class_exists( $classname ) )
			{
				\XBRL_Log::getInstance()->err( "The class '$classname' does not exist" );
				return null;
			}

			$instance = new $classname();

			if ( ! $instance instanceof Resource )
			{
				\XBRL_Log::getInstance()->err( "The class instance being created MUST inherit from 'XBRL\\Formulas\\Resources\\Resources'" );
				return null;
			}

			$has = get_object_vars( $instance );
			foreach ( $has as $name => $oldValue )
			{
	        	if ( ! isset( $source[ $name ] ) ) continue;
	        	$instance->$name = $source[ $name ];
			}

			return $instance;
		}
		catch( \Exception $ex )
		{
			return null;
		}
	}
364044
protected static function parseTemplate($source)
    {
        $source =
            '<msg xmlns="http://www.erebot.net/xmlns/erebot/styling">'.
            $source.
            '</msg>';
        $schema = dirname(__DIR__) .
                    DIRECTORY_SEPARATOR . 'data' .
                    DIRECTORY_SEPARATOR . 'styling.rng';
        $dom    =   new \Erebot\DOM();
        $dom->substituteEntities    = true;
        $dom->resolveExternals      = false;
        $dom->recover               = true;
        $ue     = libxml_use_internal_errors(true);
        $dom->loadXML($source);
        $valid  = $dom->relaxNGValidate($schema);
        $errors = $dom->getErrors();
        libxml_use_internal_errors($ue);

        if (!$valid || count($errors)) {
            // Some unpredicted error occurred,
            // show some (hopefully) useful information.
            if (class_exists('\\Plop\\Plop')) {
                $logger = \Plop\Plop::getInstance();
                $logger->error(print_r($errors, true));
            }
            throw new \InvalidArgumentException(
                'Error while validating the message'
            );
        }
        return $dom;
    }
840301
public function append($source)
    {
        foreach ($this as $node) {
            if ($node instanceof Element) {
                $node->prepend($source);
            }
        }

        return $this;
    }
164493
protected function documentFragmentCreate($source, $charset = null)
    {
        $fake              = new DOMDocumentWrapper();
        $fake->contentType = $this->contentType;
        $fake->isXML       = $this->isXML;
        $fake->isHTML      = $this->isHTML;
        $fake->isXHTML     = $this->isXHTML;
        $fake->root        = $fake->document;
        if (!$charset) {
            $charset = $this->charset;
        }
        //	$fake->documentCreate($this->charset);
        if ($source instanceof DOMNODE && !($source instanceof DOMNODELIST)) {
            $source = array($source);
        }
        if (is_array($source) || $source instanceof DOMNODELIST) {
            // dom nodes
            // load fake document
            if (!$this->documentFragmentLoadMarkup($fake, $charset)) {
                return false;
            }
            $nodes = $fake->import($source);
            foreach ($nodes as $node)
                $fake->root->appendChild($node);
        } else {
            // string markup
            $this->documentFragmentLoadMarkup($fake, $charset, $source);
        }

        return $fake;
    }
231873
public static function create($source)
    {
        if (is_array($source)) {
            $source = new Collection($source);
        }

        return parent::create($source);
    }
1275281
public function install($source)
    {
        $pattern                             = chr(1) . '^' . preg_quote(JPATH_ROOT) . '/' . chr(1);
        $this->extensions[basename($source)] = preg_replace($pattern, '', $source);

        $xmlDirectory = $source . '/entities';
        $strategy     = new RecursiveDirectoryStrategy($xmlDirectory);
        $this->builder->addLocatorStrategy($strategy);
        $entityNames = $this->importDefinition($xmlDirectory . '/*.xml');

        foreach ($entityNames as $entityName) {
            $this->dataDirectories[$entityName] = $source . '/data';
        }

        return $entityNames;
    }
1177347
protected function processNoDataDocument($source): NoDataDocument
    {
        $document = new NoDataDocument();

        $this->hydrateObject($document, $source);

        return $document;
    }
886702
private static function from($type, $key, $default, &$source = null) {

    	if(null === $source) {

	    	if(static :: isMethod($type)) {

	    		$source = [];
	    		static :: parseRawHttpRequest($source);
	    	}
    	}

    	static :: $method = ['method' => $type, 'data' => &$source];

    	if(null !== $key) {
    		return static :: get($key, $default);
    	}

    	return $source;
    }
78889
public function parse($source)
    {
        $document = $this->documentFactory->createDocumentFromSource($source);
        $context = clone $this->context;
        $iterator = new DOMIterator($document->childNodes, $context, $this->elementProcessor);

        // Iterate through all $node
        foreach ($iterator->getRecursiveIterator() as $node) {
            $node || true;
        }

        return $context->getChildren();
    }
865688
public function to_xml($data = null, $structure = null, $basenode = null, $use_cdata = null)
	{
		if ($data == null)
		{
			$data = $this->_data;
		}

		is_null($basenode) and $basenode = \Config::get('format.xml.basenode', 'xml');
		is_null($use_cdata) and $use_cdata = \Config::get('format.xml.use_cdata', false);

		// turn off compatibility mode as simple xml throws a wobbly if you don't.
		if (ini_get('zend.ze1_compatibility_mode') == 1)
		{
			ini_set('zend.ze1_compatibility_mode', 0);
		}

		if ($structure == null)
		{
			$structure = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$basenode />");
		}

		// Force it to be something useful
		if ( ! is_array($data) and ! is_object($data))
		{
			$data = (array) $data;
		}

		foreach ($data as $key => $value)
		{
			// replace anything not alpha numeric
			$key = preg_replace('/[^a-z_\-0-9]/i', '', $key);

			// no numeric keys in our xml please!
			if (is_numeric($key))
			{
				// make string key...
				$key = (\Inflector::singularize($basenode) != $basenode) ? \Inflector::singularize($basenode) : 'item';
			}

			// if there is another array found recrusively call this function
			if (is_array($value) or is_object($value))
			{
				$node = $structure->addChild($key);

				// recursive call if value is not empty
				if( ! empty($value))
				{
					$this->to_xml($value, $node, $key, $use_cdata);
				}
			}

			else
			{
				// add single node.
				$encoded = htmlspecialchars(html_entity_decode($value, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, "UTF-8");

				if ($use_cdata and ($encoded !== (string) $value))
				{
					$dom = dom_import_simplexml($structure->addChild($key));
					$owner = $dom->ownerDocument;
					$dom->appendChild($owner->createCDATASection($value));
				}
				else
				{
					$structure->addChild($key, $encoded);
				}
			}
		}

		// pass back as string. or simple xml object if you want!
		return $structure->asXML();
	}
110261
public function source($source = null)
    {
        $model = $this->noInitModel;
        if (!is_string($model->sourceAttribute)) {
            return $this;
        }
        if (!is_string($source)) {
            $modelClass = $this->modelClass;
            $source = $modelClass::$sourceSelf;
        }
        return $this->andWhere([$model->sourceAttribute => $source]);
    }
469563
public static function fromXml(string $string) : self
    {
        $xml = new \SimpleXMLElement($string);

        $data = static::xmlToArray($xml);

        return static::decompile($data);
    }
1095051
public function append($source)
    {
        $importNode = $this->ownerDocument->importNode($this->ownerDocument->importSourceNode($source), true);

        return $this->insertBefore($importNode, $this->firstChild);
    }
239425
public function replace($source)
    {
        $importNode = $this->ownerDocument->importNode($this->ownerDocument->importSourceNode($source), true);

        return $this->parentNode->replaceChild($importNode, $this);
    }
1021022
public function source($source, $sourceType = 'local')
    {
        $this->sourcePath = $source;
        $this->sourceType = $sourceType;

        return $this;
    }
962146
public function loadSource($source)
    {
        $parser = new Parser();

        list($this->headers, $this->content) = $parser->parsePart($source);
    }