Source code for gws.ext.helper.xml

"""Common xml writer helper."""

import gws
import gws.types as t

from . import namespaces


[docs]class NamespaceConfig(t.Data): name: str uri: t.Url schemaLocation: t.Optional[t.Url]
[docs]class Config(t.WithType): """XML settings""" namespaces: t.Optional[t.List[NamespaceConfig]]
[docs]class Object(gws.Object):
[docs] def configure(self): super().configure() self.namespaces = {} for ns in namespaces.ALL: self.namespaces[ns[0]] = ns[1:] for ns in self.var('namespaces', default=[]): self.namespaces[ns.name] = [ns.uri, ns.get('schemaLocation', '')]
[docs] def namespace(self, name): p = self.namespaces.get(name) return p or ['', '']