leptris 1.9.404.0-arm-linux → 1.9.405.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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/ext/leptris/native/native.c +60 -0
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/native.so +0 -0
- data/lib/leptris/xml/native_3_3.so +0 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +38 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +180 -13
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +102 -17
- data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +5 -0
- data/vendor-src/libleptris/test/CMakeLists.txt +3 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/i1957/instance.xml +2 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/i1957/schema.xsd +16 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schF1.xml +14 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schF1_a.xsd +28 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schF1_b.xsd +14 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schP2.xml +2 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schP2_a.xsd +27 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schP2_b.xsd +12 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/addB104.xml +6 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/addB104.xsd +19 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/attO006.xml +4 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/attO006.xsd +15 -0
- data/vendor-src/libleptris/test/xsd/test_i1957_1958.cpp +90 -0
- data/vendor-src/libleptris/test/xsd/test_rs35_regression.cpp +11 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +14 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d7f427bdc1b5850277bfe9794d2f94738d431ec1cc644647715c584a9d10fa8
|
|
4
|
+
data.tar.gz: 2d0042d2ca1a43b6ee1d3e2380d865c708ccd462cb3a9986b004eceb74562be7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba1296b756eb70bfbd451402443e828c76e96ee629f8f69886f594273d3e8f3e37636090ee59b8d98bf76edfc6d9e58b189604cc8598b9c171fa7e9302997142
|
|
7
|
+
data.tar.gz: ec51a62d7001673295cbdc26cfcd971c3ac1358edbffd717d5025c3e9f2bb5455f0903fc6ade786f2827fafaeb987b3208ef65fc2a60d249122f968b659df208
|
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.
|
|
11
|
+
LIBLEPTRIS_VERSION = "1.9.405"
|
|
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
|
data/ext/leptris/native/native.c
CHANGED
|
@@ -2782,6 +2782,64 @@ static VALUE nf_walk_columnar(VALUE self, VALUE root)
|
|
|
2782
2782
|
return rb_ary_new3(3, names, handles, depths);
|
|
2783
2783
|
}
|
|
2784
2784
|
|
|
2785
|
+
/* ---- Raw-address columnar walk (leptris-ruby#587) ----------------
|
|
2786
|
+
* The identity-free read lane: the preorder/depths contract of
|
|
2787
|
+
* walk_columnar (#527), but the handles lane carries RAW NODE
|
|
2788
|
+
* ADDRESSES as Integers instead of minted NativeNodes — addresses
|
|
2789
|
+
* are immediates in CRuby, so a whole-subtree read walk allocates
|
|
2790
|
+
* nothing per node beyond the three arrays, mints nothing, and
|
|
2791
|
+
* writes nothing into the per-document identity cache. Names are
|
|
2792
|
+
* interned fstrings exactly as walk_columnar produces them.
|
|
2793
|
+
*
|
|
2794
|
+
* Read-only consumers resolve everything through the address-keyed
|
|
2795
|
+
* faces (fast_name, fast_element_text, attribute_pairs, ...). A
|
|
2796
|
+
* consumer that later needs a mutable, identity-backed handle
|
|
2797
|
+
* mints it through the normal wrap path — the write lane is
|
|
2798
|
+
* unchanged. This is the shadow-binding read half: Ruby objects
|
|
2799
|
+
* exist only where the consumer holds state, never per visited
|
|
2800
|
+
* node. */
|
|
2801
|
+
static void walk_addresses_impl(void *node, int depth, VALUE names,
|
|
2802
|
+
VALUE addrs, VALUE depths)
|
|
2803
|
+
{
|
|
2804
|
+
int kind = f_node_type(node);
|
|
2805
|
+
void *c;
|
|
2806
|
+
|
|
2807
|
+
if (kind == WS_NODE_ELEMENT) {
|
|
2808
|
+
const char *name = f_elem_name(node);
|
|
2809
|
+
rb_ary_push(names, name
|
|
2810
|
+
? rb_enc_interned_str(name, strlen(name),
|
|
2811
|
+
rb_utf8_encoding())
|
|
2812
|
+
: Qnil);
|
|
2813
|
+
rb_ary_push(addrs, ULL2NUM((uint64_t)(uintptr_t)node));
|
|
2814
|
+
rb_ary_push(depths, INT2NUM(depth));
|
|
2815
|
+
for (c = f_first_child(node); c; c = f_next_sibling(c)) {
|
|
2816
|
+
walk_addresses_impl(c, depth + 1, names, addrs, depths);
|
|
2817
|
+
}
|
|
2818
|
+
} else if (kind == WS_NODE_TEXT || kind == WS_NODE_COMMENT ||
|
|
2819
|
+
kind == WS_NODE_CDATA || kind == WS_NODE_PI) {
|
|
2820
|
+
rb_ary_push(names, Qnil);
|
|
2821
|
+
rb_ary_push(addrs, ULL2NUM((uint64_t)(uintptr_t)node));
|
|
2822
|
+
rb_ary_push(depths, INT2NUM(depth));
|
|
2823
|
+
} else if (kind == WS_NODE_DOCTYPE || kind == 9 /* DOCUMENT */) {
|
|
2824
|
+
for (c = f_first_child(node); c; c = f_next_sibling(c)) {
|
|
2825
|
+
walk_addresses_impl(c, depth, names, addrs, depths);
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
static VALUE nf_walk_addresses(VALUE self, VALUE root)
|
|
2831
|
+
{
|
|
2832
|
+
struct native_node *n;
|
|
2833
|
+
VALUE names, addrs, depths;
|
|
2834
|
+
(void)self;
|
|
2835
|
+
TypedData_Get_Struct(root, struct native_node, &nn_type, n);
|
|
2836
|
+
names = rb_ary_new();
|
|
2837
|
+
addrs = rb_ary_new();
|
|
2838
|
+
depths = rb_ary_new();
|
|
2839
|
+
walk_addresses_impl(n->ptr, 0, names, addrs, depths);
|
|
2840
|
+
return rb_ary_new3(3, names, addrs, depths);
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2785
2843
|
/* ---- Struct plan executor (moxml "miles faster" round) ------------
|
|
2786
2844
|
* The consumer's shape compiles to spec: name (interned String) ->
|
|
2787
2845
|
* [Struct class, attrs Hash (name -> slot Symbol), text slot Symbol
|
|
@@ -4200,6 +4258,8 @@ static void leptris_native_setup(void)
|
|
|
4200
4258
|
nf_snapshot_rows, 2);
|
|
4201
4259
|
rb_define_module_function(m_native, "walk_columnar",
|
|
4202
4260
|
nf_walk_columnar, 1);
|
|
4261
|
+
rb_define_module_function(m_native, "walk_addresses",
|
|
4262
|
+
nf_walk_addresses, 1);
|
|
4203
4263
|
rb_define_module_function(m_native, "attribute_pairs",
|
|
4204
4264
|
nf_attribute_pairs, 2);
|
|
4205
4265
|
rb_define_module_function(m_native, "plan_structs",
|
data/lib/leptris/version.rb
CHANGED
data/lib/leptris/xml/native.so
CHANGED
|
Binary file
|
|
Binary file
|
data/lib/libleptris.so
CHANGED
|
Binary file
|
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.405] - 2026-11-03
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **XSD: the leptris-rs#36 attribute leg** — an attribute with
|
|
8
|
+
`fixed` whose instance lexical differs only in whitespace was
|
|
9
|
+
rejected by the raw strcmp. The fixed constraint holds on the
|
|
10
|
+
TYPE's value (§3.2.3/§4.3.1.2): when the raw comparison fails,
|
|
11
|
+
both sides normalize per the type's whiteSpace and compare again
|
|
12
|
+
(addB104, attO006 — xsd:integer whitespace variants).
|
|
13
|
+
|
|
14
|
+
- **XSD: nested attributeGroup refs (leptris#1957)** — an inner
|
|
15
|
+
`attributeGroup ref` naming a group declared LATER expanded empty,
|
|
16
|
+
rejecting level-2 members under strict admission (attgD005..034,
|
|
17
|
+
attJ018). The pre-pass registers every def first and captures rows
|
|
18
|
+
in a second sweep; the ref expansion re-captures lazily through
|
|
19
|
+
the def's own element. A complexType whose content model is only
|
|
20
|
+
an attributeGroup ref + `mixed="true"` no longer reports "the
|
|
21
|
+
content model is empty".
|
|
22
|
+
|
|
23
|
+
- **XSD: multi-document component resolution (leptris#1958)** — an
|
|
24
|
+
import of a no-targetNamespace document kept the importer's tns
|
|
25
|
+
during capture (chameleon semantics are include-only, §4.2.3), so
|
|
26
|
+
its same-named complexType shadowed the importing namespace's own
|
|
27
|
+
declaration and swapped particle types (schF1). The content-model
|
|
28
|
+
child loop binds a no-namespace child to its own no-tns
|
|
29
|
+
declaration first; `xs:redefine` of a simpleType aliases the
|
|
30
|
+
original so the facet chain resolves to the redefinition (schP2's
|
|
31
|
+
minLength enforced).
|
|
32
|
+
|
|
33
|
+
- **Descriptor: retained captured sub-documents until schema
|
|
34
|
+
teardown** — the #1957 lazy attributeGroup expansion holds element
|
|
35
|
+
pointers into their own unit; freeing sub-documents at chase time
|
|
36
|
+
left them dangling (heap-use-after-free under ASAN in the corpus
|
|
37
|
+
sweep).
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
3
41
|
## [1.9.404] - 2026-11-03
|
|
4
42
|
|
|
5
43
|
### Fixed
|
|
@@ -62,6 +62,12 @@ struct leptris_xsd_schema {
|
|
|
62
62
|
* re-captures the whole subtree (multi-GB / minutes). */
|
|
63
63
|
char** visited;
|
|
64
64
|
size_t visited_len, visited_cap;
|
|
65
|
+
/* leptris#1957: captured sub-documents stay ALIVE until schema
|
|
66
|
+
* teardown — attributeGroup defs hold LeptrisElement pointers
|
|
67
|
+
* into their own unit for the lazy ref expansion, and freeing
|
|
68
|
+
* the sub-document at chase time left those dangling (ASAN
|
|
69
|
+
* heap-use-after-free in the corpus sweep). */
|
|
70
|
+
struct xsd_sub_doc* sub_docs;
|
|
65
71
|
void* validator; /* slice-4 parked error list */
|
|
66
72
|
char* error;
|
|
67
73
|
/* #1841: materialized structured report — rebuilt per
|
|
@@ -550,6 +556,11 @@ static ret_type fn_name(struct leptris_xsd_schema* s, const char* name, \
|
|
|
550
556
|
return t; \
|
|
551
557
|
return NULL; \
|
|
552
558
|
} \
|
|
559
|
+
/* NULL uri: the reference itself is namespace-free — unstamped \
|
|
560
|
+
* declarations bind FIRST (leptris#1958: an imported \
|
|
561
|
+
* no-targetNamespace type must win its own reference over the \
|
|
562
|
+
* importing namespace's same-name type), then the policy allows \
|
|
563
|
+
* the name-only sweep across the merged table. */ \
|
|
553
564
|
for (ret_type t = s->list_field; t; t = t->next) \
|
|
554
565
|
if (strcmp(t->name_field, name) == 0) \
|
|
555
566
|
return t; \
|
|
@@ -558,6 +569,25 @@ static ret_type fn_name(struct leptris_xsd_schema* s, const char* name, \
|
|
|
558
569
|
|
|
559
570
|
XSD_DEFINE_NS_LADDER(const XsdElementDecl*, xsd_ladder_element, elements,
|
|
560
571
|
name, ns)
|
|
572
|
+
|
|
573
|
+
/* leptris#1958: a NULL-namespace INSTANCE element binds its own
|
|
574
|
+
* no-targetNamespace declaration FIRST — the importing namespace's
|
|
575
|
+
* same-name global (registered later, prepended earlier in the
|
|
576
|
+
* merged list) must not shadow it. Stamped references keep the
|
|
577
|
+
* macro's ladder. */
|
|
578
|
+
const XsdElementDecl* xsd_ladder_element_ns_free_first(
|
|
579
|
+
struct leptris_xsd_schema* s, const char* name, const char* uri,
|
|
580
|
+
int allow_name_only) {
|
|
581
|
+
if (!s || !name) return NULL;
|
|
582
|
+
if (uri && uri[0])
|
|
583
|
+
return xsd_ladder_element(s, name, uri, allow_name_only);
|
|
584
|
+
for (XsdElementDecl* t = s->elements; t; t = t->next)
|
|
585
|
+
if (!t->ns && strcmp(t->name, name) == 0) return t;
|
|
586
|
+
if (!allow_name_only) return NULL;
|
|
587
|
+
for (XsdElementDecl* t = s->elements; t; t = t->next)
|
|
588
|
+
if (strcmp(t->name, name) == 0) return t;
|
|
589
|
+
return NULL;
|
|
590
|
+
}
|
|
561
591
|
XSD_DEFINE_NS_LADDER(XsdCm*, xsd_ladder_complex, complex_types, name, ns)
|
|
562
592
|
XSD_DEFINE_NS_LADDER(const XsdSimple*, xsd_ladder_simple, simple_types,
|
|
563
593
|
name, ns)
|
|
@@ -2293,6 +2323,23 @@ static int xsd_visited_has(struct leptris_xsd_schema* s,
|
|
|
2293
2323
|
return 0;
|
|
2294
2324
|
}
|
|
2295
2325
|
|
|
2326
|
+
struct xsd_sub_doc {
|
|
2327
|
+
LeptrisDocument doc;
|
|
2328
|
+
struct xsd_sub_doc* next;
|
|
2329
|
+
};
|
|
2330
|
+
|
|
2331
|
+
static void xsd_sub_doc_retain(struct leptris_xsd_schema* s,
|
|
2332
|
+
LeptrisDocument doc) {
|
|
2333
|
+
struct xsd_sub_doc* node =
|
|
2334
|
+
(struct xsd_sub_doc*)calloc(1, sizeof(*node));
|
|
2335
|
+
if (!node) return; /* retention is best-effort; the freed-elem
|
|
2336
|
+
lazy path is never taken for eagerly
|
|
2337
|
+
captured defs */
|
|
2338
|
+
node->doc = doc;
|
|
2339
|
+
node->next = (struct xsd_sub_doc*)s->sub_docs;
|
|
2340
|
+
s->sub_docs = node;
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2296
2343
|
static void xsd_visited_add(struct leptris_xsd_schema* s,
|
|
2297
2344
|
const char* path) {
|
|
2298
2345
|
if (s->visited_len == s->visited_cap) {
|
|
@@ -2313,20 +2360,29 @@ static XsdAttrDecl* xsd_capture_attr_rows(
|
|
|
2313
2360
|
* PRE-PASS — the symbol space is order-free, but the ref expansion
|
|
2314
2361
|
* in xsd_capture_attr_rows looks up s->attr_groups at capture time,
|
|
2315
2362
|
* so a group declared AFTER the referencing type used to vanish. */
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2363
|
+
/* Phase 1 registers the def (name + element) only; phase 2
|
|
2364
|
+
* captures the rows once EVERY top-level group is registered —
|
|
2365
|
+
* leptris#1957: an inner attributeGroup ref naming a group that
|
|
2366
|
+
* appears LATER in the document used to expand empty. */
|
|
2367
|
+
static void xsd_register_attr_group_def(struct leptris_xsd_schema* s,
|
|
2368
|
+
LeptrisElement n,
|
|
2369
|
+
const char* nm) {
|
|
2319
2370
|
XsdAttrGroupDef* g = (XsdAttrGroupDef*)calloc(1, sizeof(*g));
|
|
2320
2371
|
if (!g) return;
|
|
2321
2372
|
g->name = xsd_strdup(nm);
|
|
2322
|
-
g->
|
|
2373
|
+
g->elem = n;
|
|
2323
2374
|
g->next = s->attr_groups;
|
|
2324
2375
|
s->attr_groups = g;
|
|
2325
2376
|
}
|
|
2326
2377
|
|
|
2327
2378
|
static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
2328
2379
|
LeptrisElement root) {
|
|
2329
|
-
/* pre-pass: every top-level attributeGroup def
|
|
2380
|
+
/* pre-pass phase 1: register every top-level attributeGroup def
|
|
2381
|
+
* (name + element), document order — the symbol space is
|
|
2382
|
+
* order-free. Phase 2 captures the rows once ALL defs are
|
|
2383
|
+
* registered, so an inner attributeGroup ref naming a LATER
|
|
2384
|
+
* group resolves (leptris#1957: level-2 members used to
|
|
2385
|
+
* vanish). */
|
|
2330
2386
|
for (LeptrisNodeRef n =
|
|
2331
2387
|
leptris_node_first_child(leptris_element_as_node(root));
|
|
2332
2388
|
n; n = leptris_node_next_sibling(n)) {
|
|
@@ -2342,8 +2398,11 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2342
2398
|
const char* nm = leptris_element_attribute((LeptrisElement)n,
|
|
2343
2399
|
"name");
|
|
2344
2400
|
if (!nm) continue;
|
|
2345
|
-
|
|
2401
|
+
xsd_register_attr_group_def(s, (LeptrisElement)n, nm);
|
|
2346
2402
|
}
|
|
2403
|
+
for (XsdAttrGroupDef* g = s->attr_groups; g; g = g->next)
|
|
2404
|
+
if (!g->attrs && g->elem)
|
|
2405
|
+
g->attrs = xsd_capture_attr_rows(s, g->elem, 0);
|
|
2347
2406
|
for (LeptrisNodeRef n =
|
|
2348
2407
|
leptris_node_first_child(leptris_element_as_node(root));
|
|
2349
2408
|
n; n = leptris_node_next_sibling(n)) {
|
|
@@ -2416,11 +2475,23 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2416
2475
|
(strcmp(local, "import") == 0 || same_ns)) {
|
|
2417
2476
|
/* leptris-ruby#440/#439: each captured
|
|
2418
2477
|
* unit stamps ITS OWN targetNamespace on
|
|
2419
|
-
* its declarations — chameleon
|
|
2420
|
-
* (no tns) adopt the includer's.
|
|
2478
|
+
* its declarations — chameleon INCLUDES
|
|
2479
|
+
* (no tns) adopt the includer's.
|
|
2480
|
+
* leptris#1958: an IMPORT of a
|
|
2481
|
+
* no-targetNamespace document keeps its
|
|
2482
|
+
* declarations namespace-FREE (XSD 1.0
|
|
2483
|
+
* §4.2.3 — chameleon semantics are
|
|
2484
|
+
* include-only); stamping the importer's
|
|
2485
|
+
* tns made its same-named components
|
|
2486
|
+
* shadow the importing namespace's own
|
|
2487
|
+
* (schF1: the imported ct-A won the
|
|
2488
|
+
* (ns-a, ct-A) exact ladder slot and
|
|
2489
|
+
* swapped a1/a2's types). */
|
|
2421
2490
|
char* saved_ns = s->target_ns;
|
|
2422
2491
|
char* sub_ns = tns ? xsd_strdup(tns) : NULL;
|
|
2423
2492
|
if (sub_ns) s->target_ns = sub_ns;
|
|
2493
|
+
else if (strcmp(local, "import") == 0)
|
|
2494
|
+
s->target_ns = NULL;
|
|
2424
2495
|
s->include_depth++;
|
|
2425
2496
|
xsd_capture_root(s, subroot);
|
|
2426
2497
|
s->include_depth--;
|
|
@@ -2446,8 +2517,47 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2446
2517
|
xsd_capture_root(s, (LeptrisElement)n);
|
|
2447
2518
|
s->capture_force = 0;
|
|
2448
2519
|
s->include_depth--;
|
|
2520
|
+
/* leptris#1958 (schP2): a redefined
|
|
2521
|
+
* simpleType's restriction base names the
|
|
2522
|
+
* ORIGINAL definition — both share the
|
|
2523
|
+
* name, and the name-only chain lookup
|
|
2524
|
+
* (head-first = the replacement) would
|
|
2525
|
+
* self-loop. Rename the original to a
|
|
2526
|
+
* hidden alias and repoint the
|
|
2527
|
+
* replacement's base at it; every OTHER
|
|
2528
|
+
* reference keeps resolving to the
|
|
2529
|
+
* replacement (head-first). */
|
|
2530
|
+
for (XsdSimple* t = s->simple_types; t;
|
|
2531
|
+
t = t->next) {
|
|
2532
|
+
if (!t->base || strcmp(t->base, t->name) != 0)
|
|
2533
|
+
continue;
|
|
2534
|
+
XsdSimple* other = NULL;
|
|
2535
|
+
for (XsdSimple* o = s->simple_types; o;
|
|
2536
|
+
o = o->next) {
|
|
2537
|
+
if (o == t) continue;
|
|
2538
|
+
if (o->name &&
|
|
2539
|
+
strcmp(o->name, t->name) == 0) {
|
|
2540
|
+
other = o;
|
|
2541
|
+
break;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
if (!other) continue;
|
|
2545
|
+
size_t alen = strlen(other->name) + 24;
|
|
2546
|
+
char* alias =
|
|
2547
|
+
(char*)malloc(alen);
|
|
2548
|
+
if (!alias) continue;
|
|
2549
|
+
snprintf(alias, alen, "%s#rb%p",
|
|
2550
|
+
other->name, (void*)other);
|
|
2551
|
+
free(other->name);
|
|
2552
|
+
other->name = alias;
|
|
2553
|
+
free(t->base);
|
|
2554
|
+
t->base = xsd_strdup(alias);
|
|
2555
|
+
}
|
|
2449
2556
|
}
|
|
2450
|
-
|
|
2557
|
+
/* leptris#1957: retained — attributeGroup
|
|
2558
|
+
* defs hold elements from this unit for the
|
|
2559
|
+
* lazy ref expansion; freed at teardown. */
|
|
2560
|
+
xsd_sub_doc_retain(s, sub);
|
|
2451
2561
|
}
|
|
2452
2562
|
free(text);
|
|
2453
2563
|
}
|
|
@@ -2593,8 +2703,16 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2593
2703
|
XsdAttrGroupDef* seen = s->attr_groups;
|
|
2594
2704
|
for (; seen; seen = seen->next)
|
|
2595
2705
|
if (strcmp(seen->name, nm) == 0) break;
|
|
2596
|
-
if (!seen || s->capture_force)
|
|
2597
|
-
|
|
2706
|
+
if (!seen || s->capture_force) {
|
|
2707
|
+
/* Sub-document defs register + capture inline —
|
|
2708
|
+
* their own inner refs ride the same lazy
|
|
2709
|
+
* expansion (leptris#1957). */
|
|
2710
|
+
xsd_register_attr_group_def(s, (LeptrisElement)n, nm);
|
|
2711
|
+
XsdAttrGroupDef* rg = s->attr_groups;
|
|
2712
|
+
if (rg && !rg->attrs)
|
|
2713
|
+
rg->attrs =
|
|
2714
|
+
xsd_capture_attr_rows(s, rg->elem, 0);
|
|
2715
|
+
}
|
|
2598
2716
|
}
|
|
2599
2717
|
} else if (strcmp(local, "group") == 0 && uri && !strcmp(uri, XSD_NS)) {
|
|
2600
2718
|
const char* nm =
|
|
@@ -2663,6 +2781,15 @@ static void xsd_free_simple_one(XsdSimple* t) {
|
|
|
2663
2781
|
LEPTRIS_API void leptris_xsd_free(LeptrisXsdSchema schema) {
|
|
2664
2782
|
struct leptris_xsd_schema* s = (struct leptris_xsd_schema*)schema;
|
|
2665
2783
|
if (!s) return;
|
|
2784
|
+
/* leptris#1957: retained sub-documents last — attributeGroup
|
|
2785
|
+
* defs' LeptrisElement pointers live inside them. */
|
|
2786
|
+
struct xsd_sub_doc* sd = (struct xsd_sub_doc*)s->sub_docs;
|
|
2787
|
+
while (sd) {
|
|
2788
|
+
struct xsd_sub_doc* sn = sd->next;
|
|
2789
|
+
leptris_document_free(sd->doc);
|
|
2790
|
+
free(sd);
|
|
2791
|
+
sd = sn;
|
|
2792
|
+
}
|
|
2666
2793
|
free(s->report);
|
|
2667
2794
|
xsd_cm_free(s->complex_types);
|
|
2668
2795
|
XsdElementIcs* slot = s->element_ics;
|
|
@@ -3451,8 +3578,15 @@ static XsdAttrDecl* xsd_capture_attr_rows(struct leptris_xsd_schema* s,
|
|
|
3451
3578
|
XsdAttrGroupDef* g = s->attr_groups;
|
|
3452
3579
|
for (; g; g = g->next)
|
|
3453
3580
|
if (strcmp(g->name, ref) == 0) break;
|
|
3454
|
-
if (!g
|
|
3455
|
-
|
|
3581
|
+
if (!g) continue;
|
|
3582
|
+
/* leptris#1957: expand lazily through the def's own
|
|
3583
|
+
* element when its rows are not captured yet (a group
|
|
3584
|
+
* registered in phase 1 whose phase-2 capture has not
|
|
3585
|
+
* run, or runs later in document order). depth+1 keeps
|
|
3586
|
+
* the cycle guard. */
|
|
3587
|
+
XsdAttrDecl* copied =
|
|
3588
|
+
g->attrs ? xsd_copy_attr_rows(g->attrs)
|
|
3589
|
+
: xsd_capture_attr_rows(s, g->elem, depth + 1);
|
|
3456
3590
|
if (!copied) continue;
|
|
3457
3591
|
if (!head)
|
|
3458
3592
|
head = copied;
|
|
@@ -3703,6 +3837,23 @@ const XsdElementDecl* xsd_find_element_ns(
|
|
|
3703
3837
|
return xsd_ladder_element(s, name, uri, 0);
|
|
3704
3838
|
}
|
|
3705
3839
|
|
|
3840
|
+
/* leptris#1958: the CONTENT-MODEL child loop's lookup — a
|
|
3841
|
+
* no-namespace instance child binds its own no-targetNamespace
|
|
3842
|
+
* declaration FIRST (the importing namespace's same-name global
|
|
3843
|
+
* sits ahead in the merged list and must not shadow it). Root and
|
|
3844
|
+
* global lookups keep the stock ladder. */
|
|
3845
|
+
const XsdElementDecl* xsd_find_element_child_ns(
|
|
3846
|
+
struct leptris_xsd_schema* s, const char* name, const char* uri) {
|
|
3847
|
+
if (!s || !name) return NULL;
|
|
3848
|
+
if (uri && uri[0])
|
|
3849
|
+
return xsd_ladder_element(s, name, uri, 0);
|
|
3850
|
+
for (XsdElementDecl* t = s->elements; t; t = t->next)
|
|
3851
|
+
if (!t->ns && strcmp(t->name, name) == 0) return t;
|
|
3852
|
+
for (XsdElementDecl* t = s->elements; t; t = t->next)
|
|
3853
|
+
if (strcmp(t->name, name) == 0) return t;
|
|
3854
|
+
return NULL;
|
|
3855
|
+
}
|
|
3856
|
+
|
|
3706
3857
|
XsdCm* xsd_find_complex(struct leptris_xsd_schema* s,
|
|
3707
3858
|
const char* type_name) {
|
|
3708
3859
|
if (!s || !type_name) return NULL;
|
|
@@ -3721,6 +3872,22 @@ XsdCm* xsd_find_complex_ns(struct leptris_xsd_schema* s,
|
|
|
3721
3872
|
return xsd_ladder_complex(s, type_name, uri, 0);
|
|
3722
3873
|
}
|
|
3723
3874
|
|
|
3875
|
+
/* leptris#1958: the ns-FREE reference — a no-targetNamespace
|
|
3876
|
+
* declaration's unprefixed type binds ITS OWN unit's (unstamped)
|
|
3877
|
+
* component first; the importing namespace's same-name type (which
|
|
3878
|
+
* sits ahead in the merged list) must not shadow it. Used only by
|
|
3879
|
+
* the validator's decl-driven fallback (hint == NULL, instance
|
|
3880
|
+
* namespace absent) — every other lookup keeps the stock ladder. */
|
|
3881
|
+
XsdCm* xsd_find_complex_ns_free_first(struct leptris_xsd_schema* s,
|
|
3882
|
+
const char* type_name) {
|
|
3883
|
+
if (!s || !type_name) return NULL;
|
|
3884
|
+
for (XsdCm* t = s->complex_types; t; t = t->next)
|
|
3885
|
+
if (!t->ns && strcmp(t->name, type_name) == 0) return t;
|
|
3886
|
+
for (XsdCm* t = s->complex_types; t; t = t->next)
|
|
3887
|
+
if (strcmp(t->name, type_name) == 0) return t;
|
|
3888
|
+
return NULL;
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3724
3891
|
/* leptris-ruby#440 (follow-up): a TYPE REFERENCE on an instance
|
|
3725
3892
|
* element resolves against the namespace the REFERENCE declares —
|
|
3726
3893
|
* OOXML's dml family types every wp:/pic: particle with
|
|
@@ -36,10 +36,14 @@ extern const XsdElementDecl* xsd_find_element_ns(
|
|
|
36
36
|
struct leptris_xsd_schema* s, const char* name, const char* uri);
|
|
37
37
|
extern const XsdElementDecl* xsd_find_element(
|
|
38
38
|
struct leptris_xsd_schema* s, const char* name);
|
|
39
|
+
extern const XsdElementDecl* xsd_find_element_child_ns(
|
|
40
|
+
struct leptris_xsd_schema* s, const char* name, const char* uri);
|
|
39
41
|
extern XsdCm* xsd_find_complex_ns(struct leptris_xsd_schema* s,
|
|
40
42
|
const char* type_name, const char* uri);
|
|
41
43
|
extern XsdCm* xsd_find_complex_ref(struct leptris_xsd_schema* s,
|
|
42
44
|
const char* type_name, const char* uri);
|
|
45
|
+
extern XsdCm* xsd_find_complex_ns_free_first(struct leptris_xsd_schema* s,
|
|
46
|
+
const char* type_name);
|
|
43
47
|
XsdCm* xsd_find_complex(struct leptris_xsd_schema* s, const char* type_name);
|
|
44
48
|
extern const XsdSimple* xsd_find_simple_ns_pub(
|
|
45
49
|
struct leptris_xsd_schema* s, const char* name, const char* uri);
|
|
@@ -297,15 +301,21 @@ static int text_valid(struct xsd_validator* v,
|
|
|
297
301
|
static void validate_element(struct xsd_validator* v,
|
|
298
302
|
struct leptris_xsd_schema* s,
|
|
299
303
|
LeptrisElement elem, int depth);
|
|
304
|
+
static void validate_element_decl(struct xsd_validator* v,
|
|
305
|
+
struct leptris_xsd_schema* s,
|
|
306
|
+
LeptrisElement elem, int depth,
|
|
307
|
+
const XsdElementDecl* decl_override);
|
|
300
308
|
static void validate_local(struct xsd_validator* v,
|
|
301
309
|
struct leptris_xsd_schema* s,
|
|
302
310
|
LeptrisElement elem, const char* local,
|
|
303
|
-
const char* type, const char* fill
|
|
311
|
+
const char* type, const char* fill,
|
|
312
|
+
const char* tns_hint);
|
|
304
313
|
static void validate_local_uri(struct xsd_validator* v,
|
|
305
314
|
struct leptris_xsd_schema* s,
|
|
306
315
|
LeptrisElement elem, const char* local,
|
|
307
316
|
const char* type, const char* euri,
|
|
308
|
-
const char* xsi_q, const char* fill
|
|
317
|
+
const char* xsi_q, const char* fill,
|
|
318
|
+
const char* tns_hint);
|
|
309
319
|
|
|
310
320
|
/* #1879: the strongest processContents among the model's wildcards
|
|
311
321
|
* whose namespace grammar admits (uri) — 2 skip, 1 lax, 0 strict,
|
|
@@ -549,13 +559,16 @@ static void validate_children(struct xsd_validator* v,
|
|
|
549
559
|
"xsi:type prefix is not bound in the instance");
|
|
550
560
|
} else {
|
|
551
561
|
validate_local_uri(v, s, ce, cl, xlocal, xuri, cxsi,
|
|
552
|
-
pfill);
|
|
562
|
+
pfill, NULL);
|
|
553
563
|
}
|
|
554
564
|
} else {
|
|
555
|
-
validate_local(v, s, ce, cl, ptype, pfill
|
|
565
|
+
validate_local(v, s, ce, cl, ptype, pfill,
|
|
566
|
+
ct ? ct->ns : NULL);
|
|
556
567
|
}
|
|
557
|
-
} else
|
|
558
|
-
|
|
568
|
+
} else {
|
|
569
|
+
const XsdElementDecl* cd =
|
|
570
|
+
xsd_find_element_child_ns(s, cl, cu);
|
|
571
|
+
if (cd) validate_element_decl(v, s, ce, 0, cd);
|
|
559
572
|
}
|
|
560
573
|
/* wildcard-admitted children without a declaration pass:
|
|
561
574
|
* strict and lax alike admit undeclared names (the pinned
|
|
@@ -665,6 +678,43 @@ static int any_attr_matches(const char* grammar, const char* uri,
|
|
|
665
678
|
return 0;
|
|
666
679
|
}
|
|
667
680
|
|
|
681
|
+
/* leptris-rs#36 (addB104, attO006): the fixed constraint holds on
|
|
682
|
+
* the TYPE's value, not the raw lexical (XSD 1.0 §3.2.3/§4.3.1.2) —
|
|
683
|
+
* a whitespace-variant lexical of a collapsing type (token family,
|
|
684
|
+
* numeric) is the same value. Normalize both per the type's
|
|
685
|
+
* whiteSpace and compare. */
|
|
686
|
+
static int attr_fixed_matches(struct leptris_xsd_schema* s,
|
|
687
|
+
const char* type, const char* ns,
|
|
688
|
+
const char* val, const char* fixed) {
|
|
689
|
+
if (!type) return 0;
|
|
690
|
+
if (!type_collapses_ws(s, type, ns)) return 0;
|
|
691
|
+
char norm_v[512];
|
|
692
|
+
char norm_f[512];
|
|
693
|
+
size_t n = strlen(val);
|
|
694
|
+
if (n >= sizeof(norm_v)) return 0;
|
|
695
|
+
size_t m = strlen(fixed);
|
|
696
|
+
if (m >= sizeof(norm_f)) return 0;
|
|
697
|
+
for (int pass = 0; pass < 2; pass++) {
|
|
698
|
+
const char* src = pass ? fixed : val;
|
|
699
|
+
char* out = pass ? norm_f : norm_v;
|
|
700
|
+
char* o = out;
|
|
701
|
+
const char* p = src;
|
|
702
|
+
while (*p && isspace((unsigned char)*p)) p++;
|
|
703
|
+
int spaced = 0;
|
|
704
|
+
while (*p) {
|
|
705
|
+
if (isspace((unsigned char)*p)) {
|
|
706
|
+
spaced = 1;
|
|
707
|
+
p++;
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
if (spaced) { *o++ = ' '; spaced = 0; }
|
|
711
|
+
*o++ = *p++;
|
|
712
|
+
}
|
|
713
|
+
*o = 0;
|
|
714
|
+
}
|
|
715
|
+
return strcmp(norm_v, norm_f) == 0;
|
|
716
|
+
}
|
|
717
|
+
|
|
668
718
|
static void validate_attributes(struct xsd_validator* v,
|
|
669
719
|
struct leptris_xsd_schema* s,
|
|
670
720
|
LeptrisElement elem,
|
|
@@ -703,7 +753,9 @@ static void validate_attributes(struct xsd_validator* v,
|
|
|
703
753
|
}
|
|
704
754
|
text_valid(v, s, a->type, val, ta ? ta->ns : NULL, "attribute",
|
|
705
755
|
a->name, elem);
|
|
706
|
-
if (a->fixed && strcmp(val, a->fixed) != 0
|
|
756
|
+
if (a->fixed && strcmp(val, a->fixed) != 0 &&
|
|
757
|
+
!attr_fixed_matches(s, a->type, ta ? ta->ns : NULL, val,
|
|
758
|
+
a->fixed))
|
|
707
759
|
verrf_atk(v, elem, "attribute-use", a->name, "attribute",
|
|
708
760
|
a->name, "value does not match the fixed value");
|
|
709
761
|
}
|
|
@@ -798,13 +850,24 @@ static void validate_attributes(struct xsd_validator* v,
|
|
|
798
850
|
static void validate_element(struct xsd_validator* v,
|
|
799
851
|
struct leptris_xsd_schema* s,
|
|
800
852
|
LeptrisElement elem, int depth) {
|
|
853
|
+
validate_element_decl(v, s, elem, depth, NULL);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/* decl_override: the CALLER's ns-free declaration find (the content
|
|
857
|
+
* model child loop's leptris#1958 semantics) — NULL = resolve here. */
|
|
858
|
+
static void validate_element_decl(struct xsd_validator* v,
|
|
859
|
+
struct leptris_xsd_schema* s,
|
|
860
|
+
LeptrisElement elem, int depth,
|
|
861
|
+
const XsdElementDecl* decl_override) {
|
|
801
862
|
if (depth > 64) return;
|
|
802
863
|
const char* local = NULL, *prefix = NULL, *uri = NULL;
|
|
803
864
|
leptris_element_expanded_name(elem, &local, &prefix, &uri);
|
|
804
865
|
if (!local) return;
|
|
805
866
|
const char* guri = NULL;
|
|
806
867
|
leptris_element_expanded_name(elem, NULL, NULL, &guri);
|
|
807
|
-
const XsdElementDecl* d =
|
|
868
|
+
const XsdElementDecl* d =
|
|
869
|
+
decl_override ? decl_override
|
|
870
|
+
: xsd_find_element_ns(s, local, guri);
|
|
808
871
|
if (!d) {
|
|
809
872
|
/* strict: the instance uses an element the schema never
|
|
810
873
|
* declared (a local particle would have typed it) */
|
|
@@ -882,10 +945,11 @@ static void validate_element(struct xsd_validator* v,
|
|
|
882
945
|
return;
|
|
883
946
|
}
|
|
884
947
|
validate_local_uri(v, s, elem, local, xlocal, xuri, xsi_q,
|
|
885
|
-
fill);
|
|
948
|
+
fill, NULL);
|
|
886
949
|
return;
|
|
887
950
|
}
|
|
888
|
-
validate_local(v, s, elem, local, eff_type, fill
|
|
951
|
+
validate_local(v, s, elem, local, eff_type, fill,
|
|
952
|
+
d->ns);
|
|
889
953
|
}
|
|
890
954
|
|
|
891
955
|
/* Validate one element against a type name that comes from a
|
|
@@ -894,22 +958,43 @@ static void validate_element(struct xsd_validator* v,
|
|
|
894
958
|
static void validate_local(struct xsd_validator* v,
|
|
895
959
|
struct leptris_xsd_schema* s,
|
|
896
960
|
LeptrisElement elem, const char* local,
|
|
897
|
-
const char* type, const char* fill
|
|
961
|
+
const char* type, const char* fill,
|
|
962
|
+
const char* tns_hint);
|
|
963
|
+
static void validate_local_uri(struct xsd_validator* v,
|
|
964
|
+
struct leptris_xsd_schema* s,
|
|
965
|
+
LeptrisElement elem, const char* local,
|
|
966
|
+
const char* type, const char* euri,
|
|
967
|
+
const char* xsi_q, const char* fill,
|
|
968
|
+
const char* tns_hint);
|
|
969
|
+
|
|
970
|
+
static void validate_local(struct xsd_validator* v,
|
|
971
|
+
struct leptris_xsd_schema* s,
|
|
972
|
+
LeptrisElement elem, const char* local,
|
|
973
|
+
const char* type, const char* fill,
|
|
974
|
+
const char* tns_hint) {
|
|
898
975
|
const char* euri = NULL;
|
|
899
976
|
leptris_element_expanded_name(elem, NULL, NULL, &euri);
|
|
900
|
-
validate_local_uri(v, s, elem, local, type, euri, NULL, fill
|
|
977
|
+
validate_local_uri(v, s, elem, local, type, euri, NULL, fill,
|
|
978
|
+
tns_hint);
|
|
901
979
|
}
|
|
902
980
|
|
|
903
981
|
static void validate_local_uri(struct xsd_validator* v,
|
|
904
982
|
struct leptris_xsd_schema* s,
|
|
905
983
|
LeptrisElement elem, const char* local,
|
|
906
984
|
const char* type, const char* euri,
|
|
907
|
-
const char* xsi_q, const char* fill
|
|
985
|
+
const char* xsi_q, const char* fill,
|
|
986
|
+
const char* tns_hint) {
|
|
908
987
|
if (!type) return;
|
|
909
|
-
/* the
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
|
|
988
|
+
/* leptris#1958: the DECLARING unit's targetNamespace binds the
|
|
989
|
+
* type reference first — a no-targetNamespace declaration's
|
|
990
|
+
* unprefixed type must resolve to ITS OWN unit's component, not
|
|
991
|
+
* the importing namespace's same-name type (schF1). The
|
|
992
|
+
* instance-ns reference ladder remains the fallback (OOXML:
|
|
993
|
+
* wp:extent -> a:CT_PositiveSize2D — #1687). */
|
|
994
|
+
XsdCm* ct = tns_hint ? xsd_find_complex_ns(s, type, tns_hint) : NULL;
|
|
995
|
+
if (!ct && (!euri || !euri[0]))
|
|
996
|
+
ct = xsd_find_complex_ns_free_first(s, type);
|
|
997
|
+
if (!ct) ct = xsd_find_complex_ref(s, type, euri);
|
|
913
998
|
/* XSD 1.0 §2.7/§3.3.3 (leptris-rs#26, particlesIa002/
|
|
914
999
|
* QFE1700g2): a NILLED element must have neither character nor
|
|
915
1000
|
* element content — the content model is not applied (the nil
|
|
@@ -255,6 +255,11 @@ typedef struct xsd_element_ics {
|
|
|
255
255
|
typedef struct xsd_attrgroup_def {
|
|
256
256
|
char* name;
|
|
257
257
|
XsdAttrDecl* attrs;
|
|
258
|
+
/* leptris#1957: the definition's own element — the ref
|
|
259
|
+
* expansion RE-CAPTURES it lazily so an inner attributeGroup ref
|
|
260
|
+
* naming a LATER-registered group resolves (document-order
|
|
261
|
+
* capture used to leave level-2 members unexpanded). */
|
|
262
|
+
LeptrisElement elem;
|
|
258
263
|
struct xsd_attrgroup_def* next;
|
|
259
264
|
} XsdAttrGroupDef;
|
|
260
265
|
|
|
@@ -156,6 +156,9 @@ target_compile_definitions(test_xsd_compile PRIVATE
|
|
|
156
156
|
leptris_add_test(test_rs35_regression xsd/test_rs35_regression.cpp)
|
|
157
157
|
target_compile_definitions(test_rs35_regression PRIVATE
|
|
158
158
|
LEPTRIS_XSD_CASES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/xsd/libxml2-cases")
|
|
159
|
+
leptris_add_test(test_i1957_1958 xsd/test_i1957_1958.cpp)
|
|
160
|
+
target_compile_definitions(test_i1957_1958 PRIVATE
|
|
161
|
+
LEPTRIS_XSD_CASES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/xsd/libxml2-cases")
|
|
159
162
|
target_compile_definitions(test_rng PRIVATE
|
|
160
163
|
LEPTRIS_RNG_INCLUDE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/rng/include-cases")
|
|
161
164
|
leptris_add_test(test_rng_corpus rng/test_rng_corpus.cpp)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
|
3
|
+
<xsd:attribute name="att1" type="xsd:string"/>
|
|
4
|
+
<xsd:element name="doc">
|
|
5
|
+
<xsd:complexType mixed="true">
|
|
6
|
+
<xsd:attributeGroup ref="main"/>
|
|
7
|
+
</xsd:complexType>
|
|
8
|
+
</xsd:element>
|
|
9
|
+
<xsd:attributeGroup name="main">
|
|
10
|
+
<xsd:attribute ref="att1"/>
|
|
11
|
+
<xsd:attributeGroup ref="sub"/>
|
|
12
|
+
</xsd:attributeGroup>
|
|
13
|
+
<xsd:attributeGroup name="sub">
|
|
14
|
+
<xsd:attribute name="foo" type="xsd:int"/>
|
|
15
|
+
</xsd:attributeGroup>
|
|
16
|
+
</xsd:schema>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
2
|
+
targetNamespace="ns-a"
|
|
3
|
+
xmlns:a="ns-a"
|
|
4
|
+
elementFormDefault="qualified"
|
|
5
|
+
>
|
|
6
|
+
|
|
7
|
+
<xsd:import schemaLocation="schF1_b.xsd"/>
|
|
8
|
+
|
|
9
|
+
<xsd:complexType name="ct-A">
|
|
10
|
+
<xsd:sequence minOccurs="1">
|
|
11
|
+
<xsd:element name="a1" type="xsd:int" />
|
|
12
|
+
<xsd:element name="a2" type="xsd:boolean" />
|
|
13
|
+
</xsd:sequence>
|
|
14
|
+
</xsd:complexType>
|
|
15
|
+
|
|
16
|
+
<xsd:element name="e1" type="a:ct-A" />
|
|
17
|
+
|
|
18
|
+
<xsd:element name="root">
|
|
19
|
+
<xsd:complexType>
|
|
20
|
+
<xsd:choice maxOccurs="unbounded">
|
|
21
|
+
<xsd:any namespace="##any" processContents="strict"/>
|
|
22
|
+
</xsd:choice>
|
|
23
|
+
</xsd:complexType>
|
|
24
|
+
</xsd:element>
|
|
25
|
+
|
|
26
|
+
</xsd:schema>
|
|
27
|
+
|
|
28
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
2
|
+
elementFormDefault="qualified"
|
|
3
|
+
>
|
|
4
|
+
|
|
5
|
+
<xsd:complexType name="ct-A">
|
|
6
|
+
<xsd:sequence minOccurs="1">
|
|
7
|
+
<xsd:element name="a1" type="xsd:boolean" />
|
|
8
|
+
<xsd:element name="a2" type="xsd:int" />
|
|
9
|
+
</xsd:sequence>
|
|
10
|
+
</xsd:complexType>
|
|
11
|
+
|
|
12
|
+
<xsd:element name="e1" type="ct-A" />
|
|
13
|
+
|
|
14
|
+
</xsd:schema>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
2
|
+
targetNamespace="ns-a"
|
|
3
|
+
xmlns="ns-a"
|
|
4
|
+
elementFormDefault="qualified"
|
|
5
|
+
>
|
|
6
|
+
|
|
7
|
+
<xsd:redefine schemaLocation="schP2_b.xsd">
|
|
8
|
+
<xsd:simpleType name="b-st">
|
|
9
|
+
<xsd:restriction base="b-st">
|
|
10
|
+
<xsd:minLength value="4"/>
|
|
11
|
+
</xsd:restriction>
|
|
12
|
+
</xsd:simpleType>
|
|
13
|
+
</xsd:redefine>
|
|
14
|
+
|
|
15
|
+
<xsd:element name="e1" type="b-st" />
|
|
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,12 @@
|
|
|
1
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
2
|
+
targetNamespace="ns-a"
|
|
3
|
+
xmlns="ns-a"
|
|
4
|
+
elementFormDefault="qualified"
|
|
5
|
+
>
|
|
6
|
+
<xsd:simpleType name="b-st">
|
|
7
|
+
<xsd:restriction base="xsd:string"/>
|
|
8
|
+
</xsd:simpleType>
|
|
9
|
+
|
|
10
|
+
<xsd:element name="b-e1" type="b-st" />
|
|
11
|
+
|
|
12
|
+
</xsd:schema>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
3
|
+
targetNamespace="ns"
|
|
4
|
+
xmlns:x='ns'
|
|
5
|
+
elementFormDefault="qualified"
|
|
6
|
+
attributeFormDefault="qualified">
|
|
7
|
+
|
|
8
|
+
<xsd:element name="doc">
|
|
9
|
+
<xsd:complexType>
|
|
10
|
+
<xsd:choice>
|
|
11
|
+
<xsd:element name="elem" >
|
|
12
|
+
<xsd:complexType>
|
|
13
|
+
<xsd:attribute name="att" type="xsd:integer" fixed=" 123 "/>
|
|
14
|
+
</xsd:complexType>
|
|
15
|
+
</xsd:element>
|
|
16
|
+
</xsd:choice>
|
|
17
|
+
</xsd:complexType>
|
|
18
|
+
</xsd:element>
|
|
19
|
+
</xsd:schema>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xsdtesting" xmlns:x="http://xsdtesting" elementFormDefault="qualified" attributeFormDefault="qualified">
|
|
3
|
+
<xsd:element name="doc">
|
|
4
|
+
<xsd:complexType>
|
|
5
|
+
<xsd:choice>
|
|
6
|
+
<xsd:element name="elem">
|
|
7
|
+
<xsd:complexType>
|
|
8
|
+
<xsd:attribute name="att" type="xsd:integer" fixed=" 123 ">
|
|
9
|
+
</xsd:attribute>
|
|
10
|
+
</xsd:complexType>
|
|
11
|
+
</xsd:element>
|
|
12
|
+
</xsd:choice>
|
|
13
|
+
</xsd:complexType>
|
|
14
|
+
</xsd:element>
|
|
15
|
+
</xsd:schema>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// leptris#1957 + leptris#1958 — two XSD component-resolution defects.
|
|
2
|
+
//
|
|
3
|
+
// #1957: nested attributeGroup refs — the level-2 members of a group
|
|
4
|
+
// referenced from inside another attributeGroup are rejected by
|
|
5
|
+
// strict admission (the pre-pass captures group defs in document
|
|
6
|
+
// order, so an inner ref that names a LATER group expands empty);
|
|
7
|
+
// and a complexType whose content model is only an attributeGroup
|
|
8
|
+
// ref + mixed="true" reported "the content model is empty".
|
|
9
|
+
//
|
|
10
|
+
// #1958: multi-document component resolution — an imported
|
|
11
|
+
// no-targetNamespace same-named complexType shadowed the importing
|
|
12
|
+
// namespace's own declaration, and xs:redefine'd simpleTypes were
|
|
13
|
+
// not registered ("type not found in the schema").
|
|
14
|
+
#include <gtest/gtest.h>
|
|
15
|
+
|
|
16
|
+
#include <cstdio>
|
|
17
|
+
#include <cstring>
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
#include "leptris.h"
|
|
21
|
+
|
|
22
|
+
namespace {
|
|
23
|
+
|
|
24
|
+
#ifndef LEPTRIS_XSD_CASES_DIR
|
|
25
|
+
#define LEPTRIS_XSD_CASES_DIR "libxml2-cases"
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
std::string cases_path(const char* sub) {
|
|
29
|
+
return std::string(LEPTRIS_XSD_CASES_DIR) + "/" + sub;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
int validate_case(const std::string& schema, const std::string& doc) {
|
|
33
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
34
|
+
LeptrisXsdSchema s =
|
|
35
|
+
leptris_xsd_compile_file(schema.c_str(), &st);
|
|
36
|
+
if (!s) return -1;
|
|
37
|
+
LeptrisDocument d = leptris_parse_file(doc.c_str(), &st);
|
|
38
|
+
if (!d) {
|
|
39
|
+
leptris_xsd_free(s);
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
int ok = leptris_xsd_validate(s, d);
|
|
43
|
+
if (getenv("I1958_VERBOSE"))
|
|
44
|
+
for (size_t i = 0; i < leptris_xsd_error_count(s); i++)
|
|
45
|
+
printf(" err: %s\n", leptris_xsd_error_at(s, i));
|
|
46
|
+
leptris_document_free(d);
|
|
47
|
+
leptris_xsd_free(s);
|
|
48
|
+
return ok;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
} // namespace
|
|
52
|
+
|
|
53
|
+
TEST(I1957, NestedAttrGroupLevel2AdmitsAndMixedAdmitsText) {
|
|
54
|
+
EXPECT_EQ(validate_case(cases_path("i1957/schema.xsd"),
|
|
55
|
+
cases_path("i1957/instance.xml")),
|
|
56
|
+
1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
TEST(I1958, ImportedSameNameTypeDoesNotShadow) {
|
|
60
|
+
EXPECT_EQ(validate_case(cases_path("i1958/schF1_a.xsd"),
|
|
61
|
+
cases_path("i1958/schF1.xml")),
|
|
62
|
+
1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
TEST(I1958, RedefinedSimpleTypeRegistered) {
|
|
66
|
+
EXPECT_EQ(validate_case(cases_path("i1958/schP2_a.xsd"),
|
|
67
|
+
cases_path("i1958/schP2.xml")),
|
|
68
|
+
1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
TEST(I1958, RedefinedSimpleTypeFacetEnforced) {
|
|
72
|
+
/* "abc" is 3 chars — the redefined minLength 4 rejects it (the
|
|
73
|
+
* facet proves the REDEFINED type, not the original, resolved). */
|
|
74
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
75
|
+
LeptrisXsdSchema s = leptris_xsd_compile_file(
|
|
76
|
+
cases_path("i1958/schP2_a.xsd").c_str(), &st);
|
|
77
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
78
|
+
const char too_short[] =
|
|
79
|
+
"<e1 xmlns=\"ns-a\">abc</e1>";
|
|
80
|
+
LeptrisDocument d = leptris_parse_string(too_short,
|
|
81
|
+
strlen(too_short), &st);
|
|
82
|
+
ASSERT_NE(d, nullptr);
|
|
83
|
+
EXPECT_EQ(leptris_xsd_validate(s, d), 0)
|
|
84
|
+
<< "minLength 4 rejected nothing";
|
|
85
|
+
size_t errs = leptris_xsd_error_count(s);
|
|
86
|
+
for (size_t i = 0; i < errs; i++)
|
|
87
|
+
printf(" err: %s\n", leptris_xsd_error_at(s, i));
|
|
88
|
+
leptris_document_free(d);
|
|
89
|
+
leptris_xsd_free(s);
|
|
90
|
+
}
|
|
@@ -93,6 +93,15 @@ int validate_pair(const Rs35Case& c) {
|
|
|
93
93
|
}
|
|
94
94
|
} // namespace
|
|
95
95
|
|
|
96
|
+
TEST(Rs35Regression, TheAttributeLegCasesValidate) {
|
|
97
|
+
/* leptris-rs#36: fixed + whitespace-variant lexicals — the
|
|
98
|
+
* fixed constraint holds on the TYPE value (§4.3.1.2), so
|
|
99
|
+
* integer attributes whose lexical differs only in
|
|
100
|
+
* whitespace validate. */
|
|
101
|
+
EXPECT_EQ(validate_pair({"attO006.xsd", "attO006.xml"}), 1);
|
|
102
|
+
EXPECT_EQ(validate_pair({"addB104.xsd", "addB104.xml"}), 1);
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
TEST(Rs35Regression, AllFifteenW3cCasesValidate) {
|
|
97
106
|
static const Rs35Case cases[] = {
|
|
98
107
|
{"isdefault002.xsd", "isdefault005.xml"},
|
|
@@ -110,6 +119,8 @@ TEST(Rs35Regression, AllFifteenW3cCasesValidate) {
|
|
|
110
119
|
{"idG027.xsd", "idG027.xml"},
|
|
111
120
|
{"idG028.xsd", "idG028.xml"},
|
|
112
121
|
{"stZ072.xsd", "stZ072.xml"},
|
|
122
|
+
{"attO006.xsd", "attO006.xml"},
|
|
123
|
+
{"addB104.xsd", "addB104.xml"},
|
|
113
124
|
};
|
|
114
125
|
for (const auto& c : cases)
|
|
115
126
|
EXPECT_EQ(validate_pair(c), 1) << c.schema << " / " << c.instance;
|
|
@@ -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.
|
|
4
|
+
"version": "1.9.405",
|
|
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.
|
|
4
|
+
version: 1.9.405.0
|
|
5
5
|
platform: arm-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -1389,6 +1389,14 @@ files:
|
|
|
1389
1389
|
- vendor-src/libleptris/test/xsd/libxml2-cases/hexbinary_0.xml
|
|
1390
1390
|
- vendor-src/libleptris/test/xsd/libxml2-cases/hexbinary_0.xsd
|
|
1391
1391
|
- vendor-src/libleptris/test/xsd/libxml2-cases/hexbinary_1.xml
|
|
1392
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/i1957/instance.xml
|
|
1393
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/i1957/schema.xsd
|
|
1394
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schF1.xml
|
|
1395
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schF1_a.xsd
|
|
1396
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schF1_b.xsd
|
|
1397
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schP2.xml
|
|
1398
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schP2_a.xsd
|
|
1399
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/i1958/schP2_b.xsd
|
|
1392
1400
|
- vendor-src/libleptris/test/xsd/libxml2-cases/idc-keyref-err1_0.xml
|
|
1393
1401
|
- vendor-src/libleptris/test/xsd/libxml2-cases/idc-keyref-err1_1.xsd
|
|
1394
1402
|
- vendor-src/libleptris/test/xsd/libxml2-cases/import-455953.xsd
|
|
@@ -1490,6 +1498,10 @@ files:
|
|
|
1490
1498
|
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_redefine_ext/idF025.xml
|
|
1491
1499
|
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_redefine_ext/idF025.xsd
|
|
1492
1500
|
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_redefine_ext/idF025_base.xsd
|
|
1501
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/addB104.xml
|
|
1502
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/addB104.xsd
|
|
1503
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/attO006.xml
|
|
1504
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/attO006.xsd
|
|
1493
1505
|
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/ctA033.xml
|
|
1494
1506
|
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/ctA033.xsd
|
|
1495
1507
|
- vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/ctA035.xml
|
|
@@ -1588,6 +1600,7 @@ files:
|
|
|
1588
1600
|
- vendor-src/libleptris/test/xsd/libxml2-cases/xsd-list-itemType_0.xsd
|
|
1589
1601
|
- vendor-src/libleptris/test/xsd/libxml2-cases/xsd-simpleType-varieties_0.xml
|
|
1590
1602
|
- vendor-src/libleptris/test/xsd/libxml2-cases/xsd-simpleType-varieties_0.xsd
|
|
1603
|
+
- vendor-src/libleptris/test/xsd/test_i1957_1958.cpp
|
|
1591
1604
|
- vendor-src/libleptris/test/xsd/test_rs35_regression.cpp
|
|
1592
1605
|
- vendor-src/libleptris/test/xsd/test_xsd_compile.cpp
|
|
1593
1606
|
- vendor-src/libleptris/test/xsd/xsd-dispositions/README.md
|