lutaml-model 0.8.4 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-tests.yml +5 -0
  3. data/.rubocop.yml +18 -0
  4. data/.rubocop_todo.yml +91 -22
  5. data/Gemfile +2 -0
  6. data/README.adoc +114 -2
  7. data/docs/_guides/index.adoc +18 -0
  8. data/docs/_guides/jsonld-serialization.adoc +217 -0
  9. data/docs/_guides/rdf-serialization.adoc +344 -0
  10. data/docs/_guides/turtle-serialization.adoc +224 -0
  11. data/docs/_migrations/0-8-0-namespace-restructuring.adoc +90 -0
  12. data/docs/_pages/serialization_adapters.adoc +31 -0
  13. data/docs/_references/index.adoc +1 -0
  14. data/docs/_references/rdf-namespaces.adoc +243 -0
  15. data/docs/index.adoc +3 -2
  16. data/lib/lutaml/jsonld/adapter.rb +23 -0
  17. data/lib/lutaml/jsonld/context.rb +69 -0
  18. data/lib/lutaml/jsonld/term_definition.rb +39 -0
  19. data/lib/lutaml/jsonld/transform.rb +174 -0
  20. data/lib/lutaml/jsonld.rb +23 -0
  21. data/lib/lutaml/model/format_registry.rb +10 -1
  22. data/lib/lutaml/model/serialize/format_conversion.rb +17 -1
  23. data/lib/lutaml/model/version.rb +1 -1
  24. data/lib/lutaml/model.rb +6 -0
  25. data/lib/lutaml/rdf/error.rb +7 -0
  26. data/lib/lutaml/rdf/iri.rb +44 -0
  27. data/lib/lutaml/rdf/language_tagged.rb +11 -0
  28. data/lib/lutaml/rdf/literal.rb +62 -0
  29. data/lib/lutaml/rdf/mapping.rb +71 -0
  30. data/lib/lutaml/rdf/mapping_rule.rb +35 -0
  31. data/lib/lutaml/rdf/member_rule.rb +13 -0
  32. data/lib/lutaml/rdf/namespace.rb +58 -0
  33. data/lib/lutaml/rdf/namespace_set.rb +69 -0
  34. data/lib/lutaml/rdf/namespaces/dcterms_namespace.rb +12 -0
  35. data/lib/lutaml/rdf/namespaces/owl_namespace.rb +12 -0
  36. data/lib/lutaml/rdf/namespaces/rdf_namespace.rb +14 -0
  37. data/lib/lutaml/rdf/namespaces/rdfs_namespace.rb +12 -0
  38. data/lib/lutaml/rdf/namespaces/skos_namespace.rb +12 -0
  39. data/lib/lutaml/rdf/namespaces/xsd_namespace.rb +12 -0
  40. data/lib/lutaml/rdf/namespaces.rb +14 -0
  41. data/lib/lutaml/rdf/transform.rb +36 -0
  42. data/lib/lutaml/rdf.rb +19 -0
  43. data/lib/lutaml/turtle/adapter.rb +35 -0
  44. data/lib/lutaml/turtle/mapping.rb +7 -0
  45. data/lib/lutaml/turtle/transform.rb +158 -0
  46. data/lib/lutaml/turtle.rb +22 -0
  47. data/lib/lutaml/xml/adapter/adapter_helpers.rb +1 -42
  48. data/lib/lutaml/xml/adapter/base_adapter.rb +48 -458
  49. data/lib/lutaml/xml/adapter/namespace_data.rb +0 -17
  50. data/lib/lutaml/xml/adapter/namespace_uri_collector.rb +71 -0
  51. data/lib/lutaml/xml/adapter/nokogiri_adapter.rb +5 -1110
  52. data/lib/lutaml/xml/adapter/oga_adapter.rb +6 -846
  53. data/lib/lutaml/xml/adapter/ox_adapter.rb +7 -884
  54. data/lib/lutaml/xml/adapter/plan_based_builder.rb +929 -0
  55. data/lib/lutaml/xml/adapter/rexml_adapter.rb +10 -864
  56. data/lib/lutaml/xml/adapter/xml_parser.rb +86 -0
  57. data/lib/lutaml/xml/adapter/xml_serializer.rb +291 -0
  58. data/lib/lutaml/xml/adapter.rb +0 -1
  59. data/lib/lutaml/xml/adapter_element.rb +7 -1
  60. data/lib/lutaml/xml/builder/base.rb +0 -1
  61. data/lib/lutaml/xml/data_model.rb +9 -1
  62. data/lib/lutaml/xml/document.rb +3 -1
  63. data/lib/lutaml/xml/element.rb +13 -10
  64. data/lib/lutaml/xml/serialization/format_conversion.rb +19 -42
  65. data/lib/lutaml/xml/serialization/instance_methods.rb +26 -35
  66. data/lib/lutaml/xml/transformation/custom_method_wrapper.rb +34 -55
  67. data/lib/lutaml/xml/transformation/rule_applier.rb +1 -1
  68. data/lib/lutaml/xml/xml_element.rb +24 -20
  69. data/spec/lutaml/integration/edge_cases_spec.rb +109 -0
  70. data/spec/lutaml/integration/multi_format_spec.rb +106 -0
  71. data/spec/lutaml/integration/round_trip_spec.rb +170 -0
  72. data/spec/lutaml/jsonld/adapter_spec.rb +46 -0
  73. data/spec/lutaml/jsonld/context_spec.rb +114 -0
  74. data/spec/lutaml/jsonld/term_definition_spec.rb +55 -0
  75. data/spec/lutaml/jsonld/transform_spec.rb +211 -0
  76. data/spec/lutaml/rdf/graph_serialization_spec.rb +137 -0
  77. data/spec/lutaml/rdf/iri_spec.rb +73 -0
  78. data/spec/lutaml/rdf/literal_spec.rb +98 -0
  79. data/spec/lutaml/rdf/mapping_spec.rb +164 -0
  80. data/spec/lutaml/rdf/member_rule_spec.rb +17 -0
  81. data/spec/lutaml/rdf/namespace_set_spec.rb +115 -0
  82. data/spec/lutaml/rdf/namespace_spec.rb +241 -0
  83. data/spec/lutaml/rdf/rdf_transform_spec.rb +82 -0
  84. data/spec/lutaml/turtle/adapter_spec.rb +47 -0
  85. data/spec/lutaml/turtle/mapping_spec.rb +123 -0
  86. data/spec/lutaml/turtle/transform_spec.rb +273 -0
  87. data/spec/lutaml/xml/adapter/base_adapter_regression_spec.rb +151 -0
  88. data/spec/lutaml/xml/adapter/order_spec.rb +150 -0
  89. data/spec/lutaml/xml/clear_parse_state_spec.rb +139 -0
  90. data/spec/lutaml/xml/doubly_defined_namespace_spec.rb +0 -2
  91. data/spec/lutaml/xml/schema/compiler_spec.rb +75 -69
  92. data/spec/lutaml/xml/transformation/custom_method_wrapper_spec.rb +213 -14
  93. metadata +58 -3
  94. data/lib/lutaml/xml/adapter/xml_serialization.rb +0 -145
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c512d678682ea756cb7eb7a3d439a7d511b763405936e598900f42f7f07aa705
4
- data.tar.gz: e6623585797f809090619a9e6268e026773d962cac0f940ccae608627d8e714c
3
+ metadata.gz: c356719b1c0c3434ba1acb3f59be81cb9374403c8020710ee4d4a5ea78748765
4
+ data.tar.gz: ac2aa51ef80ce8db3c50b8055df95b6a3732e3e40b72689c635e8ac22fe889f2
5
5
  SHA512:
6
- metadata.gz: 81558e237a6a7f55c3defee45c8fa8a1d59bf75a875159708065ce8db44308fdaa17d3c727d6ff1074477391ec199008088221f54d5bbb7f2b3b4546ff4d25cf
7
- data.tar.gz: 242730ac59628f328fe07409cc54d7798e75b40d29b6b47ad7382de37a033d9f907d0578d8ab950c45c9ff1b06cd67f6cb98e3e6215948149e63e8e4591be15d
6
+ metadata.gz: b63ac862dc2eeef4a599ff5ada8c6f2434b3bf71187b5813a2637e69f25170692d373bffb2b9413b48323b1cd6161a8529a2ec6582a2fc313d46c95fa8b67088
7
+ data.tar.gz: 24e23bdedad47cc0796cff0bad1b32809c649bad4a13a64b23d08b3bef2dad4c769cfc299cdb85abeffd9a53ea677c41f91c759114f320a5047787cafc6c253e
@@ -22,3 +22,8 @@ jobs:
22
22
  uses: metanorma/ci/.github/workflows/dependent-rake.yml@main
23
23
  with:
24
24
  command: bundle exec rspec
25
+ setup-tools: 'inkscape,ghostscript,exiftool,ffmpeg,imagemagick'
26
+ after-setup-ruby: |
27
+ if [ -f frontend/package.json ]; then cd frontend && npm install && npm run build; fi
28
+ secrets:
29
+ pat_token: ${{ secrets.LUTAML_CI_PAT_TOKEN }}
data/.rubocop.yml CHANGED
@@ -24,3 +24,21 @@ Style/OneClassPerFile:
24
24
  - Exclude
25
25
  Exclude:
26
26
  - 'spec/**/*'
27
+
28
+ RSpec/EmptyExampleGroup:
29
+ inherit_mode:
30
+ merge:
31
+ - Exclude
32
+ Exclude:
33
+ - 'spec/lutaml/jsonld/transform_spec.rb'
34
+
35
+ RSpec/NamedSubject:
36
+ inherit_mode:
37
+ merge:
38
+ - Exclude
39
+ Exclude:
40
+ - 'spec/lutaml/turtle/transform_spec.rb'
41
+
42
+ RSpec/ContextMethod:
43
+ Exclude:
44
+ - 'spec/lutaml/jsonld/transform_spec.rb'
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-05-06 04:21:39 UTC using RuboCop version 1.86.0.
3
+ # on 2026-05-13 07:30:26 UTC using RuboCop version 1.86.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -11,13 +11,67 @@ Gemspec/RequiredRubyVersion:
11
11
  Exclude:
12
12
  - 'lutaml-model.gemspec'
13
13
 
14
- # Offense count: 3232
14
+ # Offense count: 4
15
+ # This cop supports safe autocorrection (--autocorrect).
16
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
17
+ # SupportedStyles: with_first_argument, with_fixed_indentation
18
+ Layout/ArgumentAlignment:
19
+ Exclude:
20
+ - 'lib/lutaml/xml/adapter/plan_based_builder.rb'
21
+ - 'lib/lutaml/xml/adapter/xml_parser.rb'
22
+ - 'lib/lutaml/xml/serialization/instance_methods.rb'
23
+ - 'spec/lutaml/xml/schema/compiler_spec.rb'
24
+
25
+ # Offense count: 1
26
+ # This cop supports safe autocorrection (--autocorrect).
27
+ # Configuration parameters: IndentationWidth.
28
+ Layout/AssignmentIndentation:
29
+ Exclude:
30
+ - 'lib/lutaml/xml/adapter/xml_serializer.rb'
31
+
32
+ # Offense count: 3
33
+ # This cop supports safe autocorrection (--autocorrect).
34
+ # Configuration parameters: EnforcedStyleAlignWith.
35
+ # SupportedStylesAlignWith: either, start_of_block, start_of_line
36
+ Layout/BlockAlignment:
37
+ Exclude:
38
+ - 'lib/lutaml/xml/serialization/format_conversion.rb'
39
+ - 'lib/lutaml/xml/xml_element.rb'
40
+
41
+ # Offense count: 3
42
+ # This cop supports safe autocorrection (--autocorrect).
43
+ Layout/BlockEndNewline:
44
+ Exclude:
45
+ - 'lib/lutaml/xml/serialization/format_conversion.rb'
46
+ - 'lib/lutaml/xml/xml_element.rb'
47
+
48
+ # Offense count: 6
49
+ # This cop supports safe autocorrection (--autocorrect).
50
+ # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
51
+ # SupportedStylesAlignWith: start_of_line, relative_to_receiver
52
+ Layout/IndentationWidth:
53
+ Exclude:
54
+ - 'lib/lutaml/xml/serialization/format_conversion.rb'
55
+ - 'lib/lutaml/xml/xml_element.rb'
56
+
57
+ # Offense count: 2981
15
58
  # This cop supports safe autocorrection (--autocorrect).
16
59
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
17
60
  # URISchemes: http, https
18
61
  Layout/LineLength:
19
62
  Enabled: false
20
63
 
64
+ # Offense count: 5
65
+ # This cop supports safe autocorrection (--autocorrect).
66
+ # Configuration parameters: AllowInHeredoc.
67
+ Layout/TrailingWhitespace:
68
+ Exclude:
69
+ - 'lib/lutaml/xml/adapter/plan_based_builder.rb'
70
+ - 'lib/lutaml/xml/adapter/xml_parser.rb'
71
+ - 'lib/lutaml/xml/adapter/xml_serializer.rb'
72
+ - 'lib/lutaml/xml/serialization/instance_methods.rb'
73
+ - 'spec/lutaml/xml/schema/compiler_spec.rb'
74
+
21
75
  # Offense count: 21
22
76
  # Configuration parameters: AllowedMethods.
23
77
  # AllowedMethods: enums
@@ -96,13 +150,12 @@ Lint/StructNewOverride:
96
150
  Exclude:
97
151
  - 'lib/lutaml/model/import_registry.rb'
98
152
 
99
- # Offense count: 15
153
+ # Offense count: 14
100
154
  # This cop supports safe autocorrection (--autocorrect).
101
155
  # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
102
156
  # NotImplementedExceptions: NotImplementedError
103
157
  Lint/UnusedMethodArgument:
104
158
  Exclude:
105
- - 'lib/lutaml/xml/adapter/nokogiri_adapter.rb'
106
159
  - 'lib/lutaml/xml/declaration_planner.rb'
107
160
  - 'lib/lutaml/xml/mapping.rb'
108
161
  - 'lib/lutaml/xml/namespace_collector.rb'
@@ -110,45 +163,44 @@ Lint/UnusedMethodArgument:
110
163
  - 'lib/lutaml/xml/unqualified_inheritance_strategy.rb'
111
164
  - 'spec/support/xml/xsd/code_example_validator.rb'
112
165
 
113
- # Offense count: 3
166
+ # Offense count: 1
114
167
  Lint/UselessConstantScoping:
115
168
  Exclude:
116
- - 'lib/lutaml/xml/adapter/nokogiri_adapter.rb'
117
169
  - 'lib/lutaml/xml/mapping_rule.rb'
118
170
 
119
- # Offense count: 346
171
+ # Offense count: 342
120
172
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
121
173
  Metrics/AbcSize:
122
174
  Enabled: false
123
175
 
124
- # Offense count: 54
176
+ # Offense count: 39
125
177
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
126
178
  # AllowedMethods: refine
127
179
  Metrics/BlockLength:
128
180
  Max: 127
129
181
 
130
- # Offense count: 20
182
+ # Offense count: 16
131
183
  # Configuration parameters: CountBlocks, CountModifierForms.
132
184
  Metrics/BlockNesting:
133
185
  Max: 6
134
186
 
135
- # Offense count: 309
187
+ # Offense count: 300
136
188
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
137
189
  Metrics/CyclomaticComplexity:
138
190
  Enabled: false
139
191
 
140
- # Offense count: 562
192
+ # Offense count: 549
141
193
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
142
194
  Metrics/MethodLength:
143
195
  Max: 514
144
196
 
145
- # Offense count: 86
197
+ # Offense count: 81
146
198
  # Configuration parameters: CountKeywordArgs.
147
199
  Metrics/ParameterLists:
148
200
  Max: 24
149
201
  MaxOptionalParameters: 5
150
202
 
151
- # Offense count: 260
203
+ # Offense count: 251
152
204
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
153
205
  Metrics/PerceivedComplexity:
154
206
  Enabled: false
@@ -240,7 +292,7 @@ RSpec/BeforeAfterAll:
240
292
  RSpec/ContextWording:
241
293
  Enabled: false
242
294
 
243
- # Offense count: 88
295
+ # Offense count: 94
244
296
  # Configuration parameters: IgnoredMetadata.
245
297
  RSpec/DescribeClass:
246
298
  Enabled: false
@@ -251,7 +303,7 @@ RSpec/DescribeMethod:
251
303
  - 'spec/lutaml/xml/schema/xsd/schema_helper_methods_spec.rb'
252
304
  - 'spec/lutaml/xml/serializable_namespace_spec.rb'
253
305
 
254
- # Offense count: 1207
306
+ # Offense count: 1238
255
307
  # Configuration parameters: CountAsOne.
256
308
  RSpec/ExampleLength:
257
309
  Max: 68
@@ -326,7 +378,7 @@ RSpec/MultipleDescribes:
326
378
  - 'spec/lutaml/xml/namespace_resolution_strategy_spec.rb'
327
379
  - 'spec/lutaml/xml/xml_space_type_spec.rb'
328
380
 
329
- # Offense count: 1383
381
+ # Offense count: 1468
330
382
  RSpec/MultipleExpectations:
331
383
  Max: 21
332
384
 
@@ -350,7 +402,7 @@ RSpec/NoExpectationExample:
350
402
  - 'spec/lutaml/model/global_context_spec.rb'
351
403
  - 'spec/lutaml/model/type_context_spec.rb'
352
404
 
353
- # Offense count: 11
405
+ # Offense count: 10
354
406
  RSpec/RemoveConst:
355
407
  Exclude:
356
408
  - 'spec/lutaml/xml/schema/compiler_spec.rb'
@@ -374,7 +426,7 @@ RSpec/RepeatedExampleGroupDescription:
374
426
  Exclude:
375
427
  - 'spec/lutaml/model/mixed_content_spec.rb'
376
428
 
377
- # Offense count: 35
429
+ # Offense count: 40
378
430
  # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
379
431
  # SupportedInflectors: default, active_support
380
432
  RSpec/SpecFilePathFormat:
@@ -399,6 +451,18 @@ Security/MarshalLoad:
399
451
  Exclude:
400
452
  - 'scripts-xmi-profile/profile_xmi.rb'
401
453
 
454
+ # Offense count: 4
455
+ # This cop supports safe autocorrection (--autocorrect).
456
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
457
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
458
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
459
+ # FunctionalMethods: let, let!, subject, watch
460
+ # AllowedMethods: lambda, proc, it
461
+ Style/BlockDelimiters:
462
+ Exclude:
463
+ - 'lib/lutaml/xml/serialization/format_conversion.rb'
464
+ - 'lib/lutaml/xml/xml_element.rb'
465
+
402
466
  # Offense count: 2
403
467
  # This cop supports unsafe autocorrection (--autocorrect-all).
404
468
  # Configuration parameters: AllowedMethods, AllowedPatterns.
@@ -408,7 +472,7 @@ Style/ClassEqualityComparison:
408
472
  - 'lib/lutaml/model/attribute.rb'
409
473
  - 'lib/lutaml/model/validation/profile.rb'
410
474
 
411
- # Offense count: 13
475
+ # Offense count: 7
412
476
  # This cop supports safe autocorrection (--autocorrect).
413
477
  # Configuration parameters: EnforcedStyle, AllowComments.
414
478
  # SupportedStyles: empty, nil, both
@@ -417,9 +481,6 @@ Style/EmptyElse:
417
481
  - 'lib/lutaml/key_value/data_model/element.rb'
418
482
  - 'lib/lutaml/key_value/transformation.rb'
419
483
  - 'lib/lutaml/model/mapping/mapping_rule.rb'
420
- - 'lib/lutaml/xml/adapter/nokogiri_adapter.rb'
421
- - 'lib/lutaml/xml/adapter/oga_adapter.rb'
422
- - 'lib/lutaml/xml/adapter/ox_adapter.rb'
423
484
  - 'lib/lutaml/xml/declaration_planner.rb'
424
485
  - 'lib/lutaml/xml/model_transform.rb'
425
486
 
@@ -447,6 +508,14 @@ Style/MixinUsage:
447
508
  - 'bench/bench_unitsml.rb'
448
509
  - 'bench/bench_xmi.rb'
449
510
 
511
+ # Offense count: 3
512
+ # This cop supports safe autocorrection (--autocorrect).
513
+ Style/MultilineIfModifier:
514
+ Exclude:
515
+ - 'lib/lutaml/xml/adapter/xml_parser.rb'
516
+ - 'lib/lutaml/xml/adapter/xml_serializer.rb'
517
+ - 'spec/lutaml/xml/schema/compiler_spec.rb'
518
+
450
519
  # Offense count: 12
451
520
  # Configuration parameters: AllowedClasses.
452
521
  Style/OneClassPerFile:
data/Gemfile CHANGED
@@ -12,6 +12,7 @@ gem "base64"
12
12
  gem "benchmark-ips"
13
13
  gem "bigdecimal"
14
14
  gem "canon" # , path: "../canon"
15
+ gem "json-ld", "~> 3.3"
15
16
  gem "liquid", "~> 5"
16
17
  gem "multi_json"
17
18
  gem "nokogiri"
@@ -20,6 +21,7 @@ gem "oj"
20
21
  gem "openssl", "~> 3.0"
21
22
  gem "ox"
22
23
  gem "rake"
24
+ gem "rdf-turtle", "~> 3.3"
23
25
  gem "rexml"
24
26
  gem "rspec"
25
27
  gem "rubocop"
data/README.adoc CHANGED
@@ -27,7 +27,7 @@ for:
27
27
 
28
28
  It provides simple, flexible and comprehensive mechanisms for defining
29
29
  information models with attributes and types, and the serialization of them
30
- to/from serialization formats including JSON, XML, YAML, and TOML, as well as
30
+ to/from serialization formats including JSON, XML, YAML, TOML, JSON-LD, and Turtle, as well as
31
31
  transformation to other formats like Hash.
32
32
 
33
33
  For serialization formats, it uses an adapter pattern to support multiple
@@ -48,7 +48,7 @@ link:docs/migration-guides/0-1-0-migrate-from-shale.adoc[Migrating from Shale to
48
48
  == Features
49
49
 
50
50
  * Define models with attributes and types
51
- * Serialize and deserialize models to/from JSON, XML, YAML, and TOML
51
+ * Serialize and deserialize models to/from JSON, XML, YAML, TOML, JSON-LD, and Turtle
52
52
  * Transform models to other formats like Hash
53
53
  * Support for multiple serialization libraries (e.g., `toml-rb`, `tomlib`)
54
54
  * Configurable adapters for different serialization formats
@@ -65,6 +65,7 @@ link:docs/migration-guides/0-1-0-migrate-from-shale.adoc[Migrating from Shale to
65
65
  * Symmetric OOP architecture for all formats with KeyValueDataModel (see <<keyvaluedatamodel-architecture>>)
66
66
  * Parse XSD schemas into Ruby objects for inspection and manipulation (see <<xsd-schema-parsing>>)
67
67
  * Reusable XML mapping classes for sharing mappings across models
68
+ * RDF namespace classes and JSON-LD/Turtle format adapters for Linked Data serialization
68
69
  * Consolidation mapping: group sibling XML elements into structured model instances (see <<consolidation-mapping>>)
69
70
  * Document-level validation framework with composable rules, profiles, and remediation (see <<document-validation-framework>>)
70
71
 
@@ -5391,6 +5392,11 @@ Collection serialization formats::
5391
5392
  `jsonl`::: JSONL (JSON Lines) (see <<mapping-collections>>)
5392
5393
  `yamls`::: YAML Stream (multi-document format) (see <<mapping-collections>>)
5393
5394
 
5395
+ RDF serialization formats::
5396
+
5397
+ `rdf`::: Unified RDF mapping for both JSON-LD and Turtle (see <<mapping-rdf>>)
5398
+ `turtle`::: Turtle (see link:docs/_guides/turtle-serialization.adoc[Turtle Serialization])
5399
+
5394
5400
 
5395
5401
  .Using the `xml`, `hsh`, `json`, `yaml`, `toml` and `key_value` blocks to define serialization mappings
5396
5402
  [example]
@@ -5439,6 +5445,73 @@ end
5439
5445
  ====
5440
5446
 
5441
5447
 
5448
+ [[mapping-rdf]]
5449
+ === Unified RDF mapping (`rdf`)
5450
+
5451
+ The `rdf` block defines predicate-based mappings once for both JSON-LD and
5452
+ Turtle serialization. It follows the same unified-mapping principle as
5453
+ `key_value` (which serves JSON, YAML, TOML).
5454
+
5455
+ .Using the `rdf` block to define unified RDF mappings
5456
+ [example]
5457
+ ====
5458
+ [source,ruby]
5459
+ ----
5460
+ class Concept < Lutaml::Model::Serializable
5461
+ attribute :code, :string
5462
+ attribute :name, :string
5463
+
5464
+ rdf do
5465
+ namespace SkosNamespace
5466
+
5467
+ subject { |m| "http://example.org/concept/#{m.code}" }
5468
+ type "skos:Concept"
5469
+
5470
+ predicate :notation, namespace: SkosNamespace, to: :code
5471
+ predicate :prefLabel, namespace: SkosNamespace, to: :name
5472
+ end
5473
+ end
5474
+ ----
5475
+
5476
+ Serializes to both formats:
5477
+
5478
+ [source,ruby]
5479
+ ----
5480
+ concept = Concept.new(code: "2119", name: "component")
5481
+ concept.to_turtle # => Turtle with @prefix, a skos:Concept, predicates
5482
+ concept.to_jsonld # => JSON-LD with @context, @type, @id, properties
5483
+ ----
5484
+ ====
5485
+
5486
+ Graph-level serialization uses `members` to emit all contained resources as
5487
+ separate subjects in the same document:
5488
+
5489
+ [source,ruby]
5490
+ ----
5491
+ class Vocabulary < Lutaml::Model::Serializable
5492
+ attribute :id, :string
5493
+ attribute :concepts, Concept, collection: true
5494
+
5495
+ rdf do
5496
+ namespace SkosNamespace
5497
+ subject { |v| "http://example.org/vocab/#{v.id}" }
5498
+ type "skos:ConceptScheme"
5499
+ predicate :prefLabel, namespace: SkosNamespace, to: :id
5500
+ members :concepts
5501
+ end
5502
+ end
5503
+
5504
+ # Turtle: single document with ConceptScheme + all Concept triples
5505
+ # JSON-LD: @graph array with ConceptScheme + all Concept objects
5506
+ vocab.to_turtle
5507
+ vocab.to_jsonld
5508
+ ----
5509
+
5510
+ See link:docs/_guides/rdf-serialization.adoc[Unified RDF Serialization] for the
5511
+ complete guide including language-tagged values, graph serialization, and
5512
+ architecture details.
5513
+
5514
+
5442
5515
  == Serialization: XML
5443
5516
 
5444
5517
  === General
@@ -10100,8 +10173,14 @@ Key-value data models supported are identified by their short name:
10100
10173
  `json`:: JSON
10101
10174
  `yaml`:: YAML
10102
10175
  `toml`:: TOML
10176
+ `jsonld`:: JSON-LD (extends key-value with `@context`, `@type`, `@id`)
10103
10177
  `key_value`:: A way to configure key-value mappings for all supported key-value data models.
10104
10178
 
10179
+ RDF serialization formats::
10180
+
10181
+ `rdf`:: Unified RDF mapping for both JSON-LD and Turtle (see <<mapping-rdf>>)
10182
+ `turtle`:: Turtle (see link:docs/_guides/turtle-serialization.adoc[Turtle Serialization])
10183
+
10105
10184
 
10106
10185
  === Mapping
10107
10186
 
@@ -15735,6 +15814,8 @@ LutaML, out of the box, supports the following serialization formats:
15735
15814
  * YAML (https://yaml.org/[YAML version 1.2])
15736
15815
  * JSON (https://www.ecma-international.org/publications-and-standards/standards/ecma-404/[ECMA-404 The JSON Data Interchange Standard], unofficial link: https://www.json.org[JSON])
15737
15816
  * TOML (https://toml.io/en[TOML version 1.0])
15817
+ * JSON-LD (https://www.w3.org/TR/json-ld11/[W3C JSON-LD 1.1])
15818
+ * Turtle (https://www.w3.org/TR/turtle/[W3C RDF 1.1 Turtle])
15738
15819
 
15739
15820
  The adapter interface is also used to support certain transformation of models
15740
15821
  into an "end format", which is not a serialization format. For example, the
@@ -15977,6 +16058,37 @@ end
15977
16058
  ----
15978
16059
 
15979
16060
 
16061
+ === JSON-LD
16062
+
16063
+ Lutaml::Model supports serialization to and from JSON-LD (W3C JSON-LD 1.1).
16064
+ JSON-LD is a key-value format that extends JSON with `@context`, `@type`, and
16065
+ `@id`. No additional gem is required beyond `lutaml-model`.
16066
+
16067
+ For unified RDF mapping (both JSON-LD and Turtle from a single `rdf` block), see
16068
+ link:docs/_guides/rdf-serialization.adoc[Unified RDF Serialization].
16069
+
16070
+ See link:docs/_guides/jsonld-serialization.adoc[JSON-LD Serialization] for the
16071
+ legacy `jsonld do` block DSL and usage examples.
16072
+
16073
+
16074
+ === Turtle
16075
+
16076
+ Lutaml::Model supports serialization to and from W3C RDF Turtle format.
16077
+ Turtle is a non-key-value format based on RDF triples. Requires the
16078
+ `rdf-turtle` gem:
16079
+
16080
+ [source,ruby]
16081
+ ----
16082
+ gem "rdf-turtle", "~> 3.3"
16083
+ ----
16084
+
16085
+ For unified RDF mapping (both JSON-LD and Turtle from a single `rdf` block), see
16086
+ link:docs/_guides/rdf-serialization.adoc[Unified RDF Serialization].
16087
+
16088
+ See link:docs/_guides/turtle-serialization.adoc[Turtle Serialization] for the
16089
+ legacy `turtle do` block DSL and usage examples.
16090
+
16091
+
15980
16092
  === Per-operation adapter override
15981
16093
 
15982
16094
  Override the adapter for a single serialization/deserialization call using the `adapter:` option:
@@ -22,6 +22,17 @@ Task-oriented guides for accomplishing specific goals with Lutaml::Model.
22
22
  * link:../keyvalue-serialization[Key-Value Serialization] - JSON/YAML/TOML/Hash
23
23
  * link:../collection-serialization[Collection Serialization] - JSONL and YAML Stream
24
24
 
25
+ == Linked Data serialization
26
+
27
+ * link:../rdf-serialization[Unified RDF Serialization] - One `rdf` block for both JSON-LD and Turtle
28
+ * link:../jsonld-serialization[JSON-LD Serialization] - W3C JSON-LD 1.1 with `@context`
29
+ * link:../turtle-serialization[Turtle Serialization] - W3C RDF Turtle format
30
+
31
+ == RDF infrastructure
32
+
33
+ See link:../references/rdf-namespaces[RDF Namespaces] for namespace classes,
34
+ `NamespaceSet`, `Iri`, and `Literal` value objects.
35
+
25
36
  == Advanced features
26
37
 
27
38
  * link:../value-transformations[Value Transformations] - Transform values during serialization
@@ -49,6 +60,13 @@ Task-oriented guides for accomplishing specific goals with Lutaml::Model.
49
60
  . link:../value-transformations[Transform values if needed]
50
61
  . link:../missing-values-handling[Handle nil/empty values]
51
62
 
63
+ === I want to serialize to JSON-LD or Turtle (Linked Data)
64
+
65
+ . link:../rdf-serialization[Unified RDF Serialization] (recommended — one block for both formats)
66
+ . link:../jsonld-serialization[JSON-LD Serialization guide] (legacy `jsonld do` block)
67
+ . link:../turtle-serialization[Turtle Serialization guide] (legacy `turtle do` block)
68
+ . link:../references/rdf-namespaces[RDF Namespaces reference]
69
+
52
70
  === I want to work with collections
53
71
 
54
72
  . link:../collection-serialization[Collection Serialization]