leptris 1.9.403.1-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 +147 -8
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/leptris/descriptor/plan.c +98 -7
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +200 -13
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +133 -24
- data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +15 -0
- data/vendor-src/libleptris/test/CMakeLists.txt +6 -0
- data/vendor-src/libleptris/test/abi/test_descriptor.cpp +232 -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_fixed_empty/isdefault005.xml +1 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_fixed_empty/isdefault005.xsd +9 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_list_default/stZ072.xml +1 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_list_default/stZ072.xsd +12 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_mixed_particleless/ctA033.xml +1 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_mixed_particleless/ctA033.xsd +4 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_redefine_ext/idF025.red +8 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_redefine_ext/idF025.xml +15 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_redefine_ext/idF025.xsd +30 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_redefine_ext/idF025_base.xsd +7 -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/libxml2-cases/rs35_w3c/ctA033.xml +2 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/ctA033.xsd +5 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/ctA035.xml +2 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/ctA035.xsd +5 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idF025.red +8 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idF025.xml +15 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idF025.xsd +30 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idF033.xml +12 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idF033.xsd +23 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idF033a.xsd +8 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idF034.red +8 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idF034.xml +15 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idF034.xsd +30 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG018.xml +12 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG018.xsd +23 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG018a.xsd +8 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG019.red +8 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG019.xml +15 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG019.xsd +30 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG027.xml +12 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG027.xsd +23 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG027a.xsd +8 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG028.red +8 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG028.xml +15 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/idG028.xsd +30 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/isdefault002.xsd +12 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/isdefault004.xsd +12 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/isdefault005.xml +5 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/isdefault006.xml +5 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/isdefault025.xml +5 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/isdefault026.xml +5 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/stZ072.xml +1 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/stZ072.xsd +20 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/test95960_1.xml +4 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs35_w3c/test95960_1.xsd +12 -0
- data/vendor-src/libleptris/test/xsd/test_i1957_1958.cpp +90 -0
- data/vendor-src/libleptris/test/xsd/test_rs35_regression.cpp +127 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +60 -1
|
@@ -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
|
|
@@ -191,6 +197,8 @@ static void xsd_cm_free(XsdCm* cm) {
|
|
|
191
197
|
free(cm->not_qname);
|
|
192
198
|
free(cm->any_unit_tns);
|
|
193
199
|
free(cm->text_type);
|
|
200
|
+
free(cm->fixed_value);
|
|
201
|
+
free(cm->default_value);
|
|
194
202
|
free(cm);
|
|
195
203
|
cm = next;
|
|
196
204
|
}
|
|
@@ -279,6 +287,13 @@ static XsdCm* xsd_cm_parse(struct leptris_xsd_schema* s,
|
|
|
279
287
|
if (xsd_capture_inline(s, e, synth))
|
|
280
288
|
cm->type = xsd_strdup(synth);
|
|
281
289
|
}
|
|
290
|
+
/* leptris-rs#35 (isDefault005): particle value
|
|
291
|
+
* constraints — an empty child is satisfied BY its
|
|
292
|
+
* fixed/default value (§3.12.2). */
|
|
293
|
+
cm->fixed_value = xsd_strdup(
|
|
294
|
+
leptris_element_attribute(e, "fixed"));
|
|
295
|
+
cm->default_value = xsd_strdup(
|
|
296
|
+
leptris_element_attribute(e, "default"));
|
|
282
297
|
}
|
|
283
298
|
} else if (strcmp(local, "group") == 0) {
|
|
284
299
|
/* <xs:group ref="g"/> — expanded at NFA build so
|
|
@@ -541,6 +556,11 @@ static ret_type fn_name(struct leptris_xsd_schema* s, const char* name, \
|
|
|
541
556
|
return t; \
|
|
542
557
|
return NULL; \
|
|
543
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. */ \
|
|
544
564
|
for (ret_type t = s->list_field; t; t = t->next) \
|
|
545
565
|
if (strcmp(t->name_field, name) == 0) \
|
|
546
566
|
return t; \
|
|
@@ -549,6 +569,25 @@ static ret_type fn_name(struct leptris_xsd_schema* s, const char* name, \
|
|
|
549
569
|
|
|
550
570
|
XSD_DEFINE_NS_LADDER(const XsdElementDecl*, xsd_ladder_element, elements,
|
|
551
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
|
+
}
|
|
552
591
|
XSD_DEFINE_NS_LADDER(XsdCm*, xsd_ladder_complex, complex_types, name, ns)
|
|
553
592
|
XSD_DEFINE_NS_LADDER(const XsdSimple*, xsd_ladder_simple, simple_types,
|
|
554
593
|
name, ns)
|
|
@@ -2284,6 +2323,23 @@ static int xsd_visited_has(struct leptris_xsd_schema* s,
|
|
|
2284
2323
|
return 0;
|
|
2285
2324
|
}
|
|
2286
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
|
+
|
|
2287
2343
|
static void xsd_visited_add(struct leptris_xsd_schema* s,
|
|
2288
2344
|
const char* path) {
|
|
2289
2345
|
if (s->visited_len == s->visited_cap) {
|
|
@@ -2304,20 +2360,29 @@ static XsdAttrDecl* xsd_capture_attr_rows(
|
|
|
2304
2360
|
* PRE-PASS — the symbol space is order-free, but the ref expansion
|
|
2305
2361
|
* in xsd_capture_attr_rows looks up s->attr_groups at capture time,
|
|
2306
2362
|
* so a group declared AFTER the referencing type used to vanish. */
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
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) {
|
|
2310
2370
|
XsdAttrGroupDef* g = (XsdAttrGroupDef*)calloc(1, sizeof(*g));
|
|
2311
2371
|
if (!g) return;
|
|
2312
2372
|
g->name = xsd_strdup(nm);
|
|
2313
|
-
g->
|
|
2373
|
+
g->elem = n;
|
|
2314
2374
|
g->next = s->attr_groups;
|
|
2315
2375
|
s->attr_groups = g;
|
|
2316
2376
|
}
|
|
2317
2377
|
|
|
2318
2378
|
static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
2319
2379
|
LeptrisElement root) {
|
|
2320
|
-
/* 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). */
|
|
2321
2386
|
for (LeptrisNodeRef n =
|
|
2322
2387
|
leptris_node_first_child(leptris_element_as_node(root));
|
|
2323
2388
|
n; n = leptris_node_next_sibling(n)) {
|
|
@@ -2333,8 +2398,11 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2333
2398
|
const char* nm = leptris_element_attribute((LeptrisElement)n,
|
|
2334
2399
|
"name");
|
|
2335
2400
|
if (!nm) continue;
|
|
2336
|
-
|
|
2401
|
+
xsd_register_attr_group_def(s, (LeptrisElement)n, nm);
|
|
2337
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);
|
|
2338
2406
|
for (LeptrisNodeRef n =
|
|
2339
2407
|
leptris_node_first_child(leptris_element_as_node(root));
|
|
2340
2408
|
n; n = leptris_node_next_sibling(n)) {
|
|
@@ -2407,11 +2475,23 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2407
2475
|
(strcmp(local, "import") == 0 || same_ns)) {
|
|
2408
2476
|
/* leptris-ruby#440/#439: each captured
|
|
2409
2477
|
* unit stamps ITS OWN targetNamespace on
|
|
2410
|
-
* its declarations — chameleon
|
|
2411
|
-
* (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). */
|
|
2412
2490
|
char* saved_ns = s->target_ns;
|
|
2413
2491
|
char* sub_ns = tns ? xsd_strdup(tns) : NULL;
|
|
2414
2492
|
if (sub_ns) s->target_ns = sub_ns;
|
|
2493
|
+
else if (strcmp(local, "import") == 0)
|
|
2494
|
+
s->target_ns = NULL;
|
|
2415
2495
|
s->include_depth++;
|
|
2416
2496
|
xsd_capture_root(s, subroot);
|
|
2417
2497
|
s->include_depth--;
|
|
@@ -2437,8 +2517,47 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2437
2517
|
xsd_capture_root(s, (LeptrisElement)n);
|
|
2438
2518
|
s->capture_force = 0;
|
|
2439
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
|
+
}
|
|
2440
2556
|
}
|
|
2441
|
-
|
|
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);
|
|
2442
2561
|
}
|
|
2443
2562
|
free(text);
|
|
2444
2563
|
}
|
|
@@ -2471,6 +2590,9 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2471
2590
|
d->fixed = xsd_strdup(
|
|
2472
2591
|
leptris_element_attribute((LeptrisElement)n,
|
|
2473
2592
|
"fixed"));
|
|
2593
|
+
d->default_value = xsd_strdup(
|
|
2594
|
+
leptris_element_attribute((LeptrisElement)n,
|
|
2595
|
+
"default"));
|
|
2474
2596
|
const char* sg = leptris_element_attribute(
|
|
2475
2597
|
(LeptrisElement)n, "substitutionGroup");
|
|
2476
2598
|
if (sg) {
|
|
@@ -2509,6 +2631,9 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2509
2631
|
d->fixed = xsd_strdup(
|
|
2510
2632
|
leptris_element_attribute((LeptrisElement)n,
|
|
2511
2633
|
"fixed"));
|
|
2634
|
+
d->default_value = xsd_strdup(
|
|
2635
|
+
leptris_element_attribute((LeptrisElement)n,
|
|
2636
|
+
"default"));
|
|
2512
2637
|
const char* sg = leptris_element_attribute(
|
|
2513
2638
|
(LeptrisElement)n, "substitutionGroup");
|
|
2514
2639
|
if (sg) {
|
|
@@ -2578,8 +2703,16 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
|
|
|
2578
2703
|
XsdAttrGroupDef* seen = s->attr_groups;
|
|
2579
2704
|
for (; seen; seen = seen->next)
|
|
2580
2705
|
if (strcmp(seen->name, nm) == 0) break;
|
|
2581
|
-
if (!seen || s->capture_force)
|
|
2582
|
-
|
|
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
|
+
}
|
|
2583
2716
|
}
|
|
2584
2717
|
} else if (strcmp(local, "group") == 0 && uri && !strcmp(uri, XSD_NS)) {
|
|
2585
2718
|
const char* nm =
|
|
@@ -2648,6 +2781,15 @@ static void xsd_free_simple_one(XsdSimple* t) {
|
|
|
2648
2781
|
LEPTRIS_API void leptris_xsd_free(LeptrisXsdSchema schema) {
|
|
2649
2782
|
struct leptris_xsd_schema* s = (struct leptris_xsd_schema*)schema;
|
|
2650
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
|
+
}
|
|
2651
2793
|
free(s->report);
|
|
2652
2794
|
xsd_cm_free(s->complex_types);
|
|
2653
2795
|
XsdElementIcs* slot = s->element_ics;
|
|
@@ -2706,6 +2848,7 @@ LEPTRIS_API void leptris_xsd_free(LeptrisXsdSchema schema) {
|
|
|
2706
2848
|
free(d->name);
|
|
2707
2849
|
free(d->type);
|
|
2708
2850
|
free(d->fixed);
|
|
2851
|
+
free(d->default_value);
|
|
2709
2852
|
free(d->sub_head);
|
|
2710
2853
|
free(d);
|
|
2711
2854
|
d = dn;
|
|
@@ -2922,6 +3065,10 @@ static XsdCm* xsd_capture_complex_model(struct leptris_xsd_schema* s,
|
|
|
2922
3065
|
const char* name) {
|
|
2923
3066
|
XsdCm* root = xsd_cm_new(XSD_CM_SEQ); /* wrapper keeps the name */
|
|
2924
3067
|
if (!root) return NULL;
|
|
3068
|
+
/* leptris-rs#35 (ctA033, idF025's inline c): mixed="true" admits
|
|
3069
|
+
* character data even with no particle model — the flag must
|
|
3070
|
+
* survive capture or the validator treats the type as empty. */
|
|
3071
|
+
root->mixed = xsd_mixed_flag(ct);
|
|
2925
3072
|
XsdAttrDecl* attrs = NULL;
|
|
2926
3073
|
char* any_attr_ns = NULL;
|
|
2927
3074
|
char* any_attr_not_qname = NULL;
|
|
@@ -3431,8 +3578,15 @@ static XsdAttrDecl* xsd_capture_attr_rows(struct leptris_xsd_schema* s,
|
|
|
3431
3578
|
XsdAttrGroupDef* g = s->attr_groups;
|
|
3432
3579
|
for (; g; g = g->next)
|
|
3433
3580
|
if (strcmp(g->name, ref) == 0) break;
|
|
3434
|
-
if (!g
|
|
3435
|
-
|
|
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);
|
|
3436
3590
|
if (!copied) continue;
|
|
3437
3591
|
if (!head)
|
|
3438
3592
|
head = copied;
|
|
@@ -3683,6 +3837,23 @@ const XsdElementDecl* xsd_find_element_ns(
|
|
|
3683
3837
|
return xsd_ladder_element(s, name, uri, 0);
|
|
3684
3838
|
}
|
|
3685
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
|
+
|
|
3686
3857
|
XsdCm* xsd_find_complex(struct leptris_xsd_schema* s,
|
|
3687
3858
|
const char* type_name) {
|
|
3688
3859
|
if (!s || !type_name) return NULL;
|
|
@@ -3701,6 +3872,22 @@ XsdCm* xsd_find_complex_ns(struct leptris_xsd_schema* s,
|
|
|
3701
3872
|
return xsd_ladder_complex(s, type_name, uri, 0);
|
|
3702
3873
|
}
|
|
3703
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
|
+
|
|
3704
3891
|
/* leptris-ruby#440 (follow-up): a TYPE REFERENCE on an instance
|
|
3705
3892
|
* element resolves against the namespace the REFERENCE declares —
|
|
3706
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
|
|
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
|
|
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,
|
|
@@ -351,8 +361,10 @@ static void validate_children(struct xsd_validator* v,
|
|
|
351
361
|
* oracle rejects whitespace-only content too, #1691 law) */
|
|
352
362
|
if (!model) {
|
|
353
363
|
/* simpleContent types ride text_type with no particle —
|
|
354
|
-
* their text is validated at the call site
|
|
355
|
-
|
|
364
|
+
* their text is validated at the call site. leptris-rs#35
|
|
365
|
+
* (ctA033, idF025's inline c): mixed="true" admits character
|
|
366
|
+
* content even with no particle model. */
|
|
367
|
+
if (!ct->text_type && !ct->mixed) {
|
|
356
368
|
const char* et = leptris_element_text(elem);
|
|
357
369
|
if (et && *et) {
|
|
358
370
|
const char* pn = NULL;
|
|
@@ -504,6 +516,7 @@ static void validate_children(struct xsd_validator* v,
|
|
|
504
516
|
int wpc = model_wildcard_pc(model, cu, xsd_target_ns(s));
|
|
505
517
|
if (wpc == 2) continue;
|
|
506
518
|
const char* ptype = NULL;
|
|
519
|
+
const char* pfill = NULL;
|
|
507
520
|
if (model) {
|
|
508
521
|
XsdCm* stack[64];
|
|
509
522
|
int sp = 0;
|
|
@@ -514,6 +527,11 @@ static void validate_children(struct xsd_validator* v,
|
|
|
514
527
|
if (p->kind == XSD_CM_ELEMENT && p->name &&
|
|
515
528
|
strcmp(p->name, cl) == 0 && p->type) {
|
|
516
529
|
ptype = p->type;
|
|
530
|
+
/* leptris-rs#35 (isDefault005): the
|
|
531
|
+
* particle's fixed/default value satisfies
|
|
532
|
+
* EMPTY content (§3.12.2). */
|
|
533
|
+
pfill = p->fixed_value ? p->fixed_value
|
|
534
|
+
: p->default_value;
|
|
517
535
|
break;
|
|
518
536
|
}
|
|
519
537
|
if (p->kind == XSD_CM_GROUP_REF) {
|
|
@@ -540,13 +558,17 @@ static void validate_children(struct xsd_validator* v,
|
|
|
540
558
|
verrf_atk(v, ce, "type-resolution", cl, "element", cl,
|
|
541
559
|
"xsi:type prefix is not bound in the instance");
|
|
542
560
|
} else {
|
|
543
|
-
validate_local_uri(v, s, ce, cl, xlocal, xuri, cxsi
|
|
561
|
+
validate_local_uri(v, s, ce, cl, xlocal, xuri, cxsi,
|
|
562
|
+
pfill, NULL);
|
|
544
563
|
}
|
|
545
564
|
} else {
|
|
546
|
-
validate_local(v, s, ce, cl, ptype
|
|
565
|
+
validate_local(v, s, ce, cl, ptype, pfill,
|
|
566
|
+
ct ? ct->ns : NULL);
|
|
547
567
|
}
|
|
548
|
-
} else
|
|
549
|
-
|
|
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);
|
|
550
572
|
}
|
|
551
573
|
/* wildcard-admitted children without a declaration pass:
|
|
552
574
|
* strict and lax alike admit undeclared names (the pinned
|
|
@@ -656,6 +678,43 @@ static int any_attr_matches(const char* grammar, const char* uri,
|
|
|
656
678
|
return 0;
|
|
657
679
|
}
|
|
658
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
|
+
|
|
659
718
|
static void validate_attributes(struct xsd_validator* v,
|
|
660
719
|
struct leptris_xsd_schema* s,
|
|
661
720
|
LeptrisElement elem,
|
|
@@ -694,7 +753,9 @@ static void validate_attributes(struct xsd_validator* v,
|
|
|
694
753
|
}
|
|
695
754
|
text_valid(v, s, a->type, val, ta ? ta->ns : NULL, "attribute",
|
|
696
755
|
a->name, elem);
|
|
697
|
-
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))
|
|
698
759
|
verrf_atk(v, elem, "attribute-use", a->name, "attribute",
|
|
699
760
|
a->name, "value does not match the fixed value");
|
|
700
761
|
}
|
|
@@ -789,13 +850,24 @@ static void validate_attributes(struct xsd_validator* v,
|
|
|
789
850
|
static void validate_element(struct xsd_validator* v,
|
|
790
851
|
struct leptris_xsd_schema* s,
|
|
791
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) {
|
|
792
862
|
if (depth > 64) return;
|
|
793
863
|
const char* local = NULL, *prefix = NULL, *uri = NULL;
|
|
794
864
|
leptris_element_expanded_name(elem, &local, &prefix, &uri);
|
|
795
865
|
if (!local) return;
|
|
796
866
|
const char* guri = NULL;
|
|
797
867
|
leptris_element_expanded_name(elem, NULL, NULL, &guri);
|
|
798
|
-
const XsdElementDecl* d =
|
|
868
|
+
const XsdElementDecl* d =
|
|
869
|
+
decl_override ? decl_override
|
|
870
|
+
: xsd_find_element_ns(s, local, guri);
|
|
799
871
|
if (!d) {
|
|
800
872
|
/* strict: the instance uses an element the schema never
|
|
801
873
|
* declared (a local particle would have typed it) */
|
|
@@ -830,7 +902,8 @@ static void validate_element(struct xsd_validator* v,
|
|
|
830
902
|
* only non-empty content that differs violates (nine suite
|
|
831
903
|
* rows flipped on the 1.9.402 ride; whitespace-only counts as
|
|
832
904
|
* empty per the §3.3.4 initial reading). */
|
|
833
|
-
|
|
905
|
+
const char* fill = NULL;
|
|
906
|
+
{
|
|
834
907
|
const char* text = leptris_element_text(elem);
|
|
835
908
|
int has_content = 0;
|
|
836
909
|
if (text)
|
|
@@ -839,9 +912,17 @@ static void validate_element(struct xsd_validator* v,
|
|
|
839
912
|
has_content = 1;
|
|
840
913
|
break;
|
|
841
914
|
}
|
|
842
|
-
if (
|
|
843
|
-
|
|
844
|
-
|
|
915
|
+
if (d->fixed) {
|
|
916
|
+
if (has_content && strcmp(text, d->fixed) != 0)
|
|
917
|
+
verrfk(v, "content-model", "element", local,
|
|
918
|
+
"content does not match the fixed value");
|
|
919
|
+
if (!has_content)
|
|
920
|
+
fill = d->fixed;
|
|
921
|
+
} else if (!has_content && d->default_value) {
|
|
922
|
+
/* leptris-rs#35 (stZ072): the default value supplies the
|
|
923
|
+
* content of an empty element (§3.12.2). */
|
|
924
|
+
fill = d->default_value;
|
|
925
|
+
}
|
|
845
926
|
}
|
|
846
927
|
if (!eff_type) return; /* anyType */
|
|
847
928
|
/* XSD 1.0 §2.6.2/§3.3.4 (moxml#433): xsi:type on the instance
|
|
@@ -863,10 +944,12 @@ static void validate_element(struct xsd_validator* v,
|
|
|
863
944
|
"xsi:type prefix is not bound in the instance");
|
|
864
945
|
return;
|
|
865
946
|
}
|
|
866
|
-
validate_local_uri(v, s, elem, local, xlocal, xuri, xsi_q
|
|
947
|
+
validate_local_uri(v, s, elem, local, xlocal, xuri, xsi_q,
|
|
948
|
+
fill, NULL);
|
|
867
949
|
return;
|
|
868
950
|
}
|
|
869
|
-
validate_local(v, s, elem, local, eff_type
|
|
951
|
+
validate_local(v, s, elem, local, eff_type, fill,
|
|
952
|
+
d->ns);
|
|
870
953
|
}
|
|
871
954
|
|
|
872
955
|
/* Validate one element against a type name that comes from a
|
|
@@ -875,22 +958,43 @@ static void validate_element(struct xsd_validator* v,
|
|
|
875
958
|
static void validate_local(struct xsd_validator* v,
|
|
876
959
|
struct leptris_xsd_schema* s,
|
|
877
960
|
LeptrisElement elem, const char* local,
|
|
878
|
-
const char* type
|
|
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) {
|
|
879
975
|
const char* euri = NULL;
|
|
880
976
|
leptris_element_expanded_name(elem, NULL, NULL, &euri);
|
|
881
|
-
validate_local_uri(v, s, elem, local, type, euri, NULL
|
|
977
|
+
validate_local_uri(v, s, elem, local, type, euri, NULL, fill,
|
|
978
|
+
tns_hint);
|
|
882
979
|
}
|
|
883
980
|
|
|
884
981
|
static void validate_local_uri(struct xsd_validator* v,
|
|
885
982
|
struct leptris_xsd_schema* s,
|
|
886
983
|
LeptrisElement elem, const char* local,
|
|
887
984
|
const char* type, const char* euri,
|
|
888
|
-
const char* xsi_q
|
|
985
|
+
const char* xsi_q, const char* fill,
|
|
986
|
+
const char* tns_hint) {
|
|
889
987
|
if (!type) return;
|
|
890
|
-
/* the
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
|
|
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);
|
|
894
998
|
/* XSD 1.0 §2.7/§3.3.3 (leptris-rs#26, particlesIa002/
|
|
895
999
|
* QFE1700g2): a NILLED element must have neither character nor
|
|
896
1000
|
* element content — the content model is not applied (the nil
|
|
@@ -950,9 +1054,12 @@ static void validate_local_uri(struct xsd_validator* v,
|
|
|
950
1054
|
}
|
|
951
1055
|
if (ct->text_type) {
|
|
952
1056
|
/* empty content is still a lexical value — it faces the
|
|
953
|
-
* facets (reG17: '' must fail the pattern)
|
|
1057
|
+
* facets (reG17: '' must fail the pattern). leptris-rs#35:
|
|
1058
|
+
* an EMPTY element is satisfied BY its fixed/default
|
|
1059
|
+
* value (§3.12.2) — the fill substitutes for the read. */
|
|
954
1060
|
const char* text = leptris_element_text(elem);
|
|
955
1061
|
if (!text) text = "";
|
|
1062
|
+
if (fill && !*text) text = fill;
|
|
956
1063
|
text_valid(v, s, ct->text_type, text, ct->ns,
|
|
957
1064
|
"element", local, elem);
|
|
958
1065
|
}
|
|
@@ -976,6 +1083,7 @@ static void validate_local_uri(struct xsd_validator* v,
|
|
|
976
1083
|
validate_attributes(v, s, elem, &k_no_attrs, NULL);
|
|
977
1084
|
const char* text = leptris_element_text(elem);
|
|
978
1085
|
if (!text) text = "";
|
|
1086
|
+
if (fill && !*text) text = fill;
|
|
979
1087
|
text_valid(v, s, type, text, euri, "element", local,
|
|
980
1088
|
elem);
|
|
981
1089
|
return;
|
|
@@ -996,6 +1104,7 @@ static void validate_local_uri(struct xsd_validator* v,
|
|
|
996
1104
|
validate_attributes(v, s, elem, &k_no_attrs, NULL);
|
|
997
1105
|
const char* text = leptris_element_text(elem);
|
|
998
1106
|
if (!text) text = "";
|
|
1107
|
+
if (fill && !*text) text = fill;
|
|
999
1108
|
text_valid(v, s, builtin, text, euri, "element",
|
|
1000
1109
|
local, elem);
|
|
1001
1110
|
return;
|