示例#1
0
    def _get_namespace_def(self, additional_ns_dict=None):
        # copy necessary namespaces

        namespaces = self._get_namespaces()

        # if there are any other namepaces, include xsi for "schemaLocation"
        # also, include the MAEC default vocabularies schema by default
        if namespaces:
            namespaces.update([lookup_prefix('xsi')])
            namespaces.update([lookup_prefix('maecVocabs')])

        if namespaces and additional_ns_dict:
            namespace_list = [x.name for x in namespaces if x]
            for ns, prefix in additional_ns_dict.iteritems():
                if ns not in namespace_list:
                    namespaces.update([Namespace(ns, prefix, '')])

        if not namespaces:
            return ""

        namespaces = sorted(namespaces, key=str)

        return ('\n\t' + get_xmlns_string(namespaces) +
                '\n\txsi:schemaLocation="' + get_schemaloc_string(namespaces) +
                '"')
示例#2
0
    def _get_namespace_def(self, additional_ns_dict=None):
        # copy necessary namespaces

        namespaces = self._get_namespaces()

        # if there are any other namepaces, include xsi for "schemaLocation"
        # also, include the MAEC default vocabularies schema by default
        if namespaces:
            namespaces.add(lookup_prefix('xsi'))
            namespaces.add(lookup_prefix('maecVocabs'))

            ns_set = make_namespace_subset_from_uris(namespaces)
            if additional_ns_dict:
                for ns, prefix in iteritems(additional_ns_dict):
                    ns_set.add_namespace_uri(ns, prefix)
        else:
            return ""

        return ('\n\t' + ns_set.get_xmlns_string(sort=True, delim='\n\t') +
                '\n\t' + ns_set.get_schemaloc_string(sort=True, delim='\n\t'))