Skip to content

Commit 1e084a7

Browse files
committed
set contexts, we won't keep this commit
1 parent 4b2988a commit 1e084a7

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

hsmodels/schemas/__init__.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from pydantic import AnyUrl, BaseModel
55
from rdflib import Graph, Literal, URIRef
66

7-
from hsmodels.namespaces import DC, HSTERMS, ORE, RDF, RDFS1
7+
from hsmodels.namespaces import DC, HSTERMS, ORE, RDF, RDFS1, HSRESOURCE, DCTERMS, SCHEMA, XML, RDFS, CITOTERMS, XSD, \
8+
SH, FOAF, DASH, HSUSER
89
from hsmodels.schemas.aggregations import (
910
FileSetMetadata,
1011
GeographicFeatureMetadata,
@@ -81,10 +82,27 @@ def parse_file(schema, file, file_format='xml', subject=None):
8182

8283

8384
def rdf_graph(schema):
85+
g = Graph()
86+
g.bind('hsresource', HSRESOURCE)
87+
g.bind('dcterms', DCTERMS)
88+
g.bind('rdfs1', RDFS1)
89+
g.bind('schema', SCHEMA)
90+
g.bind('hsterms', HSTERMS)
91+
g.bind('xml', XML)
92+
g.bind('rdfs', RDFS)
93+
g.bind('dc', DC)
94+
g.bind('citoterms', CITOTERMS)
95+
g.bind('xsd', XSD)
96+
g.bind('sh', SH)
97+
g.bind('rdf', RDF)
98+
g.bind('foaf', FOAF)
99+
g.bind('dash', DASH)
100+
g.bind('ORE', ORE)
101+
g.bind('hsuser', HSUSER)
84102
for rdf_schema, user_schema in user_schemas.items():
85103
if isinstance(schema, user_schema):
86-
return _rdf_graph(rdf_schema(**schema.dict(to_rdf=True)), Graph())
87-
return _rdf_graph(schema, Graph())
104+
return _rdf_graph(rdf_schema(**schema.dict(to_rdf=True)), g)
105+
return _rdf_graph(schema, g)
88106

89107

90108
def rdf_string(schema, rdf_format='pretty-xml'):

0 commit comments

Comments
 (0)