|
4 | 4 | from pydantic import AnyUrl, BaseModel |
5 | 5 | from rdflib import Graph, Literal, URIRef |
6 | 6 |
|
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 |
8 | 9 | from hsmodels.schemas.aggregations import ( |
9 | 10 | FileSetMetadata, |
10 | 11 | GeographicFeatureMetadata, |
@@ -81,10 +82,27 @@ def parse_file(schema, file, file_format='xml', subject=None): |
81 | 82 |
|
82 | 83 |
|
83 | 84 | 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) |
84 | 102 | for rdf_schema, user_schema in user_schemas.items(): |
85 | 103 | 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) |
88 | 106 |
|
89 | 107 |
|
90 | 108 | def rdf_string(schema, rdf_format='pretty-xml'): |
|
0 commit comments