Create a simple namespace-aware objectify element creator.

    Args:
        namespace (str): Namespace to work in

    Returns:
        function: Namespace-aware element creator
517397
def element_creator(namespace=None):
    
    ELEMENT_MAKER = _objectify.ElementMaker(namespace=namespace,
                                            annotate=False)

    def create_elem(tag, attr=None, text=None):
        """:class:`objectify.Element` wrapper with namespace defined.

        Args:
            tag (str): Tag name
            attr (dict): Default attributes for tag
            text (str): Text content for the tag

        Returns:
            _objectify.ObjectifiedElement: objectify element
        """
        if not attr:
            attr = {}
        if text:
            element = getattr(ELEMENT_MAKER, tag)(text, **attr)
        else:
            element = getattr(ELEMENT_MAKER, tag)(**attr)
        return element

    return create_elem
459079
def createElement(self, token):
        """"""
        name = token["name"]
        namespace = token.get("namespace", self.defaultNamespace)
        element = self.elementClass(name, namespace)
        element.attributes = token["data"]
        return element
639369
function buildNamespaceReexport(meta, namespace, checkExport) {
    checkExport();
    return babelTemplate.statement(`
        (function() {
          for (var key in NAMESPACE) {
            if (NAMESPACE == null || !NAMESPACE.hasOwnProperty(key) || key === 'default' || key === '__esModule') return;
            VERIFY_NAME_LIST;
            exports[key] = NAMESPACE[key];
          }
        })();
    `)({
        NAMESPACE: namespace,
        VERIFY_NAME_LIST: meta.exportNameListName
            ? babelTemplate.statement(`
                if (Object.prototype.hasOwnProperty.call(EXPORTS_LIST, key)) return;
            `)({EXPORTS_LIST: meta.exportNameListName})
            : null
    });
}
545756
def in_namespace(name)
      name ||= generate_name
      @scope.push(name)
      ns = NameSpace.new(self, @scope)
      yield(ns)
      ns
    ensure
      @scope.pop
    end
653959
def namespace_uri(self, name):
        
        a_node = self.adapter.get_node_attribute_node(self.impl_element, name)
        if a_node is None:
            return None
        return self.adapter.get_node_namespace_uri(a_node)
541832
def _generate_base_namespace_module(self, api, namespace):
        """"""

        self.cur_namespace = namespace
        generate_module_header(self)

        if namespace.doc is not None:
            self.emit('"""')
            self.emit_raw(namespace.doc)
            self.emit('"""')
            self.emit()

        self.emit_raw(validators_import)

        # Generate import statements for all referenced namespaces.
        self._generate_imports_for_referenced_namespaces(namespace)

        for annotation_type in namespace.annotation_types:
            self._generate_annotation_type_class(namespace, annotation_type)

        for data_type in namespace.linearize_data_types():
            if isinstance(data_type, Struct):
                self._generate_struct_class(namespace, data_type)
            elif isinstance(data_type, Union):
                self._generate_union_class(namespace, data_type)
            else:
                raise TypeError('Cannot handle type %r' % type(data_type))

        for alias in namespace.linearize_aliases():
            self._generate_alias_definition(namespace, alias)

        # Generate the struct->subtype tag mapping at the end so that
        # references to later-defined subtypes don't cause errors.
        for data_type in namespace.linearize_data_types():
            if is_struct_type(data_type):
                self._generate_struct_class_reflection_attributes(
                    namespace, data_type)
                if data_type.has_enumerated_subtypes():
                    self._generate_enumerated_subtypes_tag_mapping(
                        namespace, data_type)
            elif is_union_type(data_type):
                self._generate_union_class_reflection_attributes(
                    namespace, data_type)
                self._generate_union_class_symbol_creators(data_type)

        self._generate_routes(api.route_schema, namespace)
434404
def _fixNS(self, namespace):
        
        if namespace == OPENID_NS:
            if self._openid_ns_uri is None:
                raise UndefinedOpenIDNamespace('OpenID namespace not set')
            else:
                namespace = self._openid_ns_uri

        if namespace != BARE_NS and type(namespace) not in [str, unicode]:
            raise TypeError(
                "Namespace must be BARE_NS, OPENID_NS or a string. got %r"
                % (namespace,))

        if namespace != BARE_NS and ':' not in namespace:
            fmt = 'OpenID 2.0 namespace identifiers SHOULD be URIs. Got %r'
            warnings.warn(fmt % (namespace,), DeprecationWarning)

            if namespace == 'sreg':
                fmt = 'Using %r instead of "sreg" as namespace'
                warnings.warn(fmt % (SREG_URI,), DeprecationWarning,)
                return SREG_URI

        return namespace
378887
function createDocument(root, namespace) {
    if (!root)
      return document.implementation.createHTMLDocument();
    else
      return document.implementation.createDocument(
        namespace || null,
        root,
        null
      );
  }
199453
def register_element_cls(tag, cls):
    
    nspfx, tagroot = tag.split(':')
    namespace = element_class_lookup.get_namespace(nsmap[nspfx])
    namespace[tagroot] = cls
652334
public void useNamespace(SerializerContext serializerContext, String namespace)
	{
		if (namespace != null && namespace.length() > 0)
		{
			if (serializerContext.knownNamespaces == null)
			{
				serializerContext.knownNamespaces = new HashSet<String>(8);
			}
			serializerContext.knownNamespaces.add(namespace);
		}
	}
1290208
function (namespace) {
            var nsparts = namespace.split(".");
            var parent = module.scope.MeadCo;

            // we want to be able to include or exclude the root namespace so we strip
            // it if it's in the namespace
            if (nsparts[0] === "MeadCo") {
                nsparts = nsparts.slice(1);
            }

            // loop through the parts and create a nested namespace if necessary
            for (var i = 0; i < nsparts.length; i++) {
                var partname = nsparts[i];
                // check if the current parent already has the namespace declared
                // if it isn't, then create it
                if (typeof parent[partname] === "undefined") {
                    parent[partname] = {};
                }
                // get a reference to the deepest element in the hierarchy so far
                parent = parent[partname];
            }
            // the parent is now constructed with empty namespaces and can be used.
            // we return the outermost namespace
            return parent;
        }
9569
def generate_imports_for_referenced_namespaces(
        backend, namespace, insert_type_ignore=False):
    # type: (Backend, ApiNamespace, bool) -> None
    

    imported_namespaces = namespace.get_imported_namespaces(consider_annotation_types=True)
    if not imported_namespaces:
        return

    type_ignore_comment = TYPE_IGNORE_COMMENT if insert_type_ignore else ""

    backend.emit('try:')
    with backend.indent():
        backend.emit('from . import (')
        with backend.indent():
            for ns in imported_namespaces:
                backend.emit(fmt_namespace(ns.name) + ',')
        backend.emit(')')
    backend.emit('except (ImportError, SystemError, ValueError):')
    # Fallback if imported from outside a package.
    with backend.indent():
        for ns in imported_namespaces:
            backend.emit('import {namespace_name}{type_ignore_comment}'.format(
                namespace_name=fmt_namespace(ns.name),
                type_ignore_comment=type_ignore_comment
            ))
    backend.emit()
1138225
function (namespaces, defaultNamespace, name) {
    var self = this;

    assert(namespaces);
    assert(name);
    if (/^\{.+\}/.test(name)) {
      return name;
    }
    else if (/:/.test(name)) {
      var parts = name.split(':');
      assert(parts.length === 2, parts);
      if (!namespaces[parts[0]]) {
        throw new xml2js.ValidationError("Unknown namespace " + parts[0] + ", name: " + name + ", known namespaces: " + util.inspect(namespaces, false, null));
      }
      return '{' + namespaces[parts[0]] + '}' + parts[1];
    }
    else if (defaultNamespace) {
      return '{' + defaultNamespace + '}' + name;
    }
    else {
      throw new xml2js.ValidationError("Unqualified name and no default namespace: " + name);
    }
  }
437013
def write_namespaces(self, namespaces):
        """"""
        self.printer.writelines(
            "def _mako_get_namespace(context, name):",
                "try:",
                    "return context.namespaces[(__name__, name)]",
                "except KeyError:",
                    "_mako_generate_namespaces(context)",
                "return context.namespaces[(__name__, name)]",
            None, None
        )
        self.printer.writeline("def _mako_generate_namespaces(context):")


        for node in namespaces.values():
            if 'import' in node.attributes:
                self.compiler.has_ns_imports = True
            self.printer.start_source(node.lineno)
            if len(node.nodes):
                self.printer.writeline("def make_namespace():")
                export = []
                identifiers = self.compiler.identifiers.branch(node)
                self.in_def = True
                class NSDefVisitor(object):
                    def visitDefTag(s, node):
                        s.visitDefOrBase(node)

                    def visitBlockTag(s, node):
                        s.visitDefOrBase(node)

                    def visitDefOrBase(s, node):
                        if node.is_anonymous:
                            raise exceptions.CompileException(
                                "Can't put anonymous blocks inside "
                                "<%namespace>",
                                **node.exception_kwargs
                            )
                        self.write_inline_def(node, identifiers, nested=False)
                        export.append(node.funcname)
                vis = NSDefVisitor()
                for n in node.nodes:
                    n.accept_visitor(vis)
                self.printer.writeline("return [%s]" % (','.join(export)))
                self.printer.writeline(None)
                self.in_def = False
                callable_name = "make_namespace()"
            else:
                callable_name = "None"

            if 'file' in node.parsed_attributes:
                self.printer.writeline(
                                "ns = runtime.TemplateNamespace(%r,"
                                " context._clean_inheritance_tokens(),"
                                " templateuri=%s, callables=%s, "
                                " calling_uri=_template_uri)" %
                                (
                                    node.name,
                                    node.parsed_attributes.get('file', 'None'),
                                    callable_name,
                                )
                            )
            elif 'module' in node.parsed_attributes:
                self.printer.writeline(
                                "ns = runtime.ModuleNamespace(%r,"
                                " context._clean_inheritance_tokens(),"
                                " callables=%s, calling_uri=_template_uri,"
                                " module=%s)" %
                                (
                                    node.name,
                                    callable_name,
                                    node.parsed_attributes.get(
                                                'module', 'None')
                                )
                            )
            else:
                self.printer.writeline(
                                "ns = runtime.Namespace(%r,"
                                " context._clean_inheritance_tokens(),"
                                " callables=%s, calling_uri=_template_uri)" %
                                (
                                    node.name,
                                    callable_name,
                                )
                            )
            if eval(node.attributes.get('inheritable', "False")):
                self.printer.writeline("context['self'].%s = ns" % (node.name))

            self.printer.writeline(
                "context.namespaces[(__name__, %s)] = ns" % repr(node.name))
            self.printer.write_blanks(1)
        if not len(namespaces):
            self.printer.writeline("pass")
        self.printer.writeline(None)
496743
def p_namespace(self, p):
        """"""
        if p[1] == 'namespace':
            doc = None
            if len(p) > 4:
                doc = p[5]
            p[0] = AstNamespace(
                self.path, p.lineno(1), p.lexpos(1), p[2], doc)
        else:
            raise ValueError('Expected namespace keyword')
716039
function Namespacer(settings, callback) {
      if (settings.namespace != null) {
        this.groupNamespace = settings.namespace;
      } else {
        callback('Error: \'namespace\' is not configured');
      }
      if (settings.templates != null) {
        this.templates = settings.templates;
      } else {
        callback('Error: \'templates\' is not configured');
      }
      if (settings.skiproot != null) {
        this.skiproot = settings.skiproot;
      }
      if ((this.groupNamespace != null) && (this.templates != null)) {
        this.callback = callback;
        this.namespaces = [];
        this.result = [];
        this.init();
      }
    }
566792
def _create_xml_node(cls):
        
        try:
            xml_map = cls._xml_map
        except AttributeError:
            raise ValueError("This model has no XML definition")

        return _create_xml_node(
            xml_map.get('name', cls.__name__),
            xml_map.get("prefix", None),
            xml_map.get("ns", None)
        )