moxml 0.5.149 → 0.5.150

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-repos.json +7 -2
  3. data/.github/workflows/dependent-tests.yml +4 -1
  4. data/.github/workflows/performance-release.yml +79 -0
  5. data/.github/workflows/performance.yml +59 -0
  6. data/Rakefile +23 -0
  7. data/benchmark/README.md +106 -0
  8. data/benchmark/scoreboard.json +115 -0
  9. data/benchmark/scoreboard.rb +556 -0
  10. data/bin/generate-model-coverage +21 -0
  11. data/docs/_pages/adapter-compatibility.adoc +3 -3
  12. data/docs/_pages/divergences.adoc +32 -41
  13. data/docs/_pages/ecosystem.adoc +62 -0
  14. data/docs/_pages/headed-ox-limitations.adoc +1 -1
  15. data/docs/_pages/headed-ox.adoc +2 -2
  16. data/docs/_pages/index.adoc +4 -0
  17. data/docs/_pages/model-coverage.adoc +57 -0
  18. data/docs/_pages/performance.adoc +29 -0
  19. data/docs/_pages/why-moxml.adoc +87 -0
  20. data/docs/_references/processing-model.adoc +42 -3
  21. data/lib/moxml/adapter/base.rb +73 -0
  22. data/lib/moxml/adapter/leptris.rb +183 -4
  23. data/lib/moxml/adapter/libxml.rb +34 -2
  24. data/lib/moxml/adapter/nokogiri.rb +10 -0
  25. data/lib/moxml/adapter/oga.rb +39 -7
  26. data/lib/moxml/adapter/ox.rb +8 -0
  27. data/lib/moxml/adapter/rexml.rb +17 -2
  28. data/lib/moxml/c14n/data_model.rb +8 -0
  29. data/lib/moxml/c14n/processor.rb +17 -8
  30. data/lib/moxml/context.rb +28 -0
  31. data/lib/moxml/document.rb +17 -3
  32. data/lib/moxml/node.rb +56 -5
  33. data/lib/moxml/node_set.rb +31 -1
  34. data/lib/moxml/relaxng.rb +62 -0
  35. data/lib/moxml/sax/block_handler.rb +7 -0
  36. data/lib/moxml/sax/handler.rb +20 -0
  37. data/lib/moxml/version.rb +1 -1
  38. data/lib/moxml/xpath.rb +28 -0
  39. data/lib/moxml.rb +1 -0
  40. data/spec/consistency/adapter_parity_spec.rb +22 -0
  41. data/spec/consistency/citation_hygiene_spec.rb +30 -0
  42. data/spec/consistency/model_coverage_audit_spec.rb +61 -86
  43. data/spec/consistency/published_docs_spec.rb +49 -0
  44. data/spec/consistency/xpath_idioms_spec.rb +23 -5
  45. data/spec/integration/shared_examples/edge_cases.rb +0 -13
  46. data/spec/moxml/adapter/leptris_spec.rb +23 -3
  47. data/spec/moxml/adapter/shared_examples/adapter_contract.rb +0 -8
  48. data/spec/moxml/attribute_resolver_spec.rb +33 -0
  49. data/spec/moxml/c14n/adapter_delegation_spec.rb +33 -6
  50. data/spec/moxml/c14n/character_encoding_spec.rb +7 -13
  51. data/spec/moxml/c14n/comments_pis_spec.rb +35 -8
  52. data/spec/moxml/c14n/subset_spec.rb +2 -12
  53. data/spec/moxml/c14n/w3c_examples_spec.rb +2 -5
  54. data/spec/moxml/element_indent_spec.rb +34 -0
  55. data/spec/moxml/node_spec.rb +0 -3
  56. data/spec/moxml/relax_ng_spec.rb +67 -0
  57. data/spec/moxml/sax_spec.rb +45 -74
  58. data/spec/moxml/xpath_capabilities_spec.rb +11 -38
  59. data/spec/support/input_taxonomy.rb +7 -0
  60. data/spec/support/model_coverage.rb +159 -0
  61. metadata +17 -2
@@ -81,9 +81,7 @@ RSpec.describe "XPath Capabilities" do
81
81
  it "supports attribute value matching ([@attr='value'])" do
82
82
  doc = Moxml.new.parse(simple_xml)
83
83
  programming = doc.xpath("//book[@category='programming']")
84
- expect(programming.length).to be >= 0 # May not work on all
85
- rescue Moxml::XPathError
86
- skip "D-12: Attribute value predicates not supported on #{adapter_name}"
84
+ expect(programming.length).to eq(1)
87
85
  end
88
86
  end
89
87
 
@@ -96,9 +94,7 @@ RSpec.describe "XPath Capabilities" do
96
94
  }
97
95
 
98
96
  items = doc.xpath("//book:item", namespaces)
99
- expect(items.length).to be >= 0
100
- rescue Moxml::XPathError, NoMethodError
101
- skip "D-12: Namespace XPath not supported on #{adapter_name}"
97
+ expect(items.length).to eq(2)
102
98
  end
103
99
 
104
100
  it "handles default namespaces" do
@@ -106,9 +102,7 @@ RSpec.describe "XPath Capabilities" do
106
102
  namespaces = { "lib" => "http://library.org" }
107
103
 
108
104
  library = doc.xpath("//lib:library", namespaces)
109
- expect(library.length).to be >= 0
110
- rescue Moxml::XPathError, NoMethodError
111
- skip "D-12: Default namespace XPath not supported on #{adapter_name}"
105
+ expect(library.length).to eq(1)
112
106
  end
113
107
  end
114
108
 
@@ -116,17 +110,13 @@ RSpec.describe "XPath Capabilities" do
116
110
  it "supports numeric positions ([1])" do
117
111
  doc = Moxml.new.parse(simple_xml)
118
112
  first_book = doc.xpath("//book[1]")
119
- expect(first_book.length).to be >= 0
120
- rescue Moxml::XPathError
121
- skip "D-12: Position predicates not supported on #{adapter_name}"
113
+ expect(first_book.length).to eq(1)
122
114
  end
123
115
 
124
116
  it "supports position() function" do
125
117
  doc = Moxml.new.parse(simple_xml)
126
118
  first_books = doc.xpath("//book[position()=1]")
127
- expect(first_books.length).to be >= 0
128
- rescue Moxml::XPathError
129
- skip "D-12: position() function not supported on #{adapter_name}"
119
+ expect(first_books.length).to eq(1)
130
120
  end
131
121
  end
132
122
 
@@ -134,20 +124,13 @@ RSpec.describe "XPath Capabilities" do
134
124
  it "supports count() function, returning the scalar unwrapped" do
135
125
  doc = Moxml.new.parse(simple_xml)
136
126
  result = doc.xpath("count(//book)")
137
- # REXML's XPath has no function support and yields an empty set
138
- skip "D-12: count() function not supported on #{adapter_name}" if result.is_a?(Moxml::NodeSet)
139
-
140
127
  expect(result).to eq(2)
141
- rescue Moxml::XPathError, NoMethodError
142
- skip "D-12: count() function not supported on #{adapter_name}"
143
128
  end
144
129
 
145
130
  it "supports text() node selection" do
146
131
  doc = Moxml.new.parse(simple_xml)
147
132
  texts = doc.xpath("//title/text()")
148
- expect(texts.length).to be >= 0
149
- rescue Moxml::XPathError
150
- skip "D-12: text() not supported on #{adapter_name}"
133
+ expect(texts.length).to eq(3)
151
134
  end
152
135
  end
153
136
 
@@ -155,17 +138,13 @@ RSpec.describe "XPath Capabilities" do
155
138
  it "supports numeric comparisons ([@attr < value])" do
156
139
  doc = Moxml.new.parse(simple_xml)
157
140
  cheap_books = doc.xpath("//book[@id < 2]")
158
- expect(cheap_books.length).to be >= 0
159
- rescue Moxml::XPathError
160
- skip "D-12: Numeric predicates not supported on #{adapter_name}"
141
+ expect(cheap_books.length).to eq(1)
161
142
  end
162
143
 
163
144
  it "supports boolean expressions ([cond1 and cond2])" do
164
145
  doc = Moxml.new.parse(simple_xml)
165
146
  result = doc.xpath("//book[@id and @category]")
166
- expect(result.length).to be >= 0
167
- rescue Moxml::XPathError
168
- skip "D-12: Boolean expressions not supported on #{adapter_name}"
147
+ expect(result.length).to eq(2)
169
148
  end
170
149
  end
171
150
 
@@ -173,17 +152,13 @@ RSpec.describe "XPath Capabilities" do
173
152
  it "supports child axis" do
174
153
  doc = Moxml.new.parse(simple_xml)
175
154
  children = doc.xpath("/library/child::book")
176
- expect(children.length).to be >= 0
177
- rescue Moxml::XPathError
178
- skip "D-12: child:: axis not supported on #{adapter_name}"
155
+ expect(children.length).to eq(2)
179
156
  end
180
157
 
181
158
  it "supports descendant axis" do
182
159
  doc = Moxml.new.parse(simple_xml)
183
160
  descendants = doc.xpath("//library/descendant::title")
184
- expect(descendants.length).to be >= 0
185
- rescue Moxml::XPathError
186
- skip "D-12: descendant:: axis not supported on #{adapter_name}"
161
+ expect(descendants.length).to eq(3)
187
162
  end
188
163
  end
189
164
 
@@ -191,9 +166,7 @@ RSpec.describe "XPath Capabilities" do
191
166
  it "supports union (|)" do
192
167
  doc = Moxml.new.parse(simple_xml)
193
168
  items = doc.xpath("//book | //magazine")
194
- expect(items.length).to be >= 0
195
- rescue Moxml::XPathError
196
- skip "D-12: Union operator not supported on #{adapter_name}"
169
+ expect(items.length).to eq(3)
197
170
  end
198
171
  end
199
172
  end
@@ -67,6 +67,10 @@ module InputTaxonomy
67
67
  text: { oga: "D-14" },
68
68
  pi_content: { ox: "D-05", headed_ox: "D-05" },
69
69
  },
70
+ "pi/comment/cdata: pi trailing whitespace" => {
71
+ text: { oga: "D-14" },
72
+ pi_content: { ox: "D-05", headed_ox: "D-05", rexml: "D-20" },
73
+ },
70
74
  "huge text with entities" => {
71
75
  text: { rexml: "D-16" },
72
76
  serialize: { rexml: "D-16" },
@@ -191,6 +195,9 @@ module InputTaxonomy
191
195
  Input.new("pi/comment/cdata: pi multi-space separator", "pi/comment/cdata edges",
192
196
  "<r><?pi data?></r>", true,
193
197
  "separator whitespace is not PI content (uniform)"),
198
+ Input.new("pi/comment/cdata: pi trailing whitespace", "pi/comment/cdata edges",
199
+ "<r><?pi data ?></r>", true,
200
+ "trailing whitespace is PI data (D-20 on rexml)"),
194
201
  Input.new("pi/comment/cdata: empty pi", "pi/comment/cdata edges",
195
202
  "<r><?pi?></r>", true, nil),
196
203
 
@@ -0,0 +1,159 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The model-coverage matrix (TODO.sota/01, TODO.sota/07): every face
4
+ # family of the processing model mapped to the normative section it
5
+ # cites, the pin that enforces it, and per-adapter dispositions
6
+ # (registered divergence or named loud error). One source of truth for
7
+ # the audit, the model-document pin lists, and the published coverage
8
+ # page.
9
+ module ModelCoverage
10
+ MODEL_COVERAGE_MATRIX = {
11
+ "document order and children listing" => {
12
+ section: "Document order and traversal",
13
+ pin: "spec/consistency/adapter_parity_spec.rb",
14
+ },
15
+ "name resolution" => {
16
+ section: "Names and namespaces",
17
+ pin: "spec/consistency/xpath_idioms_spec.rb",
18
+ },
19
+ "namespace resolution and bindings normalization" => {
20
+ section: "Names and namespaces",
21
+ pin: "spec/consistency/xpath_idioms_spec.rb",
22
+ },
23
+ "attribute access" => {
24
+ section: "Access semantics",
25
+ pin: "spec/moxml/attribute_resolver_spec.rb",
26
+ },
27
+ "text/content/raw_content" => {
28
+ section: "Access semantics",
29
+ pin: "spec/moxml/text_spec.rb",
30
+ },
31
+ "parsing modes and diagnostics" => {
32
+ section: "Parsing",
33
+ pin: "spec/moxml/document_parse_diagnostics_spec.rb",
34
+ },
35
+ "EOL normalization" => {
36
+ section: "Parsing",
37
+ pin: "spec/consistency/eol_normalization_spec.rb",
38
+ exempt: { oga: "D-02", ox: "D-03" },
39
+ },
40
+ "entity modes" => {
41
+ section: "Parsing",
42
+ pin: "spec/moxml/entity_spec.rb",
43
+ },
44
+ "XPath evaluation and declared idioms" => {
45
+ section: "XPath evaluation",
46
+ pin: "spec/consistency/xpath_idioms_spec.rb",
47
+ },
48
+ "serialization shapes (xml/html/xhtml)" => {
49
+ section: "Serialization",
50
+ pin: "spec/moxml/xhtml_output_spec.rb",
51
+ },
52
+ "indentation knobs" => {
53
+ section: "Serialization",
54
+ pin: "spec/moxml/to_html_spec.rb",
55
+ exempt: { oga: "D-09", ox: "D-09", headed_ox: "D-09",
56
+ libxml: "D-09", leptris: "D-09" },
57
+ },
58
+ "canonicalization" => {
59
+ section: "Canonicalization",
60
+ pin: "spec/moxml/c14n/adapter_delegation_spec.rb",
61
+ exempt: { ox: "D-05", headed_ox: "D-05" },
62
+ },
63
+ "XSLT" => {
64
+ section: "XSLT",
65
+ pin: "spec/consistency/xslt_spec.rb",
66
+ loud: { oga: "Moxml::NotImplementedError",
67
+ ox: "Moxml::NotImplementedError",
68
+ headed_ox: "Moxml::NotImplementedError",
69
+ rexml: "Moxml::NotImplementedError",
70
+ libxml: "Moxml::NotImplementedError" },
71
+ },
72
+ "SAX" => {
73
+ section: "SAX",
74
+ pin: "spec/moxml/sax_spec.rb",
75
+ },
76
+ "materialization" => {
77
+ section: "Materialization",
78
+ pin: "spec/moxml/plan_conformance_spec.rb",
79
+ },
80
+ "loud capability contracts" => {
81
+ section: "Errors and loud degradation",
82
+ pin: "spec/consistency/loud_degradation_spec.rb",
83
+ },
84
+ }.freeze
85
+
86
+ # Normative sections that are not face families (meta/apparatus).
87
+ MODEL_COVERAGE_NON_FACE = [
88
+ "Status and precedence",
89
+ "Mission and invariant",
90
+ "Object model",
91
+ "Performance: a declared, non-semantic channel",
92
+ ].freeze
93
+
94
+ MODEL_COVERAGE_ADAPTERS = %i[nokogiri oga rexml ox headed_ox libxml leptris].freeze
95
+
96
+ module_function
97
+
98
+ def families
99
+ MODEL_COVERAGE_MATRIX.keys
100
+ end
101
+
102
+ def sections
103
+ MODEL_COVERAGE_MATRIX.values.map { |cell| cell[:section] }.uniq
104
+ end
105
+
106
+ def pins_for(section)
107
+ MODEL_COVERAGE_MATRIX.values.select { |cell| cell[:section] == section }
108
+ .filter_map { |cell| cell[:pin] }.uniq.sort
109
+ end
110
+
111
+ def disposition(family, adapter)
112
+ cell = MODEL_COVERAGE_MATRIX.fetch(family)
113
+ if (id = (cell[:exempt] || {})[adapter])
114
+ [:specd, id]
115
+ elsif (error = (cell[:loud] || {})[adapter])
116
+ [:loud, error]
117
+ else
118
+ [:equivalent, nil]
119
+ end
120
+ end
121
+
122
+ def cell_text(family, adapter)
123
+ kind, detail = disposition(family, adapter)
124
+ case kind
125
+ when :specd then detail
126
+ when :loud then "loud (#{detail.split('::').last})"
127
+ else "equivalent"
128
+ end
129
+ end
130
+
131
+ # The published page block, deterministic (no clock, no engine
132
+ # versions): the page is a view of the committed matrix and register,
133
+ # so a data change without regeneration fails CI.
134
+ def render_page_block
135
+ lines = []
136
+ lines << "Generated by `bundle exec rake docs:coverage` from the " \
137
+ "coverage matrix and the divergence register. Do not edit " \
138
+ "by hand: `spec/consistency/published_docs_spec.rb` fails " \
139
+ "when this block is stale."
140
+ lines << ""
141
+ lines << %([cols="4#{',1' * MODEL_COVERAGE_ADAPTERS.size}",options="header"])
142
+ lines << "|==="
143
+ lines << "| Face family | " \
144
+ "#{MODEL_COVERAGE_ADAPTERS.map { |adapter| adapter.to_s.tr('_', ' ') }.join(' | ')}"
145
+ families.each do |family|
146
+ lines << "| #{family} | " \
147
+ "#{MODEL_COVERAGE_ADAPTERS.map { |adapter| cell_text(family, adapter) }.join(' | ')}"
148
+ end
149
+ lines << "|==="
150
+ lines << ""
151
+ lines << "*equivalent* — all adapters answer the same observable " \
152
+ "result. *loud (...)* — the adapter raises the named error " \
153
+ "for that face. *D-NN* — a registered divergence in " \
154
+ "link:divergences.html[the register], with its rationale. " \
155
+ "Every cell cites a pin; see the processing model's " \
156
+ "`Pins::` line for the enforcing specs."
157
+ lines.join("\n")
158
+ end
159
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.149
4
+ version: 0.5.150
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-20 00:00:00.000000000 Z
11
+ date: 2026-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Moxml is a unified XML manipulation library that provides a common API
@@ -26,6 +26,8 @@ files:
26
26
  - ".github/workflows/docs.yml"
27
27
  - ".github/workflows/nightly-fuzz.yml"
28
28
  - ".github/workflows/opal.yml"
29
+ - ".github/workflows/performance-release.yml"
30
+ - ".github/workflows/performance.yml"
29
31
  - ".github/workflows/rake.yml"
30
32
  - ".github/workflows/release.yml"
31
33
  - ".github/workflows/round-trip.yml"
@@ -40,12 +42,16 @@ files:
40
42
  - LICENSE.md
41
43
  - README.adoc
42
44
  - Rakefile
45
+ - benchmark/README.md
43
46
  - benchmark/pipeline_bench.rb
44
47
  - benchmark/plan_bench.rb
45
48
  - benchmark/sax_bench.rb
49
+ - benchmark/scoreboard.json
50
+ - benchmark/scoreboard.rb
46
51
  - benchmarks/.gitignore
47
52
  - benchmarks/generate_report.rb
48
53
  - bin/console
54
+ - bin/generate-model-coverage
49
55
  - bin/setup
50
56
  - data/w3c_entities.json
51
57
  - docs/ENTITY_SUPPORT_FOR_LUTAML_MODEL.md
@@ -75,15 +81,18 @@ files:
75
81
  - docs/_pages/configuration.adoc
76
82
  - docs/_pages/conversion-apis.adoc
77
83
  - docs/_pages/divergences.adoc
84
+ - docs/_pages/ecosystem.adoc
78
85
  - docs/_pages/error-handling.adoc
79
86
  - docs/_pages/headed-ox-limitations.adoc
80
87
  - docs/_pages/headed-ox.adoc
81
88
  - docs/_pages/index.adoc
82
89
  - docs/_pages/installation.adoc
90
+ - docs/_pages/model-coverage.adoc
83
91
  - docs/_pages/node-api-reference.adoc
84
92
  - docs/_pages/performance.adoc
85
93
  - docs/_pages/quick-start.adoc
86
94
  - docs/_pages/thread-safety.adoc
95
+ - docs/_pages/why-moxml.adoc
87
96
  - docs/_references/document-api.adoc
88
97
  - docs/_references/index.adoc
89
98
  - docs/_references/processing-model.adoc
@@ -232,6 +241,7 @@ files:
232
241
  - lib/moxml/reference/normalizer.rb
233
242
  - lib/moxml/reference/parser.rb
234
243
  - lib/moxml/reference/writer.rb
244
+ - lib/moxml/relaxng.rb
235
245
  - lib/moxml/sax.rb
236
246
  - lib/moxml/sax/block_handler.rb
237
247
  - lib/moxml/sax/element_handler.rb
@@ -318,6 +328,7 @@ files:
318
328
  - sig/moxml.rbs
319
329
  - spec/consistency/README.md
320
330
  - spec/consistency/adapter_parity_spec.rb
331
+ - spec/consistency/citation_hygiene_spec.rb
321
332
  - spec/consistency/differential_taxonomy_spec.rb
322
333
  - spec/consistency/divergence_register_spec.rb
323
334
  - spec/consistency/document_text_spec.rb
@@ -327,6 +338,7 @@ files:
327
338
  - spec/consistency/metamorphic_properties_spec.rb
328
339
  - spec/consistency/metamorphic_spec.rb
329
340
  - spec/consistency/model_coverage_audit_spec.rb
341
+ - spec/consistency/published_docs_spec.rb
330
342
  - spec/consistency/reference_differential_spec.rb
331
343
  - spec/consistency/round_trip_spec.rb
332
344
  - spec/consistency/spec_constant_uniqueness_spec.rb
@@ -526,6 +538,7 @@ files:
526
538
  - spec/moxml/document_spec.rb
527
539
  - spec/moxml/element_add_element_spec.rb
528
540
  - spec/moxml/element_attribute_pairs_spec.rb
541
+ - spec/moxml/element_indent_spec.rb
529
542
  - spec/moxml/element_spec.rb
530
543
  - spec/moxml/entity_preservation_spec.rb
531
544
  - spec/moxml/entity_reference_spec.rb
@@ -560,6 +573,7 @@ files:
560
573
  - spec/moxml/recover_mode_spec.rb
561
574
  - spec/moxml/reference_opal_spec.rb
562
575
  - spec/moxml/reference_spec.rb
576
+ - spec/moxml/relax_ng_spec.rb
563
577
  - spec/moxml/sax/namespace_splitter_spec.rb
564
578
  - spec/moxml/sax_entity_parity_spec.rb
565
579
  - spec/moxml/sax_spec.rb
@@ -623,6 +637,7 @@ files:
623
637
  - spec/support/allocation_helper.rb
624
638
  - spec/support/input_generator.rb
625
639
  - spec/support/input_taxonomy.rb
640
+ - spec/support/model_coverage.rb
626
641
  - spec/support/opal.rb
627
642
  - spec/support/w3c_namespace_helpers.rb
628
643
  - spec/support/xml_generator.rb