leptris 1.9.408.0 → 1.9.410.0

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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/lib/leptris/vendor/aarch64-linux/libleptris.so +0 -0
  4. data/lib/leptris/vendor/aarch64-linux-musl/libleptris.so +0 -0
  5. data/lib/leptris/vendor/arm-linux/libleptris.so +0 -0
  6. data/lib/leptris/vendor/arm-linux-musl/libleptris.so +0 -0
  7. data/lib/leptris/vendor/arm64-darwin/libleptris.dylib +0 -0
  8. data/lib/leptris/vendor/ppc64le-linux/libleptris.so +0 -0
  9. data/lib/leptris/vendor/s390x-linux-musl/libleptris.so +0 -0
  10. data/lib/leptris/vendor/x86_64-darwin/libleptris.dylib +0 -0
  11. data/lib/leptris/vendor/x86_64-linux/libleptris.so +0 -0
  12. data/lib/leptris/vendor/x86_64-linux-musl/libleptris.so +0 -0
  13. data/lib/leptris/version.rb +1 -1
  14. data/vendor-src/README.md +1 -1
  15. data/vendor-src/libleptris/CHANGELOG.md +15 -0
  16. data/vendor-src/libleptris/CMakeLists.txt +1 -1
  17. data/vendor-src/libleptris/src/leptris/xsd/compile.c +69 -11
  18. data/vendor-src/libleptris/src/leptris/xsd/content_model.c +43 -10
  19. data/vendor-src/libleptris/src/leptris/xsd/validate.c +43 -8
  20. data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +8 -0
  21. data/vendor-src/libleptris/test/xsd/libxml2-cases/elemZ020-subst-ns/elemZ020.xml +8 -0
  22. data/vendor-src/libleptris/test/xsd/libxml2-cases/elemZ020-subst-ns/elemZ020.xsd +19 -0
  23. data/vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/roundtrip_a.xsd +16 -0
  24. data/vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/schG1_c.xsd +17 -0
  25. data/vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/schG2.xml +19 -0
  26. data/vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/schG2_a.xsd +27 -0
  27. data/vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/schG2_b.xsd +15 -0
  28. data/vendor-src/libleptris/test/xsd/test_i1957_1958.cpp +54 -0
  29. data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +122 -0
  30. data/vendor-src/libleptris/vcpkg.json +1 -1
  31. metadata +8 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34d1611db686219acbaed081b637a0c36b53959fedcba506b79b77802363f421
4
- data.tar.gz: 79a9c1ebfe9f121a760d341b24f2f30d85c3fff51522bf4ab6007ab20b09e9a3
3
+ metadata.gz: b5803f03685379a2ee802acb383c9c11a3d7b8ada32f6a3672c3848c8c798af6
4
+ data.tar.gz: d8ae60e2ecbe90f98f29c9186dd340f56d596dd5c079e5788218434b564f90f0
5
5
  SHA512:
6
- metadata.gz: 346ea572efb4315248b5b20eb5c03e4a29893f96002f74fce3d0b77f6d2d270414e48e2581e4c39739eb3d6b832443a56b3c9d4c8ace66709d06aa718b2e35e3
7
- data.tar.gz: 1f9a9215433bc6fb69a87becf524f3d25efd0e24e98a916e0dbf1efce8434255ca33f3b64b577cbdab99715ff7fb55c52c5d89da1b8e3d8508893a624ba8f6ad
6
+ metadata.gz: 5230208c2bfebdd9b04a53c1ba4c8f097a46a55d43aaa3f2c51f5fab7516db76672c57c572ea04754d6c68a7d9e8c64109eb07d2554aaa6d2a11a33d7a867944
7
+ data.tar.gz: 61a2ebb29178fd6d9c6162a1d16f672485eb03e226362a649d950c90315afb75c04ad9535ff0a55f34872163ecfe089582e6f1656c15ffcdb57c1923cf035782
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  # Pin for `rake compile` and the platform-gem builds. Keep in lockstep
9
9
  # with .github/workflows/build.yml (which calls `rake compile`) and the
10
10
  # CHANGELOG when libleptris releases.
11
- LIBLEPTRIS_VERSION = "1.9.408"
11
+ LIBLEPTRIS_VERSION = "1.9.410"
12
12
  # Vendored alongside libleptris for fn:normalize-unicode (TODO
13
13
  # .restructure/20): built per platform with a RELOCATABLE @rpath
14
14
  # install name, loaded by ffi.rb before libleptris so the
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.408.0"
4
+ VERSION = "1.9.410.0"
5
5
  end
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.408
4
+ - libleptris v1.9.410
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -1,5 +1,20 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.410] - 2026-11-05
4
+
5
+ ### Fixed
6
+
7
+ - **xsd**: a no-namespace element no longer resolves to a same-name **namespaced** global declaration. `xsd_find_element_child_ns`'s no-ns branch carried an ns-blind fallback that typed whole subtrees with a foreign namespace's type — the W3C schG2 shape (lutaml-xsd roundtrip compiles unit A alone; the instance's no-ns `<e1>` answered ns-a's `ct-A` and manufactured two false lexical rows). The fallback is removed; a no-ns element resolves only against true no-ns declarations (leptris#1976, PR #1977; full suite 2239/2239 with no corpus reliance on the fallback). Present since before 1.9.407 — it surfaced in the 1.9.409 wave only because the leptris lane replaced nokogiri as the active validator.
8
+
9
+
10
+ ## [1.9.409] - 2026-11-05
11
+
12
+ ### Fixed
13
+
14
+ - **xsd**: particle typing is NAMESPACE-AWARE — content-model capture records particle namespaces (ref-form resolves the QName; name-form reads @form/elementFormDefault), substitution members ride their own namespace (not the head particle's), and the gates are asymmetric per the pinned corpus posture: qualified particles admit no-ns children leniently, unqualified particles are strict with a fallback when no global declaration could type the child (leptris-rs#46; W3C elemZ020 vendored). Rounds out the v1.9.408 XSD wave (rs#45, #1969, #1964).
15
+
16
+
17
+
3
18
  ## [1.9.408] - 2026-11-05
4
19
 
5
20
  ### Fixed
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.408
6
+ VERSION 1.9.410
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -125,6 +125,9 @@ static XsdAssert* xsd_capture_assert(struct leptris_xsd_schema* s,
125
125
  LeptrisElement e);
126
126
  static XsdCm* xsd_capture_any(LeptrisElement any_child);
127
127
  static char* xsd_capture_unit_tns(LeptrisElement e);
128
+ static void xsd_resolve_qname(LeptrisElement e, const char* qname,
129
+ char* uri, size_t urisz, char* local,
130
+ size_t localsz);
128
131
  static char* xsd_capture_any_attr_ns(LeptrisElement container);
129
132
  static char* xsd_capture_any_attr_ns_deep(
130
133
  struct leptris_xsd_schema* s, LeptrisElement container, int depth);
@@ -272,11 +275,57 @@ static XsdCm* xsd_cm_parse(struct leptris_xsd_schema* s,
272
275
  } else if (strcmp(local, "element") == 0) {
273
276
  cm = xsd_cm_new(XSD_CM_ELEMENT);
274
277
  if (cm) {
275
- const char* nm =
276
- leptris_element_attribute(e, "name");
277
- if (!nm)
278
- nm = xsd_local_name(
279
- leptris_element_attribute(e, "ref"));
278
+ const char* ref_raw =
279
+ leptris_element_attribute(e, "ref");
280
+ const char* nm = NULL;
281
+ if (ref_raw) {
282
+ /* elemZ020: record the particle's namespace — a
283
+ * ref binds in the REFERENCED DECLARATION's ns
284
+ * (same-tns ref → tns, cross-ns → the foreign
285
+ * ns). The old capture kept the local name only,
286
+ * so the NFA and the typing DFS matched by name
287
+ * alone. */
288
+ nm = xsd_local_name(ref_raw);
289
+ char ruri[512], rlocal[256];
290
+ xsd_resolve_qname(e, ref_raw, ruri, sizeof(ruri),
291
+ rlocal, sizeof(rlocal));
292
+ if (ruri[0])
293
+ cm->ns = xsd_strdup(ruri);
294
+ else
295
+ cm->ns = xsd_capture_unit_tns(e);
296
+ } else {
297
+ nm = leptris_element_attribute(e, "name");
298
+ /* name-form: @form wins; otherwise the unit's
299
+ * elementFormDefault decides */
300
+ const char* form =
301
+ leptris_element_attribute(e, "form");
302
+ const char* efd = NULL;
303
+ if (!form) {
304
+ for (LeptrisElement up =
305
+ leptris_element_parent(e);
306
+ up; up = leptris_element_parent(up)) {
307
+ const char* ul = NULL;
308
+ leptris_element_expanded_name(
309
+ up, &ul, NULL, NULL);
310
+ if (ul && strcmp(ul, "schema") == 0) {
311
+ efd = leptris_element_attribute(
312
+ up, "elementFormDefault");
313
+ break;
314
+ }
315
+ }
316
+ }
317
+ int qualified =
318
+ form ? strcmp(form, "qualified") == 0
319
+ : (efd &&
320
+ strcmp(efd, "qualified") == 0);
321
+ if (qualified) {
322
+ char* tns = xsd_capture_unit_tns(e);
323
+ if (tns && tns[0])
324
+ cm->ns = tns;
325
+ else
326
+ free(tns);
327
+ }
328
+ }
280
329
  cm->name = xsd_strdup(nm);
281
330
  const char* pty =
282
331
  leptris_element_attribute(e, "type");
@@ -3379,14 +3428,19 @@ static const XsdElementDecl* xsd_find_element_decl(
3379
3428
  return NULL;
3380
3429
  }
3381
3430
 
3382
- int xsd_is_substitute(struct leptris_xsd_schema* s,
3383
- const char* name, const char* head) {
3431
+ const XsdElementDecl* xsd_substitute_member(
3432
+ struct leptris_xsd_schema* s, const char* name, const char* head) {
3384
3433
  const XsdElementDecl* d = xsd_find_element_decl(s, name);
3385
3434
  for (int hops = 0; d && d->sub_head && hops < 16; hops++) {
3386
- if (strcmp(d->sub_head, head) == 0) return 1;
3435
+ if (strcmp(d->sub_head, head) == 0) return d;
3387
3436
  d = xsd_find_element_decl(s, d->sub_head);
3388
3437
  }
3389
- return 0;
3438
+ return NULL;
3439
+ }
3440
+
3441
+ int xsd_is_substitute(struct leptris_xsd_schema* s,
3442
+ const char* name, const char* head) {
3443
+ return xsd_substitute_member(s, name, head) != NULL;
3390
3444
  }
3391
3445
 
3392
3446
  int xsd_schema_version_11(struct leptris_xsd_schema* s) {
@@ -3889,8 +3943,12 @@ const XsdElementDecl* xsd_find_element_child_ns(
3889
3943
  return xsd_ladder_element(s, name, uri, 0);
3890
3944
  for (XsdElementDecl* t = s->elements; t; t = t->next)
3891
3945
  if (!t->ns && strcmp(t->name, name) == 0) return t;
3892
- for (XsdElementDecl* t = s->elements; t; t = t->next)
3893
- if (strcmp(t->name, name) == 0) return t;
3946
+ /* leptris#1976: NO ns-blind fallback for a no-ns child. A
3947
+ * no-namespace element resolves only against true no-ns
3948
+ * declarations — matching a NAMESPACED global of the same name
3949
+ * typed whole subtrees with a foreign type and manufactured
3950
+ * false lexical rows (the schG2 roundtrip shape: a lone ns-a
3951
+ * unit answering the instance's no-ns <e1> with ns-a's ct-A). */
3894
3952
  return NULL;
3895
3953
  }
3896
3954
 
@@ -15,6 +15,13 @@
15
15
 
16
16
  #include "xsd_internal.h"
17
17
 
18
+ /* validate.c-facing global lookup (compile.c): an unqualified
19
+ * particle may leniently admit a namespaced child only when no
20
+ * global declaration in the child's namespace could type it
21
+ * (elemZ020 vs the OOXML-style wp.xsd corpus). */
22
+ extern const struct xsd_element_decl* xsd_find_element_child_ns(
23
+ struct leptris_xsd_schema* s, const char* name, const char* uri);
24
+
18
25
  typedef struct {
19
26
  int from;
20
27
  int symbol; /* -1 = epsilon; else a particle transition */
@@ -345,8 +352,11 @@ static int all_root_valid(XsdCm* all, const char* target_ns,
345
352
  size_t hits = 0;
346
353
  for (size_t i = 0; i < count; i++) {
347
354
  const char* uri = ns_uris ? ns_uris[i] : NULL;
348
- if (p->name && strcmp(p->name, names[i]) == 0 &&
349
- (!p->ns || (uri && strcmp(uri, p->ns) == 0)))
355
+ int child_qualified = uri && uri[0];
356
+ int ns_ok = p->ns ? (!child_qualified ||
357
+ strcmp(uri, p->ns) == 0)
358
+ : !child_qualified;
359
+ if (p->name && strcmp(p->name, names[i]) == 0 && ns_ok)
350
360
  hits++;
351
361
  }
352
362
  if ((long)hits < p->min) return 0;
@@ -357,8 +367,11 @@ static int all_root_valid(XsdCm* all, const char* target_ns,
357
367
  int matched = 0;
358
368
  const char* uri = ns_uris ? ns_uris[i] : NULL;
359
369
  for (XsdCm* p = all->first_child; p && !matched; p = p->next) {
360
- if (p->name && strcmp(p->name, names[i]) == 0 &&
361
- (!p->ns || (uri && strcmp(uri, p->ns) == 0)))
370
+ int child_qualified2 = uri && uri[0];
371
+ int ns_ok2 = p->ns ? (!child_qualified2 ||
372
+ strcmp(uri, p->ns) == 0)
373
+ : !child_qualified2;
374
+ if (p->name && strcmp(p->name, names[i]) == 0 && ns_ok2)
362
375
  matched = 1;
363
376
  }
364
377
  if (!matched) return 0;
@@ -408,12 +421,32 @@ int xsd_content_valid(struct leptris_xsd_schema* s, XsdCm* model,
408
421
  continue;
409
422
  XsdCm* p = tr->particle;
410
423
  if (p->kind == XSD_CM_ELEMENT) {
411
- int named = (strcmp(p->name, names[c]) == 0) ||
412
- (n.s && xsd_is_substitute(
413
- n.s, names[c], p->name));
414
- if (named &&
415
- (!p->ns || (uri && strcmp(uri, p->ns) == 0)))
416
- ss_add(&next, tr->to);
424
+ /* elemZ020: the ns gate is asymmetric — a
425
+ * qualified particle matches its own ns but
426
+ * leniently admits a no-ns child (the pinned
427
+ * #1871 corpus posture); an unqualified
428
+ * particle (ns NULL) is strict: no-ns children
429
+ * only. A substitute hit rides the MEMBER's
430
+ * own ns (cross-ns groups, #1881 sets). */
431
+ const char* pns = p->ns;
432
+ int named = (strcmp(p->name, names[c]) == 0);
433
+ if (!named && n.s) {
434
+ const XsdElementDecl* m =
435
+ xsd_substitute_member(n.s, names[c],
436
+ p->name);
437
+ if (m) {
438
+ named = 1;
439
+ if (m->ns) pns = m->ns;
440
+ }
441
+ }
442
+ int child_ns = uri && uri[0];
443
+ int pns_ok =
444
+ pns ? (!child_ns ||
445
+ (uri && strcmp(uri, pns) == 0))
446
+ : (!child_ns ||
447
+ (n.s && !xsd_find_element_child_ns(
448
+ n.s, names[c], uri)));
449
+ if (named && pns_ok) ss_add(&next, tr->to);
417
450
  } else if (p->kind == XSD_CM_ANY) {
418
451
  /* #1735: ##targetNamespace/##other are relative
419
452
  * to the DECLARING unit's tns */
@@ -599,6 +599,14 @@ static void validate_children(struct xsd_validator* v,
599
599
  if (wpc == 2) continue;
600
600
  const char* ptype = NULL;
601
601
  const char* pfill = NULL;
602
+ /* elemZ020 lenient fallback: an unqualified particle may
603
+ * still type a namespaced child when NO global declaration
604
+ * in the child's namespace could (the OOXML-style wp.xsd
605
+ * corpus: no elementFormDefault, no globals). The strict
606
+ * pass remembers the candidate; the global lookup below
607
+ * decides whether it is needed. */
608
+ const char* ltype = NULL;
609
+ const char* lfill = NULL;
602
610
  if (model) {
603
611
  XsdCm* stack[64];
604
612
  int sp = 0;
@@ -606,15 +614,34 @@ static void validate_children(struct xsd_validator* v,
606
614
  while (sp > 0 && ptype == NULL) {
607
615
  XsdCm* p = stack[--sp];
608
616
  for (; p; p = p->next) {
617
+ int child_ns = cu && cu[0];
618
+ /* asymmetric ns gate (elemZ020 + the pinned
619
+ * #1871 lenient posture): qualified particles
620
+ * match their own ns and leniently admit no-ns
621
+ * children; unqualified particles are strict —
622
+ * no-ns children only, with the lenient
623
+ * fallback when nothing else can type it. */
624
+ int pns_ok =
625
+ p->ns ? (!child_ns ||
626
+ strcmp(p->ns, cu) == 0)
627
+ : !child_ns;
609
628
  if (p->kind == XSD_CM_ELEMENT && p->name &&
610
629
  strcmp(p->name, cl) == 0 && p->type) {
611
- ptype = p->type;
612
- /* leptris-rs#35 (isDefault005): the
613
- * particle's fixed/default value satisfies
614
- * EMPTY content (§3.12.2). */
615
- pfill = p->fixed_value ? p->fixed_value
616
- : p->default_value;
617
- break;
630
+ if (pns_ok) {
631
+ ptype = p->type;
632
+ /* leptris-rs#35 (isDefault005): the
633
+ * particle's fixed/default value
634
+ * satisfies EMPTY content (§3.12.2). */
635
+ pfill = p->fixed_value ? p->fixed_value
636
+ : p->default_value;
637
+ break;
638
+ }
639
+ if (!ltype) {
640
+ ltype = p->type;
641
+ lfill = p->fixed_value
642
+ ? p->fixed_value
643
+ : p->default_value;
644
+ }
618
645
  }
619
646
  if (p->kind == XSD_CM_GROUP_REF) {
620
647
  XsdGroupDef* g = xsd_find_group(s, p->name);
@@ -650,7 +677,15 @@ static void validate_children(struct xsd_validator* v,
650
677
  } else {
651
678
  const XsdElementDecl* cd =
652
679
  xsd_find_element_child_ns(s, cl, cu);
653
- if (cd) validate_element_decl(v, s, ce, 0, cd);
680
+ if (cd)
681
+ validate_element_decl(v, s, ce, 0, cd);
682
+ else if (ltype) {
683
+ /* nothing global claims the namespaced child —
684
+ * the unqualified particle's type governs
685
+ * (wp.xsd corpus posture) */
686
+ validate_local(v, s, ce, cl, ltype, lfill,
687
+ ct ? ct->ns : NULL);
688
+ }
654
689
  }
655
690
  /* wildcard-admitted children without a declaration pass:
656
691
  * strict and lax alike admit undeclared names (the pinned
@@ -211,6 +211,14 @@ typedef struct xsd_element_decl {
211
211
  int xsd_is_substitute(struct leptris_xsd_schema* s,
212
212
  const char* name, const char* head);
213
213
 
214
+ /* elemZ020: the MEMBER declaration behind a substitute hit — the
215
+ * member carries its OWN namespace (a member in ns g rides a head
216
+ * particle written for ns f, XSD 1.1 cross-ns groups + schema-set
217
+ * compilation), so ns gates must compare against the member's ns,
218
+ * never the head particle's. */
219
+ const XsdElementDecl* xsd_substitute_member(
220
+ struct leptris_xsd_schema* s, const char* name, const char* head);
221
+
214
222
  typedef struct xsd_attr_decl {
215
223
  char* name; /* attribute local name */
216
224
  char* type; /* builtin ref or local simpleType name (NULL=anySimple) */
@@ -0,0 +1,8 @@
1
+ <foo:root
2
+ xmlns:foo="foo"
3
+ >
4
+ <foo:foo>true</foo:foo>
5
+ <foo>123</foo >
6
+ <foo:foo>true</foo:foo>
7
+ <foo>123</foo >
8
+ </foo:root>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0"?>
2
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3
+ elementFormDefault="qualified"
4
+ targetNamespace="foo"
5
+ xmlns="foo"
6
+ >
7
+ <xsd:element name="e1" type="xsd:boolean" />
8
+ <xsd:element name="foo" substitutionGroup="e1" type="xsd:boolean" />
9
+
10
+ <xsd:element name="root" type="B" />
11
+
12
+ <xsd:complexType name="B">
13
+ <xsd:choice maxOccurs="1000">
14
+ <xsd:element ref="e1" />
15
+ <xsd:element name="foo" type="xsd:int" form="unqualified"/>
16
+ </xsd:choice>
17
+ </xsd:complexType>
18
+
19
+ </xsd:schema>
@@ -0,0 +1,16 @@
1
+ <xsd:schema xmlns="ns-a" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="ns-a">
2
+ <xsd:complexType name="ct-A">
3
+ <xsd:sequence minOccurs="1">
4
+ <xsd:element name="a1" type="xsd:int"/>
5
+ <xsd:element name="a2" type="xsd:boolean"/>
6
+ </xsd:sequence>
7
+ </xsd:complexType>
8
+ <xsd:element name="e1" type="ct-A"/>
9
+ <xsd:element name="root">
10
+ <xsd:complexType>
11
+ <xsd:choice maxOccurs="unbounded">
12
+ <xsd:any namespace="##any" processContents="strict"/>
13
+ </xsd:choice>
14
+ </xsd:complexType>
15
+ </xsd:element>
16
+ </xsd:schema>
@@ -0,0 +1,17 @@
1
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
2
+ targetNamespace="ns-c"
3
+ xmlns="ns-c"
4
+ >
5
+
6
+ <xsd:complexType name="ct-A">
7
+ <xsd:sequence minOccurs="1">
8
+ <xsd:element name="a1" type="xsd:int" />
9
+ <xsd:element name="a2" type="xsd:int" />
10
+ </xsd:sequence>
11
+ </xsd:complexType>
12
+
13
+ <xsd:element name="e1" type="ct-A" />
14
+
15
+ </xsd:schema>
16
+
17
+
@@ -0,0 +1,19 @@
1
+ <a:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+ xsi:schemaLocation="ns-a schG2_a.xsd"
3
+ xmlns:a="ns-a"
4
+ xmlns:c="ns-c"
5
+ >
6
+ <a:e1>
7
+ <a1>123</a1>
8
+ <a2>true</a2>
9
+ </a:e1>
10
+ <e1>
11
+ <a1>true</a1>
12
+ <a2>123</a2>
13
+ </e1>
14
+ <c:e1>
15
+ <a1>123</a1>
16
+ <a2>123</a2>
17
+ </c:e1>
18
+
19
+ </a:root>
@@ -0,0 +1,27 @@
1
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
2
+ targetNamespace="ns-a"
3
+ xmlns="ns-a"
4
+ >
5
+
6
+ <xsd:import schemaLocation="schG2_b.xsd"/>
7
+
8
+ <xsd:complexType name="ct-A">
9
+ <xsd:sequence minOccurs="1">
10
+ <xsd:element name="a1" type="xsd:int" />
11
+ <xsd:element name="a2" type="xsd:boolean" />
12
+ </xsd:sequence>
13
+ </xsd:complexType>
14
+
15
+ <xsd:element name="e1" type="ct-A" />
16
+
17
+ <xsd:element name="root">
18
+ <xsd:complexType>
19
+ <xsd:choice maxOccurs="unbounded">
20
+ <xsd:any namespace="##any" processContents="strict"/>
21
+ </xsd:choice>
22
+ </xsd:complexType>
23
+ </xsd:element>
24
+
25
+ </xsd:schema>
26
+
27
+
@@ -0,0 +1,15 @@
1
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
2
+ >
3
+
4
+ <xsd:import namespace="ns-c" schemaLocation="schG1_c.xsd" />
5
+
6
+ <xsd:complexType name="ct-A">
7
+ <xsd:sequence minOccurs="1">
8
+ <xsd:element name="a1" type="xsd:boolean" />
9
+ <xsd:element name="a2" type="xsd:int" />
10
+ </xsd:sequence>
11
+ </xsd:complexType>
12
+
13
+ <xsd:element name="e1" type="ct-A" />
14
+
15
+ </xsd:schema>
@@ -123,3 +123,57 @@ TEST(XsdUnionFixed, NonMemberValueStillRejects) {
123
123
  leptris_document_free(d);
124
124
  leptris_xsd_free(s);
125
125
  }
126
+
127
+ // ---- leptris-rs#46 (elemZ020): particle typing is ns-aware ------
128
+ // Real W3C fixture msData/element/elemZ020: a form="unqualified"
129
+ // local particle (xs:int) and a same-name substitution member
130
+ // (xs:boolean) discriminate by namespace. The namespaced child
131
+ // types through its member declaration; the no-ns child types
132
+ // through the unqualified particle.
133
+
134
+ TEST(XsdSubstNs, ElemZ020RealFixtureValidates) {
135
+ EXPECT_EQ(validate_case(cases_path("elemZ020-subst-ns/elemZ020.xsd"),
136
+ cases_path("elemZ020-subst-ns/elemZ020.xml")),
137
+ 1);
138
+ }
139
+
140
+ TEST(XsdSubstNs, NamespacedChildTypedByMemberNotUnqualifiedParticle) {
141
+ LeptrisStatus st = LEPTRIS_OK;
142
+ LeptrisXsdSchema s = leptris_xsd_compile_file(
143
+ cases_path("elemZ020-subst-ns/elemZ020.xsd").c_str(), &st);
144
+ ASSERT_NE(s, (LeptrisXsdSchema)0);
145
+ /* "true" is boolean (the member), not int (the unqualified
146
+ * particle) — the ns-strict member binding types it. */
147
+ const char q[] = "<?xml version=\"1.0\"?>\n"
148
+ "<foo:root xmlns:foo=\"foo\">"
149
+ "<foo:foo>true</foo:foo></foo:root>";
150
+ LeptrisDocument d = leptris_parse_string(q, strlen(q), &st);
151
+ ASSERT_NE(d, nullptr);
152
+ EXPECT_EQ(leptris_xsd_validate(s, d), 1);
153
+ leptris_document_free(d);
154
+ /* int lexical in the member's slot still rejects */
155
+ const char bad[] = "<?xml version=\"1.0\"?>\n"
156
+ "<foo:root xmlns:foo=\"foo\">"
157
+ "<foo:foo>123</foo:foo></foo:root>";
158
+ d = leptris_parse_string(bad, strlen(bad), &st);
159
+ ASSERT_NE(d, nullptr);
160
+ EXPECT_EQ(leptris_xsd_validate(s, d), 0);
161
+ leptris_document_free(d);
162
+ /* the no-ns child rides the form="unqualified" particle */
163
+ const char u[] = "<?xml version=\"1.0\"?>\n"
164
+ "<foo:root xmlns:foo=\"foo\">"
165
+ "<foo>123</foo></foo:root>";
166
+ d = leptris_parse_string(u, strlen(u), &st);
167
+ ASSERT_NE(d, nullptr);
168
+ EXPECT_EQ(leptris_xsd_validate(s, d), 1);
169
+ leptris_document_free(d);
170
+ /* boolean lexical in the unqualified particle's slot rejects */
171
+ const char bad2[] = "<?xml version=\"1.0\"?>\n"
172
+ "<foo:root xmlns:foo=\"foo\">"
173
+ "<foo>true</foo></foo:root>";
174
+ d = leptris_parse_string(bad2, strlen(bad2), &st);
175
+ ASSERT_NE(d, nullptr);
176
+ EXPECT_EQ(leptris_xsd_validate(s, d), 0);
177
+ leptris_document_free(d);
178
+ leptris_xsd_free(s);
179
+ }
@@ -1256,6 +1256,81 @@ TEST(XsdCompile, StrictAnyAttrGrammarRidesAttributeGroupRefs) {
1256
1256
  leptris_xsd_free(s);
1257
1257
  }
1258
1258
 
1259
+ // leptris#1976: the 1.9.409 ns-aware particle typing must not
1260
+ // disturb the A(ns)/B(no-ns) import composition — W3C schG2 (valid).
1261
+ // The no-ns global e1 types through B's ct-A (a1:boolean, a2:int);
1262
+ // the ns-a e1 types through A's ct-A (a1:int, a2:boolean).
1263
+ TEST(XsdValidate, SchG2ImportComposeStaysValid) {
1264
+ LeptrisStatus st = LEPTRIS_OK;
1265
+ LeptrisXsdSchema s = leptris_xsd_compile_file(
1266
+ LEPTRIS_XSD_CASES_DIR
1267
+ "/schG2-import-compose/schG2_a.xsd", &st);
1268
+ ASSERT_NE(s, (LeptrisXsdSchema)0) << "status " << (int)st;
1269
+ LeptrisDocument d = leptris_parse_file(
1270
+ LEPTRIS_XSD_CASES_DIR
1271
+ "/schG2-import-compose/schG2.xml", &st);
1272
+ ASSERT_NE(d, nullptr) << "status " << (int)st;
1273
+ EXPECT_EQ(leptris_xsd_validate(s, d), 1);
1274
+ for (size_t i = 0; i < leptris_xsd_error_count(s); i++)
1275
+ ADD_FAILURE() << leptris_xsd_error_at(s, i);
1276
+ leptris_document_free(d);
1277
+ leptris_xsd_free(s);
1278
+ }
1279
+
1280
+ // #1976 variant: the same composition through leptris_xsd_compile_set
1281
+ // (the lutaml-xsd EngineContext path) — both unit orders must stay valid.
1282
+ TEST(XsdValidate, SchG2CompileSetBothOrdersValid) {
1283
+ LeptrisStatus st = LEPTRIS_OK;
1284
+ const char* paths_ab[] = {
1285
+ LEPTRIS_XSD_CASES_DIR "/schG2-import-compose/schG2_a.xsd",
1286
+ LEPTRIS_XSD_CASES_DIR "/schG2-import-compose/schG2_b.xsd",
1287
+ };
1288
+ const char* paths_ba[] = {
1289
+ LEPTRIS_XSD_CASES_DIR "/schG2-import-compose/schG2_b.xsd",
1290
+ LEPTRIS_XSD_CASES_DIR "/schG2-import-compose/schG2_a.xsd",
1291
+ };
1292
+ const char* doc_paths[] = {
1293
+ LEPTRIS_XSD_CASES_DIR "/schG2-import-compose/schG2.xml",
1294
+ };
1295
+ for (int order = 0; order < 2; order++) {
1296
+ LeptrisXsdSchema s = leptris_xsd_compile_set(
1297
+ order == 0 ? paths_ab : paths_ba, 2, &st);
1298
+ ASSERT_NE(s, (LeptrisXsdSchema)0) << "status " << (int)st;
1299
+ LeptrisDocument d = leptris_parse_file(doc_paths[0], &st);
1300
+ ASSERT_NE(d, nullptr) << "status " << (int)st;
1301
+ EXPECT_EQ(leptris_xsd_validate(s, d), 1) << "order " << order;
1302
+ for (size_t i = 0; i < leptris_xsd_error_count(s); i++)
1303
+ ADD_FAILURE() << "order " << order << ": "
1304
+ << leptris_xsd_error_at(s, i);
1305
+ leptris_document_free(d);
1306
+ leptris_xsd_free(s);
1307
+ }
1308
+ }
1309
+
1310
+ // #1976 root cause face: the lutaml-xsd roundtrip drops the import,
1311
+ // so the engine compiles unit A ALONE (e1/ct-A/root, all ns-a; the
1312
+ // default xmlns="ns-a" preserved). The instance's no-ns <e1> then
1313
+ // meets ONLY ns-a declarations: the strict wildcard reports it
1314
+ // undeclared, and its children a1/a2 typed... by whom? This pins
1315
+ // whatever the engine does here so the fix has a regression gate.
1316
+ TEST(XsdValidate, SchG2RoundtripUnitAAlone) {
1317
+ LeptrisStatus st = LEPTRIS_OK;
1318
+ LeptrisXsdSchema s = leptris_xsd_compile_file(
1319
+ LEPTRIS_XSD_CASES_DIR
1320
+ "/schG2-import-compose/roundtrip_a.xsd", &st);
1321
+ ASSERT_NE(s, (LeptrisXsdSchema)0) << "status " << (int)st;
1322
+ LeptrisDocument d = leptris_parse_file(
1323
+ LEPTRIS_XSD_CASES_DIR
1324
+ "/schG2-import-compose/schG2.xml", &st);
1325
+ ASSERT_NE(d, nullptr) << "status " << (int)st;
1326
+ EXPECT_EQ(leptris_xsd_validate(s, d), 1)
1327
+ << leptris_xsd_error_at(s, 0);
1328
+ for (size_t i = 0; i < leptris_xsd_error_count(s); i++)
1329
+ ADD_FAILURE() << leptris_xsd_error_at(s, i);
1330
+ leptris_document_free(d);
1331
+ leptris_xsd_free(s);
1332
+ }
1333
+
1259
1334
  TEST(XsdValidate, ValidDocumentPasses) {
1260
1335
  EXPECT_EQ(validate_doc(k_v_schema,
1261
1336
  "<rows version=\"2\" status=\"ok\">"
@@ -1461,6 +1536,53 @@ TEST(XsdDatatypes, TemporalEnumerationComparesByValue) {
1461
1536
  leptris_xsd_free(s);
1462
1537
  }
1463
1538
 
1539
+ // W3C XSD suite msData/element/elemZ020: particle typing is
1540
+ // NAMESPACE-aware. A form="unqualified" local particle types only
1541
+ // no-namespace children; a namespaced child of the same local name
1542
+ // types through its own (substitution-member) declaration. The
1543
+ // first-name-match DFS bound BOTH to whichever same-name particle
1544
+ // it saw first (elemZ020: 'true' failed xsd:int, '123' failed
1545
+ // xsd:boolean).
1546
+ TEST(XsdValidate, ParticleTypingIsNamespaceAware) {
1547
+ const char* sch =
1548
+ "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""
1549
+ " elementFormDefault=\"qualified\" targetNamespace=\"foo\""
1550
+ " xmlns=\"foo\">"
1551
+ "<xsd:element name=\"e1\" type=\"xsd:boolean\"/>"
1552
+ "<xsd:element name=\"foo\" substitutionGroup=\"e1\""
1553
+ " type=\"xsd:boolean\"/>"
1554
+ "<xsd:element name=\"root\" type=\"B\"/>"
1555
+ "<xsd:complexType name=\"B\">"
1556
+ "<xsd:choice maxOccurs=\"1000\">"
1557
+ "<xsd:element ref=\"e1\"/>"
1558
+ "<xsd:element name=\"foo\" type=\"xsd:int\""
1559
+ " form=\"unqualified\"/>"
1560
+ "</xsd:choice></xsd:complexType></xsd:schema>";
1561
+ /* namespaced member: typed by its own boolean declaration */
1562
+ EXPECT_EQ(validate_doc(sch,
1563
+ "<?xml version=\"1.0\"?>\n"
1564
+ "<foo:root xmlns:foo=\"foo\"><foo:foo>true</foo:foo>"
1565
+ "</foo:root>"), 1);
1566
+ /* no-namespace child: typed by the unqualified local particle */
1567
+ EXPECT_EQ(validate_doc(sch,
1568
+ "<?xml version=\"1.0\"?>\n"
1569
+ "<foo:root xmlns:foo=\"foo\"><foo>123</foo></foo:root>"), 1);
1570
+ /* the full suite doc: both shapes interleaved [valid] */
1571
+ EXPECT_EQ(validate_doc(sch,
1572
+ "<?xml version=\"1.0\"?>\n"
1573
+ "<foo:root xmlns:foo=\"foo\"><foo:foo>true</foo:foo>"
1574
+ "<foo>123</foo><foo:foo>true</foo:foo><foo>123</foo>"
1575
+ "</foo:root>"), 1);
1576
+ /* wrong content for each binding still rejects */
1577
+ EXPECT_EQ(validate_doc(sch,
1578
+ "<?xml version=\"1.0\"?>\n"
1579
+ "<foo:root xmlns:foo=\"foo\"><foo:foo>123</foo:foo>"
1580
+ "</foo:root>"), 0);
1581
+ EXPECT_EQ(validate_doc(sch,
1582
+ "<?xml version=\"1.0\"?>\n"
1583
+ "<foo:root xmlns:foo=\"foo\"><foo>true</foo></foo:root>"), 0);
1584
+ }
1585
+
1464
1586
  TEST(XsdValidate, ContentModelViolationReports) {
1465
1587
  EXPECT_EQ(validate_doc(k_v_schema,
1466
1588
  "<rows version=\"1\">"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
3
3
  "name": "leptris",
4
- "version": "1.9.408",
4
+ "version": "1.9.410",
5
5
  "description": "High-performance XML parser and XPath 1.0 engine in C (libleptris)",
6
6
  "homepage": "https://github.com/leptris/leptris",
7
7
  "license": "MIT",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.408.0
4
+ version: 1.9.410.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -1377,6 +1377,8 @@ files:
1377
1377
  - vendor-src/libleptris/test/xsd/libxml2-cases/dur_0.xsd
1378
1378
  - vendor-src/libleptris/test/xsd/libxml2-cases/elem0_0.xml
1379
1379
  - vendor-src/libleptris/test/xsd/libxml2-cases/elem0_0.xsd
1380
+ - vendor-src/libleptris/test/xsd/libxml2-cases/elemZ020-subst-ns/elemZ020.xml
1381
+ - vendor-src/libleptris/test/xsd/libxml2-cases/elemZ020-subst-ns/elemZ020.xsd
1380
1382
  - vendor-src/libleptris/test/xsd/libxml2-cases/element-err_0.xml
1381
1383
  - vendor-src/libleptris/test/xsd/libxml2-cases/element-err_0.xsd
1382
1384
  - vendor-src/libleptris/test/xsd/libxml2-cases/element-minmax-err_0.xml
@@ -1560,6 +1562,11 @@ files:
1560
1562
  - vendor-src/libleptris/test/xsd/libxml2-cases/scc-no-xmlns_0.xsd
1561
1563
  - vendor-src/libleptris/test/xsd/libxml2-cases/scc-no-xsi_0.xml
1562
1564
  - vendor-src/libleptris/test/xsd/libxml2-cases/scc-no-xsi_0.xsd
1565
+ - vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/roundtrip_a.xsd
1566
+ - vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/schG1_c.xsd
1567
+ - vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/schG2.xml
1568
+ - vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/schG2_a.xsd
1569
+ - vendor-src/libleptris/test/xsd/libxml2-cases/schG2-import-compose/schG2_b.xsd
1563
1570
  - vendor-src/libleptris/test/xsd/libxml2-cases/schema_set/f.xsd
1564
1571
  - vendor-src/libleptris/test/xsd/libxml2-cases/schema_set/g.xsd
1565
1572
  - vendor-src/libleptris/test/xsd/libxml2-cases/seq-dubl-elem1_0.xml