@@ -171,6 +171,7 @@ def add_context(self, newcontext, baseuri=""):
171
171
self .identity_links = set ()
172
172
self .standalone = set ()
173
173
self .nolinkcheck = set ()
174
+ self .idmap = set ()
174
175
self .vocab = {}
175
176
self .rvocab = {}
176
177
@@ -193,6 +194,9 @@ def add_context(self, newcontext, baseuri=""):
193
194
if isinstance (self .ctx [c ], dict ) and self .ctx [c ].get ("noLinkCheck" ):
194
195
self .nolinkcheck .add (c )
195
196
197
+ if isinstance (self .ctx [c ], dict ) and self .ctx [c ].get ("idMap" ):
198
+ self .idmap .add (c )
199
+
196
200
if isinstance (self .ctx [c ], dict ) and "@id" in self .ctx [c ]:
197
201
self .vocab [c ] = self .ctx [c ]["@id" ]
198
202
elif isinstance (self .ctx [c ], basestring ):
@@ -330,6 +334,14 @@ def resolve_all(self, document, base_url, file_base=None):
330
334
metadata , _ = loader .resolve_all (metadata , base_url , file_base )
331
335
332
336
if isinstance (document , dict ):
337
+ for idmapField in loader .idmap :
338
+ if idmapField in document and isinstance (document [idmapField ], dict ):
339
+ ls = []
340
+ for k ,v in document [idmapField ].items ():
341
+ v ["id" ] = k
342
+ ls .append (v )
343
+ document [idmapField ] = ls
344
+
333
345
for identifer in loader .identity_links :
334
346
if identifer in document :
335
347
if isinstance (document [identifer ], basestring ):
0 commit comments