leptris 1.9.356.0-arm-linux → 1.9.360.0-arm-linux

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +13 -5
  3. data/Rakefile +1 -1
  4. data/ext/leptris/native/native.c +353 -1
  5. data/lib/leptris/version.rb +1 -1
  6. data/lib/leptris/xml/cdata.rb +3 -0
  7. data/lib/leptris/xml/comment.rb +3 -0
  8. data/lib/leptris/xml/declaration.rb +64 -0
  9. data/lib/leptris/xml/doc_type.rb +33 -1
  10. data/lib/leptris/xml/document.rb +77 -2
  11. data/lib/leptris/xml/element.rb +21 -1
  12. data/lib/leptris/xml/entity_reference.rb +3 -0
  13. data/lib/leptris/xml/native.so +0 -0
  14. data/lib/leptris/xml/node_set.rb +22 -0
  15. data/lib/leptris/xml/processing_instruction.rb +3 -0
  16. data/lib/leptris/xml/sax/parser.rb +102 -78
  17. data/lib/leptris/xml/text.rb +4 -0
  18. data/lib/leptris/xml.rb +14 -0
  19. data/lib/libleptris.so +0 -0
  20. data/scripts/gem_smoke.rb +6 -3
  21. data/vendor-src/README.md +1 -1
  22. data/vendor-src/libleptris/CHANGELOG.md +95 -0
  23. data/vendor-src/libleptris/CMakeLists.txt +1 -1
  24. data/vendor-src/libleptris/TODO.xslt-full/REMAINING.md +37 -18
  25. data/vendor-src/libleptris/cli/commands/validate.c +15 -2
  26. data/vendor-src/libleptris/src/include/leptris.h +60 -4
  27. data/vendor-src/libleptris/src/leptris/dtd/content_check.c +280 -144
  28. data/vendor-src/libleptris/src/leptris/dtd/parser.c +17 -4
  29. data/vendor-src/libleptris/src/leptris/rng/parse.c +53 -8
  30. data/vendor-src/libleptris/src/leptris/rng/validate.c +63 -21
  31. data/vendor-src/libleptris/src/leptris/xinclude/xinclude.c +304 -12
  32. data/vendor-src/libleptris/src/leptris/xpath/evaluator.c +30 -0
  33. data/vendor-src/libleptris/src/leptris/xpath/evaluator.h +11 -0
  34. data/vendor-src/libleptris/src/leptris/xpath/evaluator_axes.c +3 -3
  35. data/vendor-src/libleptris/src/leptris/xpath/evaluator_path.c +4 -20
  36. data/vendor-src/libleptris/src/leptris/xpath/parser.c +4 -1
  37. data/vendor-src/libleptris/src/leptris/xpath/vm.c +41 -11
  38. data/vendor-src/libleptris/src/leptris/xpath/xpath_compiled.c +4 -3
  39. data/vendor-src/libleptris/src/leptris/xpath/xpath_public.c +2 -1
  40. data/vendor-src/libleptris/src/leptris/xsd/compile.c +981 -38
  41. data/vendor-src/libleptris/src/leptris/xsd/content_model.c +15 -3
  42. data/vendor-src/libleptris/src/leptris/xsd/validate.c +27 -9
  43. data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +1 -0
  44. data/vendor-src/libleptris/test/cli/test_cli.cpp +50 -14
  45. data/vendor-src/libleptris/test/dtd/test_dtd_validate.cpp +80 -4
  46. data/vendor-src/libleptris/test/rng/include-cases/attr-text-choice.rng +18 -0
  47. data/vendor-src/libleptris/test/rng/include-cases/dup-inc-mid.rng +7 -0
  48. data/vendor-src/libleptris/test/rng/include-cases/dup-inc-shared.rng +5 -0
  49. data/vendor-src/libleptris/test/rng/include-cases/dup-inc-top.rng +6 -0
  50. data/vendor-src/libleptris/test/rng/test_rng.cpp +101 -0
  51. data/vendor-src/libleptris/test/xinclude/test_xinclude.cpp +261 -0
  52. data/vendor-src/libleptris/test/xpath/test_xpath.cpp +169 -0
  53. data/vendor-src/libleptris/test/xpath/test_xpath_conformance.cpp +8 -1
  54. data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +128 -11
  55. data/vendor-src/libleptris/vcpkg.json +1 -1
  56. metadata +7 -2
@@ -348,7 +348,21 @@ class Leptris::XML::Document
348
348
  # the chain lacks it, so parsed and built documents read the
349
349
  # same. Prolog/epilog placement uses node_compare against the
350
350
  # root.
351
+ # The declaration (leptris-ruby#459) rides in FRONT of the C child
352
+ # chain — it is document state, not a chain node, so the C-facing
353
+ # child logic below never sees it.
351
354
  def children
355
+ base = document_child_nodes
356
+ return base if declaration.nil?
357
+ # .dup: NodeSet#to_a hands back the LIVE memoized array — unshifting
358
+ # into it would inject the Declaration into the underlying child
359
+ # list and poison every later children call (leptris#1732 class).
360
+ list = base.to_a.dup
361
+ list.unshift(declaration)
362
+ Leptris::XML::NodeSet.new(self, list)
363
+ end
364
+
365
+ def document_child_nodes
352
366
  doc_node = node
353
367
  return Leptris::XML::NodeSet.new(self, []) if doc_node.nil?
354
368
  kids = doc_node.children.to_a
@@ -507,10 +521,18 @@ class Leptris::XML::Document
507
521
  def doctype
508
522
  ptr = Leptris::XML::FFI.leptris_document_internal_subset(c_ptr)
509
523
  return nil if ptr.null?
510
- Leptris::XML::DocType.new(ptr, self)
524
+ wrap_doctype(ptr)
511
525
  end
512
526
  alias_method :internal_subset, :doctype
513
527
 
528
+ # One DocType wrapper per C node per document (leptris-ruby#459):
529
+ # the attach routes and the readers hand back the SAME Ruby object
530
+ # the consumer created or received before.
531
+ def wrap_doctype(ptr)
532
+ @doctype_wrappers ||= {}
533
+ @doctype_wrappers[ptr.address] ||= Leptris::XML::DocType.new(ptr, self)
534
+ end
535
+
514
536
  # indent_text selects the ext-serializer knob (libleptris 1.9.22):
515
537
  # a STRING is the indent unit with Nokogiri's semantics — the unit
516
538
  # replaces the default spaces, one copy per depth level, standard
@@ -759,6 +781,16 @@ class Leptris::XML::Document
759
781
  value
760
782
  end
761
783
 
784
+ # The declaration as a NODE (leptris-ruby#459 ask 1): reads and
785
+ # writes route to the document state; remove/unlink clears it.
786
+ # nil when the document carries no declaration. One value object
787
+ # per document — repeated reads return the same instance.
788
+ def declaration
789
+ return @declaration_node if @declaration_node
790
+ return nil if xml_version.nil?
791
+ @declaration_node = Leptris::XML::Declaration.new(self)
792
+ end
793
+
762
794
  # Programmatic DOCTYPE (libleptris 1.9.176 / #212): create and
763
795
  # set the document's DOCTYPE (root name + optional PUBLIC/SYSTEM
764
796
  # ids); serializes in document position. Returns the DocType.
@@ -767,7 +799,49 @@ class Leptris::XML::Document
767
799
  c_ptr, name.to_s, public_id, system_id)
768
800
  raise Leptris::XML::Error, "leptris_document_set_doctype failed" if dt.null?
769
801
  @version += 1
770
- Leptris::XML::DocType.new(dt, self)
802
+ wrap_doctype(dt)
803
+ end
804
+
805
+ # Detached DOCTYPE token (leptris-ruby#459 ask 2): create now,
806
+ # inspect while unattached, attach later via add_child. Nothing is
807
+ # written to the document until the attach.
808
+ def new_doctype(name, public_id: nil, system_id: nil)
809
+ Leptris::XML::DocType.new_detached(self, name.to_s, public_id, system_id)
810
+ end
811
+
812
+ # Attach a detached DOCTYPE token (the two-phase facade contract):
813
+ # routes through the engine's set_doctype and adopts the caller's
814
+ # wrapper, so #doctype hands back the same node identity.
815
+ def add_child(node)
816
+ unless node.is_a?(Leptris::XML::DocType) && !node.attached?
817
+ raise ArgumentError,
818
+ "Document#add_child attaches a detached DocType, got #{node.class}"
819
+ end
820
+ dt = Leptris::XML::FFI.leptris_document_set_doctype(
821
+ c_ptr, node.name, node.public_id, node.system_id)
822
+ raise Leptris::XML::Error, "leptris_document_set_doctype failed" if dt.null?
823
+ @version += 1
824
+ node.attach!(dt)
825
+ (@doctype_wrappers ||= {})[dt.address] = node
826
+ node
827
+ end
828
+
829
+ # Recovered-parse diagnostics (leptris-ruby#465): nokogiri parity
830
+ # for the recover lane — the engine's parse diagnostics as
831
+ # SyntaxError entries, empty for a clean parse. The engine
832
+ # reader carries message + kind; position stays nil until the C
833
+ # face exposes the diag line/column.
834
+ def errors
835
+ count = Leptris::XML::FFI.leptris_document_parse_diag_count(c_ptr)
836
+ return [] if count.zero?
837
+ count.times.map do |i|
838
+ msg_buf = ::FFI::MemoryPointer.new(:char, 512)
839
+ kind_buf = ::FFI::MemoryPointer.new(:int)
840
+ ok = Leptris::XML::FFI.leptris_document_parse_diag(
841
+ c_ptr, i, kind_buf, msg_buf, 512)
842
+ next nil if ok.zero?
843
+ Leptris::XML::SyntaxError.new(msg_buf.read_string.force_encoding(Encoding::UTF_8))
844
+ end.compact
771
845
  end
772
846
 
773
847
  # Un-set the XML declaration (libleptris 1.9.204, upstream
@@ -778,6 +852,7 @@ class Leptris::XML::Document
778
852
  def clear_declaration
779
853
  Leptris::XML::FFI.check_status(
780
854
  Leptris::XML::FFI.leptris_document_clear_declaration(c_ptr))
855
+ @declaration_node = nil
781
856
  @version += 1
782
857
  self
783
858
  end
@@ -643,10 +643,30 @@ class Leptris::XML::Element < Leptris::XML::Node
643
643
  end
644
644
 
645
645
  # Replace this element with +new_node+ in the parent's child list.
646
- # +new_node+ must belong to the same document. Returns +new_node+.
646
+ # +new_node+ is a node belonging to the same document, or markup
647
+ # parsed in this document's context (leptris-ruby#457 — nokogiri
648
+ # parity; multiple top-level nodes splice in order). Returns the
649
+ # replacement node, or a NodeSet when the markup produced several.
647
650
  def replace(new_node)
648
651
  parent = self.parent
649
652
  raise Leptris::XML::Error, "cannot replace a node with no parent" unless parent
653
+ if new_node.is_a?(Leptris::XML::DocumentFragment)
654
+ # DOM Core insert semantics: the fragment itself never enters
655
+ # the tree — its children splice in (the #document-fragment
656
+ # pseudo-node would leak into serialization/XPath/C14N).
657
+ nodes = new_node.children.to_a
658
+ raise Leptris::XML::Error, "replacement fragment produced no nodes" if nodes.empty?
659
+ installed = nodes.reverse_each.map { |n| add_next_sibling(n) }.reverse
660
+ parent.remove_child(self)
661
+ return installed.size == 1 ? installed.first : Leptris::XML::NodeSet.new(@document, installed)
662
+ end
663
+ if new_node.is_a?(String)
664
+ nodes = @document.fragment(new_node).children.to_a
665
+ raise Leptris::XML::Error, "replacement markup produced no nodes" if nodes.empty?
666
+ installed = nodes.reverse_each.map { |n| add_next_sibling(n) }.reverse
667
+ parent.remove_child(self)
668
+ return installed.size == 1 ? installed.first : Leptris::XML::NodeSet.new(@document, installed)
669
+ end
650
670
  add_next_sibling(new_node)
651
671
  parent.remove_child(self)
652
672
  new_node
@@ -14,4 +14,7 @@ class Leptris::XML::EntityReference < Leptris::XML::Node
14
14
  def to_s
15
15
  "&#{name};"
16
16
  end
17
+
18
+ # leptris-ruby#464: entity-reference serialization face.
19
+ alias_method :to_xml, :to_s
17
20
  end
Binary file
@@ -187,6 +187,28 @@ class Leptris::XML::NodeSet
187
187
  end
188
188
  alias_method :text, :inner_text
189
189
 
190
+ # Nokogiri parity (leptris-ruby#455): unlink every member from its
191
+ # tree. Members are materialized first — unlinking mutates the
192
+ # sibling chain the lazy result would otherwise be walked against.
193
+ def remove
194
+ to_a.each(&:unlink)
195
+ self
196
+ end
197
+ alias_method :unlink, :remove
198
+
199
+ # Nokogiri parity (leptris-ruby#456): serialize every member in
200
+ # order and concatenate. Elements and attributes ride #to_xml;
201
+ # text/comment/PI answer #to_s with the same bytes.
202
+ def to_xml
203
+ map do |node|
204
+ if node.is_a?(Leptris::XML::Element) || node.is_a?(Leptris::XML::Attr)
205
+ node.to_xml
206
+ else
207
+ node.to_s
208
+ end
209
+ end.join
210
+ end
211
+
190
212
  # Union semantics: ONE engine call evaluates the expression
191
213
  # against every element member and merges the results into a
192
214
  # de-duplicated, document-ordered nodeset (libleptris 1.9.7,
@@ -54,6 +54,9 @@ class Leptris::XML::ProcessingInstruction < Leptris::XML::Node
54
54
  content.to_s.empty? ? "<?#{name}?>" : "<?#{name} #{content}?>"
55
55
  end
56
56
 
57
+ # leptris-ruby#464: PI serialization face.
58
+ alias_method :to_xml, :to_s
59
+
57
60
  # Document-level PIs have no tree parent for leptris_node_unlink
58
61
  # — route through the document-level removal (libleptris 1.9.9,
59
62
  # #612), identity-matched by index so the right same-target PI
@@ -71,8 +71,13 @@ class Leptris::XML::SAX::Parser
71
71
  @document, dispatched_kinds, string)
72
72
  return self
73
73
  end
74
- if bulk_dispatch?
75
- parse_memory_bulk(string)
74
+ if native_fast?
75
+ rc = Leptris::XML::Native.sax_parse(
76
+ @document, native_kinds_mask, string)
77
+ if rc != 0
78
+ raise Leptris::XML::ParseError,
79
+ "leptris_sax_parse failed (rc=#{rc})"
80
+ end
76
81
  else
77
82
  handler_struct = self.handler_struct
78
83
  rc = Leptris::XML::FFI.leptris_sax_parse(
@@ -85,48 +90,78 @@ class Leptris::XML::SAX::Parser
85
90
  self
86
91
  end
87
92
 
88
- # Bulk transport for many-override handlers: record the whole
89
- # document C-side (~12ms per 250k events), then dispatch through
90
- # the recorder's drain — 250k ffi callback trampolines cost
91
- # ~150ms, so this wins outright for handlers that consume most of
92
- # the event stream (and beats Nokogiri's C extension on the same
93
- # shape). The delivered call shapes are IDENTICAL to the callback
94
- # transport (pairs arrays, arity dispatch, UTF-8, PI-data
95
- # normalization) — the transports are interchangeable to the
96
- # handler.
97
- #
98
- # Transport choice, from the round-XXVI crossover measurements:
99
- # ONE overridden hot kind pays less through the callbacks (the
100
- # engine skips C-side emission for unattached kinds entirely:
101
- # text-only 23ms vs 43ms), while two or more hot kinds win through
102
- # the recorder (start+chars 138 -> 99ms, start+end+chars 167 ->
103
- # 122ms vs Nokogiri's 142ms). The weights are document-shape
104
- # priors — text-heavy documents with tagged structure.
105
- HOT_KIND_WEIGHTS = {
106
- characters: 0.6, start_element: 0.2, end_element: 0.2,
107
- }.freeze
108
- private_constant :HOT_KIND_WEIGHTS
109
- DISPATCH_WEIGHT_THRESHOLD = 0.8
110
- private_constant :DISPATCH_WEIGHT_THRESHOLD
111
-
112
- def parse_memory_bulk(string)
113
- recorder = Leptris::XML::SAX::Recorder.open
93
+ def parse_io(io)
94
+ unless @streaming
95
+ parse_memory(io.read)
96
+ return self
97
+ end
98
+ if native_fast?
99
+ parser = Leptris::XML::Native.sax_parser_create(
100
+ @document, native_kinds_mask)
101
+ if parser.nil?
102
+ raise Leptris::XML::Error, "leptris_sax_parser_create failed"
103
+ end
104
+ begin
105
+ Leptris::XML::Native.sax_parser_set_skip_flags(
106
+ parser, @skip_flags || 0)
107
+ while (chunk = io.read(CHUNK_SIZE))
108
+ rc = Leptris::XML::Native.sax_parser_feed(parser, chunk, false)
109
+ if rc != 0
110
+ raise Leptris::XML::ParseError,
111
+ "leptris_sax_parser_feed failed (rc=#{rc})"
112
+ end
113
+ end
114
+ rc = Leptris::XML::Native.sax_parser_feed(parser, "", true)
115
+ if rc != 0
116
+ raise Leptris::XML::ParseError,
117
+ "leptris_sax_parser_feed (final) failed (rc=#{rc})"
118
+ end
119
+ ensure
120
+ Leptris::XML::Native.sax_parser_free(parser)
121
+ end
122
+ return self
123
+ end
124
+ handler_struct = self.handler_struct
125
+ parser_ptr = Leptris::XML::FFI.leptris_sax_parser_create(
126
+ handler_struct.pointer, nil)
127
+ if parser_ptr.null?
128
+ raise Leptris::XML::Error, "leptris_sax_parser_create failed"
129
+ end
130
+ if @skip_flags
131
+ Leptris::XML::FFI.leptris_sax_parser_set_skip_flags(
132
+ parser_ptr, @skip_flags)
133
+ end
114
134
  begin
115
- rc = recorder.feed(string, final: true)
116
- recorder.dispatch(@document, dispatched_kinds)
135
+ while (chunk = io.read(CHUNK_SIZE))
136
+ rc = Leptris::XML::FFI.leptris_sax_parser_feed(
137
+ parser_ptr, chunk, chunk.bytesize, 0)
138
+ if rc != 0
139
+ raise Leptris::XML::ParseError, "leptris_sax_parser_feed failed (rc=#{rc})"
140
+ end
141
+ end
142
+ # Final flush
143
+ rc = Leptris::XML::FFI.leptris_sax_parser_feed(parser_ptr, "", 0, 1)
117
144
  if rc != 0
118
- raise Leptris::XML::ParseError,
119
- "leptris_sax_parse failed (rc=#{rc})"
145
+ raise Leptris::XML::ParseError, "leptris_sax_parser_feed (final) failed (rc=#{rc})"
120
146
  end
121
147
  ensure
122
- recorder.free
148
+ Leptris::XML::FFI.leptris_sax_parser_free(parser_ptr)
123
149
  end
124
150
  self
125
151
  end
126
152
 
127
- # The handler's overridden-kind map — the same decisions
128
- # build_handler_struct makes, in dispatch form. Memoized with the
129
- # handler struct; document= invalidates both.
153
+ def parse_file(path)
154
+ if @streaming
155
+ File.open(path, "r") { |f| parse_io(f) }
156
+ else
157
+ parse_memory(File.read(path))
158
+ end
159
+ end
160
+
161
+ # The handler's overridden-kind map — memoized with the handler
162
+ # struct; document= invalidates both. The native transport derives
163
+ # its kind bitmask from it; the FFI fallback builds its callback
164
+ # struct from the same decisions.
130
165
  def dispatched_kinds
131
166
  @dispatched_kinds ||= begin
132
167
  kinds = {}
@@ -156,54 +191,43 @@ class Leptris::XML::SAX::Parser
156
191
  end
157
192
  end
158
193
 
159
- def bulk_dispatch?
160
- dispatched_kinds.keys.sum do |kind|
161
- HOT_KIND_WEIGHTS.fetch(kind, 0.0)
162
- end >= DISPATCH_WEIGHT_THRESHOLD
163
- end
194
+ private
164
195
 
165
- def parse_io(io)
166
- unless @streaming
167
- parse_memory(io.read)
168
- return self
169
- end
170
- handler_struct = self.handler_struct
171
- parser_ptr = Leptris::XML::FFI.leptris_sax_parser_create(
172
- handler_struct.pointer, nil)
173
- if parser_ptr.null?
174
- raise Leptris::XML::Error, "leptris_sax_parser_create failed"
175
- Leptris::XML::FFI.leptris_sax_parser_set_skip_flags(
176
- parser_ptr, @skip_flags || 0)
177
- end
178
- begin
179
- while (chunk = io.read(CHUNK_SIZE))
180
- rc = Leptris::XML::FFI.leptris_sax_parser_feed(
181
- parser_ptr, chunk, chunk.bytesize, 0)
182
- if rc != 0
183
- raise Leptris::XML::ParseError, "leptris_sax_parser_feed failed (rc=#{rc})"
184
- end
185
- end
186
- # Final flush
187
- rc = Leptris::XML::FFI.leptris_sax_parser_feed(parser_ptr, "", 0, 1)
188
- if rc != 0
189
- raise Leptris::XML::ParseError, "leptris_sax_parser_feed (final) failed (rc=#{rc})"
190
- end
191
- ensure
192
- Leptris::XML::FFI.leptris_sax_parser_free(parser_ptr)
193
- end
194
- self
196
+ def native_fast?
197
+ defined?(Leptris::XML::NATIVE_FAST)
195
198
  end
196
199
 
197
- def parse_file(path)
198
- if @streaming
199
- File.open(path, "r") { |f| parse_io(f) }
200
- else
201
- parse_memory(File.read(path))
200
+ # The C transport's kind bitmask — the same decisions
201
+ # dispatched_kinds makes, in bit form. start_element's arity picks
202
+ # the 1-arg or 2-arg dispatch; only overridden kinds attach (the
203
+ # engine skips NULL callbacks, so cost scales with declared
204
+ # interest, not with the document's event mix).
205
+ NATIVE_KIND_BITS = {
206
+ start_document: 1 << 0,
207
+ end_document: 1 << 1,
208
+ end_element: 1 << 4,
209
+ characters: 1 << 5,
210
+ comment: 1 << 6,
211
+ cdata: 1 << 7,
212
+ pi: 1 << 8,
213
+ start_prefix: 1 << 9,
214
+ end_prefix: 1 << 10,
215
+ error: 1 << 11,
216
+ }.freeze
217
+ private_constant :NATIVE_KIND_BITS
218
+
219
+ def native_kinds_mask
220
+ mask = 0
221
+ dispatched_kinds.each do |kind, mode|
222
+ if kind == :start_element
223
+ mask |= (mode == :one_arg ? (1 << 2) : (1 << 3))
224
+ else
225
+ mask |= NATIVE_KIND_BITS.fetch(kind, 0)
226
+ end
202
227
  end
228
+ mask
203
229
  end
204
230
 
205
- private
206
-
207
231
  # Build a LeptrisSAXHandler struct populated with FFI::Function callbacks
208
232
  # that dispatch to the Ruby handler. Only the callbacks the handler
209
233
  # actually overrides are attached: the C engine skips NULL callbacks,
@@ -40,4 +40,8 @@ class Leptris::XML::Text < Leptris::XML::Node
40
40
  def to_s
41
41
  Leptris::XML::Serialization.escape_text(content)
42
42
  end
43
+
44
+ # leptris-ruby#464: nokogiri's Node#to_xml exists on every kind —
45
+ # text serializes escaped.
46
+ alias_method :to_xml, :to_s
43
47
  end
data/lib/leptris/xml.rb CHANGED
@@ -16,6 +16,7 @@ module Leptris
16
16
  autoload :DocumentFragment, "leptris/xml/document_fragment"
17
17
  autoload :Builder, "leptris/xml/builder"
18
18
  autoload :DocType, "leptris/xml/doc_type"
19
+ autoload :Declaration, "leptris/xml/declaration"
19
20
  autoload :NodeSet, "leptris/xml/node_set"
20
21
  autoload :Searchable, "leptris/xml/searchable"
21
22
  autoload :ParseOptions, "leptris/xml/parse_options"
@@ -104,6 +105,19 @@ module Leptris
104
105
 
105
106
  class Error < StandardError; end
106
107
  class ParseError < Error; end
108
+ # Recovered-parse diagnostics (leptris-ruby#465): nokogiri's
109
+ # SyntaxError shape — a message plus optional position — served
110
+ # by Document#errors.
111
+ class SyntaxError < Error
112
+ attr_reader :message, :line, :column
113
+
114
+ def initialize(message, line: nil, column: nil)
115
+ @message = message
116
+ @line = line
117
+ @column = column
118
+ super(message)
119
+ end
120
+ end
107
121
  class ReadOnlyError < Error; end
108
122
  class XPathError < Error; end
109
123
  class UseAfterFreeError < Error; end
data/lib/libleptris.so CHANGED
Binary file
data/scripts/gem_smoke.rb CHANGED
@@ -14,10 +14,13 @@ puts "leptris #{Leptris::VERSION} on #{RUBY_PLATFORM} (ruby #{RUBY_VERSION})"
14
14
  doc = Leptris::XML.parse("<r id='1'><a x='2'>t1</a><a>t2</a></r>")
15
15
  raise "parse: root" unless doc.root.name == "r"
16
16
  raise "xpath: children" unless doc.root.xpath("a").size == 2
17
- raise "attr read" unless doc.at_xpath("a")["x"] == "2"
17
+ # //a from DOCUMENT level: document-node context (libxml2/nokogiri
18
+ # semantics, engine 1.9.358+) — doc.at_xpath("a") would correctly be
19
+ # nil (the document's child is r, not a).
20
+ raise "attr read" unless doc.at_xpath("//a")["x"] == "2"
18
21
 
19
- doc.at_xpath("a").content = "z"
20
- raise "mutate" unless doc.at_xpath("a").content == "z"
22
+ doc.at_xpath("//a").content = "z"
23
+ raise "mutate" unless doc.at_xpath("//a").content == "z"
21
24
  raise "serialize" unless doc.to_xml.include?('<a x="2">z</a>')
22
25
 
23
26
  rng = Leptris::XML::RelaxNG.parse(
data/vendor-src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Sources vendored in this gem (recompile rights; the ruby
2
2
  variant builds them at install via extconf.rb):
3
3
 
4
- - libleptris v1.9.356
4
+ - libleptris v1.9.359
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -1,5 +1,100 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.359] - 2026-10-15
4
+
5
+ ### Fixed
6
+
7
+ - **xpath: descendant axes from document-node contexts walk the tree**
8
+ (leptris-ruby#458 follow-up, #1728). The VM's relative descendant
9
+ opcodes skipped non-element inputs — a document-typed context (the
10
+ NULL-context default) produced empty results for `.//a` and
11
+ `descendant::a` while `//a` kept working. Document inputs now walk
12
+ the root subtree with include-self (the root element IS a
13
+ descendant of the document, the AST walker's rule).
14
+ - **xpath: the reserved xmlns: prefix resolves to the in-scope
15
+ default namespace** (leptris-ruby#469, #1729). The libxml2/nokogiri
16
+ idiom for default-namespaced documents — `doc.xpath("./xmlns:target")`
17
+ now matches. One helper wired into all seven prefixed name-test
18
+ sites; explicit bindings win first; the innermost prefixless
19
+ declaration wins per context node; unprefixed name tests stay
20
+ spec-strict (XPath 1.0 §2.3, no-namespace only).
21
+
22
+
23
+ ## [1.9.358] - 2026-10-15
24
+
25
+ ### Fixed
26
+
27
+ - **xpath: document-level queries evaluate against the document node**
28
+ (leptris-ruby#458). A NULL context defaulted to the root element in
29
+ all four public eval entry points; libxml2/Nokogiri semantics are
30
+ the document node — `doc.xpath("r/a/@id")` now resolves the root's
31
+ children (was silently empty), and doc-level `*` yields exactly the
32
+ root (was the root's children). `leptris.h` documents NULL = the
33
+ document node.
34
+ - **xpath: the `//` + `*` fast path continues past predicates**
35
+ (leptris-ruby#458). It parsed the star step and predicates then
36
+ returned bare, leaving a following SLASH unconsumed —
37
+ `//*[local-name()='a']/@id` and `//*[@id]/@id` failed to compile
38
+ with "Unexpected token after expression: SLASH". It now runs
39
+ parse_path_continuation, the same shape `(//a)/@id` already used.
40
+ - **dtd: Phase 8 closeout** (#1724). Parameter-entity substitution
41
+ peeks the `<!ELEMENT` / `<!ATTLIST` / `<!NOTATION` keyword before
42
+ consuming (PE-blurred keyword boundary); occurrence capture after
43
+ the balanced-paren scan; nested-group choice parses and backtracks;
44
+ mixed content models `(#PCDATA|a|b)*` validate through the
45
+ rewritten backtracking matcher — `(#PCDATA)` without `*` correctly
46
+ rejects element children.
47
+ - Four Phase-5 ID content-model fixtures corrected from `(a|b)` to
48
+ `(a|b)*` (an ID requires at least one matching child).
49
+
50
+
51
+ ## [1.9.357] - 2026-10-15
52
+
53
+ ### Fixed
54
+
55
+ - **XSD conformance: 898/1056 oracle parity (leptris#1691 closed).**
56
+ Four slices landed: ref-QName declaration resolution across the
57
+ include/import graph — chameleon includes adopt the includer's
58
+ namespace, first import per namespace wins (#1718); UPA —
59
+ choice-branch FIRST overlap and optional/repeating sequence
60
+ adjacency with exact wildcard coverage (#1719); the
61
+ attribute-wildcard family — `##targetNamespace`/`##other` list
62
+ keywords and union normalization (#1723); plus the earlier
63
+ derivation-ok/transitive-include slice (#1716). Floors 839 → 898;
64
+ the only non-converging pair is `length3_0`, an oracle gap
65
+ (libxml2 2.9.13 cannot resolve the spec-valid
66
+ `xs:non-positive-integer`), deliberately not codified.
67
+ - **XInclude: xml:base chains + resolver policy (leptris#1694,
68
+ PR #1719).** Relative hrefs resolve against the nearest xml:base
69
+ ancestor (RFC 3986 merge) and nested includes resolve against the
70
+ INCLUDED document's own directory. `leptris_xinclude_process_opts`
71
+ adds a resolver hook, XML Catalog exact-mapping lookups, and
72
+ `no_network` (default on — remote schemes are resource errors;
73
+ catalogs are consulted first so remote names can localize).
74
+ - **RelaxNG: sound interleave + include merge (leptris#1709,
75
+ PR #1711).** Include merge deep-copies (adoption-by-copy) instead
76
+ of moving shared trees; combine=interleave nested defines keep
77
+ their wrapper; the interleave walk is a consuming fixpoint with a
78
+ zero-width satisfiability pass; attribute choices with a text
79
+ branch validate (BIPM locality/date). Include-merge originals are
80
+ freed (Linux-ASAN leak).
81
+ - **RELAX NG diagnostics: full report in the CLI (leptris#1704).**
82
+ A misplaced element that also carries an invalid attribute reports
83
+ BOTH diagnostics (Jing parity); `validate --rng` prints the whole
84
+ report instead of only the first record.
85
+ - **RELAX NG: bare relative schema filenames resolve includes
86
+ against "." (PR #1720).** A schema filename with no path
87
+ separator made every relative `<include href>` resolve against
88
+ the filename itself and die with a misleading parse error.
89
+ - **CLI: per-test fixture files for the parallel validators**
90
+ (PR #1708) — the ctest -j4 Schematron/RngRound flake.
91
+ - **XSD anyAttribute unions + wildcard list keywords (PR #1723).**
92
+
93
+ ### Test suite
94
+
95
+ - 2030 tests (2026 on v1.9.356), zero-warning builds maintained.
96
+
97
+
3
98
  ## [1.9.356] - 2026-10-14
4
99
 
5
100
  ### Fixed
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.356
6
+ VERSION 1.9.359
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -1,9 +1,10 @@
1
1
  # REMAINING — the complete open-work ledger
2
2
 
3
- SSOT for everything still open after v1.9.144 (2026-09-12).
4
- Update entries as work ships; delete entries as they close.
5
- Per-lane details live in the numbered docs; this file is the index
6
- + the graph.
3
+ SSOT for everything still open. REFRESHED 2026-10-15 for v1.9.357:
4
+ the engine issue board is EMPTY (#878-family, #659, #1691, #1694,
5
+ #1704, #1709, #1712 all closed); this file's per-lane statuses were
6
+ re-verified against the shipped state. Per-lane details live in the
7
+ numbered docs; this file is the index + the graph.
7
8
 
8
9
  ## A. In flight — the staged path (2026-09-12)
9
10
 
@@ -93,20 +94,38 @@ ruby/python/c scoreboard. We feed measured numbers only.
93
94
  v1.9.144, the adapter batched-accessor primitive.)
94
95
  - **#930** — CLOSED (v1.9.117).
95
96
 
96
- ## C. TODO.xslt-full lanes — residual items
97
-
98
- - 01/03/04/06/08/09/10 — CLOSED.
99
- - 05 (dates) tail → Stage 2.2. 07 (fn items) tail → Stage 2.3.
100
- - 11/12 (XQuery) tails → Stage 2.1 QT3 subsets via the XTH
101
- connector shape.
102
- - 13 (perf) = #682 (Stage 5). SAX binding-drain residual: retry
103
- quiet-machine best-of-20, else engine-side batched-drain API.
104
- - 14 (HTML) = #659 (Stage 1).
105
- - 15 (binding entries) → Stage 2.4. RelaxNG entries already
106
- shipped (leptris-ruby#165).
107
- - 16 (Schematron 2025): COMPLETE C-side = Stage 3; binding PRs
108
- open (user merges).
109
- - 17 (XML diff): PRs open = Stage 4 (leptris-ruby#171, canon#191).
97
+ ## C. TODO.xslt-full lanes — residual items (2026-10-15 re-verified)
98
+
99
+ - 01/03/04/05/06/07/08/09/10 — CLOSED (fn sequences/regex/math/
100
+ strings/dates/grammar-3x/function-items/maps-arrays/xslt fillins/
101
+ tunnel params all shipped; dates + fn-items verified in
102
+ functions_ext31.c).
103
+ - 11/12 (XQuery) — core surface shipped through v1.9.245+; the
104
+ residual is QT3-suite growth only: the typed-atom lane sits at
105
+ 99 adopted / 2 pins (cbcl-002/002b) and the 5
106
+ duration-canonical survivors are Saxon-verified but may be
107
+ unreachable — measure before grinding.
108
+ - 13 (perf) = #682: ceiling-analyzed (~1.1x in-process max);
109
+ OWNER SCOPE CALL pending — do not grind.
110
+ - 14 (HTML) = #659: CLOSED C-side (fail=0 on the 1753-case corpus,
111
+ 1555 pass / 198 legitimate skips).
112
+ - 15 (binding entries): versioned eval shipped
113
+ (leptris_xpath_eval_versioned, xpath_public.c); result-type
114
+ mirrors live with the binding agents.
115
+ - 16 (Schematron): COMPLETE C-side (IR + SVRL + CLI --phase/--svrl);
116
+ binding wrappers in their repos (dedicated agents).
117
+ - 17 (XML diff): C-side shipped; binding PRs with the user.
118
+ - 18 (compact nodes): superseded by the #1285 compact-pointer
119
+ architecture (elements at ~96 bytes shipped).
120
+
121
+ ## C2. New open work since the last refresh
122
+
123
+ - DTD Phase 8 closeout (PE substitution headless reparse, mixed
124
+ models through %pe;, nested-group choice parse + real
125
+ backtracking) — PR #1724 (in CI).
126
+ - #1717 closed: the churn-crash report was slice-tooling shadowing,
127
+ engine exonerated.
128
+ - Engine issue board: ZERO open issues as of 2026-10-15.
110
129
 
111
130
  ## D. Bindings (user-owned repos — PRs only, never release)
112
131