@@ -99,7 +99,7 @@ static auto store(sourcemeta::jsontoolkit::FrameLocations &frame,
99
99
const std::string &base_id,
100
100
const sourcemeta::jsontoolkit::Pointer &pointer_from_root,
101
101
const sourcemeta::jsontoolkit::Pointer &pointer_from_base,
102
- const std::string &dialect,
102
+ const std::string &dialect, const std::string &base_dialect,
103
103
const bool ignore_if_present = false ) -> void {
104
104
const auto canonical{
105
105
sourcemeta::jsontoolkit::URI{uri}.canonicalize ().recompose ()};
@@ -111,6 +111,7 @@ static auto store(sourcemeta::jsontoolkit::FrameLocations &frame,
111
111
pointer_from_root,
112
112
pointer_from_base,
113
113
dialect,
114
+ base_dialect,
114
115
{}}})
115
116
.second };
116
117
if (!ignore_if_present && !inserted) {
@@ -165,7 +166,8 @@ auto sourcemeta::jsontoolkit::frame(
165
166
store (frame, ReferenceType::Static, FrameLocationType::Resource,
166
167
default_id.value (), root_id.value (), root_id.value (),
167
168
sourcemeta::jsontoolkit::empty_pointer,
168
- sourcemeta::jsontoolkit::empty_pointer, root_dialect.value ());
169
+ sourcemeta::jsontoolkit::empty_pointer, root_dialect.value (),
170
+ root_base_dialect.value ());
169
171
base_uris.insert (
170
172
{sourcemeta::jsontoolkit::empty_pointer, {default_id.value ()}});
171
173
}
@@ -224,10 +226,12 @@ auto sourcemeta::jsontoolkit::frame(
224
226
225
227
if (!maybe_relative_is_absolute ||
226
228
!frame.contains ({ReferenceType::Static, new_id})) {
229
+ assert (entry.common .base_dialect .has_value ());
227
230
store (frame, ReferenceType::Static, FrameLocationType::Resource,
228
231
new_id, root_id, new_id, entry.common .pointer ,
229
232
sourcemeta::jsontoolkit::empty_pointer,
230
- entry.common .dialect .value ());
233
+ entry.common .dialect .value (),
234
+ entry.common .base_dialect .value ());
231
235
}
232
236
233
237
if (base_uris.contains (entry.common .pointer )) {
@@ -275,23 +279,26 @@ auto sourcemeta::jsontoolkit::frame(
275
279
store (frame, ReferenceType::Static, FrameLocationType::Anchor,
276
280
relative_anchor_uri, root_id, " " , entry.common .pointer ,
277
281
entry.common .pointer .resolve_from (bases.second ),
278
- entry.common .dialect .value ());
282
+ entry.common .dialect .value (),
283
+ entry.common .base_dialect .value ());
279
284
}
280
285
281
286
if (type == sourcemeta::jsontoolkit::AnchorType::Dynamic ||
282
287
type == sourcemeta::jsontoolkit::AnchorType::All) {
283
288
store (frame, ReferenceType::Dynamic, FrameLocationType::Anchor,
284
289
relative_anchor_uri, root_id, " " , entry.common .pointer ,
285
290
entry.common .pointer .resolve_from (bases.second ),
286
- entry.common .dialect .value ());
291
+ entry.common .dialect .value (),
292
+ entry.common .base_dialect .value ());
287
293
288
294
// Register a dynamic anchor as a static anchor if possible too
289
295
if (entry.common .vocabularies .contains (
290
296
" https://json-schema.org/draft/2020-12/vocab/core" )) {
291
297
store (frame, ReferenceType::Static, FrameLocationType::Anchor,
292
298
relative_anchor_uri, root_id, " " , entry.common .pointer ,
293
299
entry.common .pointer .resolve_from (bases.second ),
294
- entry.common .dialect .value (), true );
300
+ entry.common .dialect .value (),
301
+ entry.common .base_dialect .value (), true );
295
302
}
296
303
}
297
304
} else {
@@ -321,7 +328,8 @@ auto sourcemeta::jsontoolkit::frame(
321
328
FrameLocationType::Anchor, anchor_uri, root_id, base_string,
322
329
entry.common .pointer ,
323
330
entry.common .pointer .resolve_from (bases.second ),
324
- entry.common .dialect .value ());
331
+ entry.common .dialect .value (),
332
+ entry.common .base_dialect .value ());
325
333
}
326
334
327
335
if (type == sourcemeta::jsontoolkit::AnchorType::Dynamic ||
@@ -330,7 +338,8 @@ auto sourcemeta::jsontoolkit::frame(
330
338
FrameLocationType::Anchor, anchor_uri, root_id, base_string,
331
339
entry.common .pointer ,
332
340
entry.common .pointer .resolve_from (bases.second ),
333
- entry.common .dialect .value ());
341
+ entry.common .dialect .value (),
342
+ entry.common .base_dialect .value ());
334
343
335
344
// Register a dynamic anchor as a static anchor if possible too
336
345
if (entry.common .vocabularies .contains (
@@ -339,7 +348,8 @@ auto sourcemeta::jsontoolkit::frame(
339
348
FrameLocationType::Anchor, anchor_uri, root_id, base_string,
340
349
entry.common .pointer ,
341
350
entry.common .pointer .resolve_from (bases.second ),
342
- entry.common .dialect .value (), true );
351
+ entry.common .dialect .value (),
352
+ entry.common .base_dialect .value (), true );
343
353
}
344
354
}
345
355
@@ -377,16 +387,26 @@ auto sourcemeta::jsontoolkit::frame(
377
387
const auto nearest_bases{
378
388
find_nearest_bases (base_uris, pointer, base.first )};
379
389
assert (!nearest_bases.first .empty ());
390
+ const auto ¤t_base{nearest_bases.first .front ()};
380
391
if (subschemas.contains (pointer)) {
392
+ auto current_base_dialect{
393
+ base_dialect (get (schema, pointer), resolver, root_dialect)};
394
+ assert (current_base_dialect.has_value ());
381
395
store (frame, ReferenceType::Static, FrameLocationType::Subschema,
382
- result, root_id, nearest_bases. first . front () , pointer,
396
+ result, root_id, current_base , pointer,
383
397
pointer.resolve_from (nearest_bases.second ),
384
- dialects.first .front ());
398
+ dialects.first .front (), current_base_dialect.value ());
399
+ } else if (frame.contains ({ReferenceType::Static, current_base})) {
400
+ store (frame, ReferenceType::Static, FrameLocationType::Pointer,
401
+ result, root_id, current_base, pointer,
402
+ pointer.resolve_from (nearest_bases.second ),
403
+ dialects.first .front (),
404
+ frame.at ({ReferenceType::Static, current_base}).base_dialect );
385
405
} else {
386
406
store (frame, ReferenceType::Static, FrameLocationType::Pointer,
387
- result, root_id, nearest_bases. first . front () , pointer,
407
+ result, root_id, current_base , pointer,
388
408
pointer.resolve_from (nearest_bases.second ),
389
- dialects.first .front ());
409
+ dialects.first .front (), " !!!! TODO " );
390
410
}
391
411
}
392
412
}
0 commit comments