Set document namespace and parse the XML.

@param  string  $namespace
@param  array  $schema
@param  array  $config

@return array
760493
public function namespaced(string $namespace, array $schema, array $config = []): array
    {
        $document = $this->getContent();
        $namespaces = $this->getAvailableNamespaces();

        if (! \is_null($namespace) && isset($namespaces[$namespace])) {
            $document = $document->children($namespaces[$namespace]);
        }

        $this->content = $document;

        return $this->parse($schema, $config);
    }
1282373
protected function parseSchemaNameToArray($schemaName)
    {
        if (!isset($this->schemas[$this->schemaFolder][$schemaName])) {
            $file = $this->getSchemaFileName($this->schemaFolder, $schemaName);
            try {
                $this->schemas[$this->schemaFolder][$schemaName] = Yaml::parse(file_get_contents($file));
            } catch (ParseException $e) {
                throw new SchemaParserException(sprintf('Error in configuration file: %s', $e->getMessage()));
            }
            $this->mergeDefaultSchemaFile($schemaName);
            $this->mergeIncludedSchemas($schemaName);
            $this->validateSchemaDirectives($schemaName);
        }
    }
1089578
static function setCache($namespace)
    {
        $cacheData = [];
        $data = CommonConfigModel::getConfigByNamespace($namespace);
        foreach ($data as $key => $value) {
            $cacheData[$value['name']] = [
                'value'=>self::_getInfo($value['vtype'], $value['value']),
                'issystem'=>$value['issystem'],
                'desc'=>$value['desc']
            ];
        }
        $cacheName = 'config:'.$namespace;
        Cache::forever($cacheName, $cacheData);
        return $cacheData;
    }
1374500
public static function definition($schema = null)
    {
        if (func_num_args()) {
            if (is_string($schema)) {
                static::$_definition = $schema;
            } elseif($schema) {
                static::$_definitions[static::class] = $schema;
            } else {
                unset(static::$_definitions[static::class]);
            }
            return;
        }
        $self = static::class;
        if (isset(static::$_definitions[$self])) {
            return static::$_definitions[$self];
        }
        $conventions = static::conventions();
        $config = [
            'connection'  => static::$_connection,
            'conventions' => $conventions,
            'class'       => $self,
            'locked'      => Document::class !== $self
        ];
        $config += ['source' => $conventions->apply('source', $self)];

        $class = static::$_definition;
        $schema = static::$_definitions[$self] = new $class($config);
        static::_define($schema);
        return $schema;
    }
1273739
private void parseNamespaceFilterConfig(final Node node, final ConfigSettings config) {
		String name;
		Integer value;
		Node nnode;
		final NodeList list = node.getChildNodes();
		final int length = list.getLength();
		final Set<Integer> namespaces = new HashSet<Integer>();

		for (int i = 0; i < length; i++) {
			nnode = list.item(i);

			name = nnode.getNodeName().toUpperCase();
			if (name.equals(NAMESPACE_TO_KEEP)) {

				value = Integer.parseInt(nnode.getChildNodes().item(0)
						.getNodeValue());
				namespaces.add(value);


			}

		}

		config.setConfigParameter(
				ConfigurationKeys.NAMESPACES_TO_KEEP,
				namespaces);

	}
1282938
public function setNamespace($namespace)
    {
        $parts = explode('/', $namespace);

        foreach ($parts as &$part) {
            $part = $this->toSnakeCase($part, '-');
        }

        $namespace = implode('/', $parts);
        $namespace = '/' . trim($namespace, '/');
        $this->namespace = $namespace;

        return $this;
    }
1236044
public static function initialize($namespace, $config, $cache)
    {
        $context = new self($namespace);
        $context->cache = $cache;
        $context->config = $config;
        $context->prefix = $config->get('app.prefix', null);
        $context->parameters = Parameters::wrap([]);
        self::$instance = $context;
        return $context;
    }
421502
public function phpConfigFile($path, array $config = [], $namespace = null)
    {
        $this->file($path)->text(Php\ConfigGenerator::generateText($config, $namespace));
    }
479273
def _add_namespace(marc_xml):
    
    dom = marc_xml

    if isinstance(dom, basestring):
        dom = dhtmlparser.parseString(marc_xml)

    root = dom.find("root")
    if root:
        root[0].params = {}

    for record in dom.find("record"):
        record.params = {}

    collections = dom.find("collection")
    if not collections:
        record = dom.find("record")[0]
        return XML_TEMPLATE.replace("$CONTENT", str(record))

    for col in collections:
        col.params["xmlns"] = "http://www.loc.gov/MARC21/slim"
        col.params["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
        col.params["xsi:schemaLocation"] = "http://www.loc.gov/MARC21/slim " + \
                   "http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"

    return str(dom)
1102449
public function processSchema( $xsd, $includeElements = false )
	{
		libxml_use_internal_errors();

		$xml = @simplexml_load_file( $xsd );
		if ( ! $xml )
		{
			return false;
		}

		$activeSchemaPrefix = null;

		$prefix = null;
		$targetNamespace = (string) $xml->attributes()->targetNamespace;
		foreach ( $xml->getDocNamespaces() as $namespacePrefix => $namespace )
		{
			if ( ! empty( $namespacePrefix ) && $namespace == SCHEMA_NAMESPACE )
			{
				$activeSchemaPrefix = $namespacePrefix;
			}

			$xml->registerXPathNamespace( $namespacePrefix, $namespace );
			if ( $namespace != $targetNamespace ) continue;
			$prefix = $namespacePrefix;
		}
		$xml->registerXPathNamespace( SCHEMA_PREFIX, SCHEMA_NAMESPACE );

		if ( ! $prefix )
		{
			// If there is no prefix generate a random one
			$prefix = substr( str_shuffle( "abcdefghijklmnopqrstuvwxyz" ), 0, 8 );
		}

		$xpath = new \DOMXPath( dom_import_simplexml( $xml )->ownerDocument );
		$xpath->registerNamespace( SCHEMA_PREFIX, SCHEMA_NAMESPACE );
		$imports = $xpath->query( "/xs:schema/xs:import" );

		foreach ( $imports as $import )
		{
			$nextNamespace = (string) $import->getAttribute( 'namespace' );

			$schemaLocation = (string) $import->getAttribute( 'schemaLocation' );
			$nextXSD = SchemaTypes::resolve_path( $xsd, $schemaLocation );

			$this->processSchema( $nextXSD, $includeElements );
		}

		if ( in_array( $targetNamespace, $this->processedSchemas ) ) return true;

		$this->processedSchemas[ $prefix ] = $targetNamespace;
		$this->activeSchemaPrefix = $activeSchemaPrefix;

		foreach ( $xml->children( SCHEMA_NAMESPACE ) as $nodeKey => $node )
		{
			$this->processNode( $node, $nodeKey, $prefix, $includeElements );
		}

		return true;
	}
645026
private function addNamespaceAttributes(ClassMetadata $metadata, \DOMElement $element): void
    {
        foreach ($metadata->xmlNamespaces as $prefix => $uri) {
            $attribute = 'xmlns';
            if ('' !== $prefix) {
                $attribute .= ':' . $prefix;
            } elseif ($element->namespaceURI === $uri) {
                continue;
            }
            $element->setAttributeNS('http://www.w3.org/2000/xmlns/', $attribute, $uri);
        }
    }
1255814
public function setNamespace($namespace)
    {
        if (!is_string($namespace)) {
            throw new \InvalidArgumentException('The attribute namespace on the class Entity has to be string (' . gettype($namespace) . ('object' === gettype($namespace) ? ' ' . get_class($namespace) : '') . ' given).');
        }

        if (strlen($namespace) < 1) {
            throw new \InvalidArgumentException('On the attribute namespace, the length of the string ' . $namespace . ' is ' . strlen($namespace) . ' which is shorter than the minimum allowed (1).');
        }

        $this->namespace = $namespace;

        return $this;
    }
1000328
static function getConfigByName($namespace, $name) 
    {
        $info = CommonConfigModel::where('namespace', $namespace)
                                    ->where('name', $name)
                                    ->first();
        if (!empty($info)) {
            return $info;
        }
        return array();
    }
118974
protected function getNamespace($config_name, $extra_ns = '')
    {
        $elements =
            [
                $this->prefix_ns,
                Inflector::studlyCaps($config_name),
                Inflector::studlyCaps(sprintf("%s_schema", $this->schema)),
                $extra_ns
            ];

        return join('\\', array_filter($elements, function ($val) { return $val != null; }));
    }
984240
@SuppressWarnings("unchecked")
    private void inheritNamespaces(SchemaImpl schema, Definition wsdl) {
        Map<String, String> wsdlNamespaces = wsdl.getNamespaces();
        
        for (Entry<String, String> nsEntry: wsdlNamespaces.entrySet()) {
            if (StringUtils.hasText(nsEntry.getKey())) {
                if (!schema.getElement().hasAttributeNS(WWW_W3_ORG_2000_XMLNS, nsEntry.getKey())) {
                    schema.getElement().setAttributeNS(WWW_W3_ORG_2000_XMLNS, "xmlns:" + nsEntry.getKey(), nsEntry.getValue());
                }
            } else { // handle default namespace
                if (!schema.getElement().hasAttribute("xmlns")) {
                    schema.getElement().setAttributeNS(WWW_W3_ORG_2000_XMLNS, "xmlns" + nsEntry.getKey(), nsEntry.getValue());
                }
            }
        }
    }
454116
public function valueAlignmentForNamespace( $namespace, $name )
	{
		$prefix = "";

		// Normalize the prefix
		switch ( $namespace )
		{
			// case "http://www.xbrl.org/dtr/type/numeric":
			case XBRL_Constants::$dtrNumeric:
				$prefix = "num";
				break;

			// case "http://www.xbrl.org/dtr/type/non-numeric":
			case XBRL_Constants::$dtrNonnum:
				$prefix = "nonnum";
				break;

			case XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ]:
				$prefix = STANDARD_PREFIX_XBRLI;
				break;

			default:
				$tax = $this->getTaxonomyForNamespace( $namespace );
				if ( $tax )
				{
					$prefix = $tax->getPrefix();
				}
				else
				{
					$this->log()->warning( "valueAlignmentForNamespace: Need to handle '$namespace'" );
				}
				break;
		}

		/*
valueAlignmentForNamespace: Need to handle ''
valueAlignmentForNamespace: Need to handle 'http://xbrl.sec.gov/dei/2014-01-31'
valueAlignmentForNamespace: Need to handle type ':centralIndexKeyItemType'
valueAlignmentForNamespace: Need to handle type ':filerCategoryItemType'
valueAlignmentForNamespace: Need to handle type ':fiscalPeriodItemType'
valueAlignmentForNamespace: Need to handle type ':perShareItemType'
valueAlignmentForNamespace: Need to handle type ':submissionTypeItemType'
valueAlignmentForNamespace: Need to handle type ':yesNoItemType'
valueAlignmentForNamespace: Need to handle type 'xbrli:tokenItemType'		 * */
		$type = "$prefix:$name";

		switch ( $type )
		{
			case 'num:perShareItemType':
			case 'num:percentItemType':
			case 'xbrli:decimalItemType':
			case 'xbrli:monetaryItemType':
			case 'xbrli:sharesItemType':
			case 'xbrli:integerItemType':
			case 'xbrli:pureItemType':
			case 'types:EPSItemType';
				return "right";

			case 'nonnum:textBlockItemType':
			case 'xbrli:dateItemType':
			case 'xbrli:stringItemType':
			case 'xbrli:booleanItemType':
			case 'xbrli:normalizedStringItemType':
			case 'xbrli:gMonthDayItemType':
			case 'xbrli:gYearItemType':
			case 'xbrli:durationItemType':
			case 'xbrli:tokenItemType':
			case 'types:RelatedPartyItemType':
			case 'types:TextBlockNoteItemType':
			case 'types:TextBlockScheduleItemType':
			case 'types:TextBlockPolicyItemType':
				return "left";

			default:
				$this->log()->warning( "valueAlignmentForNamespace: Need to handle type '$type'" );
				return "left";
		}
	}
573668
private function setupNamespace($namespace)
	{
		if(!is_null($namespace)) {
			if(!isset($_SESSION[$namespace]) || !is_array($_SESSION[$namespace])) {
				$_SESSION[$namespace] = array();
			}
			$this->data = &$_SESSION[$namespace];
		} else {
			$this->data = &$_SESSION;
		}
	}