def __init__(self, schema: Schema, schema_dom, g: Graph = None): """ Schema interpreter :param schema: definition :param schema_dom: equivalent in dom to get the namespace map """ self.schema = schema self._nsmap = PrefixMap(schema, schema_dom) self._default_namespace = schema.default_namespace if schema.default_namespace else '' self._shapes = {self._nsmap.uri_for(sh.label): sh for sh in schema.shape} self._compiled_shapes = {} self._triple_results = {} self._graph = g
def __init__(self, dom_schema): """ Constructor - convert the supplied schema to json :param dom_schema: DOM document to convert """ self.schema = CreateFromDOM(dom_schema) self.json = dict(type="schema") self._prefixmap = PrefixMap(self.schema, dom_schema) self._exclude_prefixes = self.schema.exclude_prefixes.split(' ') + [ 'xml', 'xmlns' ] self.shex_schema()