leptris 1.9.320.0-arm-linux → 1.9.321.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/CHANGELOG.md +17 -0
- data/Rakefile +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/ffi.rb +15 -0
- data/lib/leptris/xml/xsd.rb +58 -6
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +22 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/CMakeLists.txt +2 -0
- data/vendor-src/libleptris/src/include/leptris.h +22 -0
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +309 -1
- data/vendor-src/libleptris/src/leptris/xsd/content_model.c +232 -0
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +287 -0
- data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +48 -0
- data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +253 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +3 -1
|
@@ -264,3 +264,256 @@ TEST(XsdDatatypes, LocalBaseChainValidatesEveryHop) {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
} // namespace
|
|
267
|
+
|
|
268
|
+
// ---- slice 3: content models ---------------------------------------
|
|
269
|
+
namespace {
|
|
270
|
+
|
|
271
|
+
const char* k_cm_schema =
|
|
272
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
|
|
273
|
+
" targetNamespace=\"urn:t\">"
|
|
274
|
+
"<xs:complexType name=\"pairT\">"
|
|
275
|
+
"<xs:sequence>"
|
|
276
|
+
"<xs:element name=\"a\"/>"
|
|
277
|
+
"<xs:element name=\"b\"/>"
|
|
278
|
+
"</xs:sequence></xs:complexType>"
|
|
279
|
+
"<xs:element name=\"pair\" type=\"pairT\"/>"
|
|
280
|
+
|
|
281
|
+
"<xs:complexType name=\"pickT\">"
|
|
282
|
+
"<xs:choice>"
|
|
283
|
+
"<xs:element name=\"x\"/>"
|
|
284
|
+
"<xs:element name=\"y\"/>"
|
|
285
|
+
"</xs:choice></xs:complexType>"
|
|
286
|
+
"<xs:element name=\"pick\" type=\"pickT\"/>"
|
|
287
|
+
|
|
288
|
+
"<xs:complexType name=\"twoToThreeT\">"
|
|
289
|
+
"<xs:sequence>"
|
|
290
|
+
"<xs:element name=\"a\" minOccurs=\"2\" maxOccurs=\"3\"/>"
|
|
291
|
+
"</xs:sequence></xs:complexType>"
|
|
292
|
+
"<xs:element name=\"twoToThree\" type=\"twoToThreeT\"/>"
|
|
293
|
+
|
|
294
|
+
"<xs:complexType name=\"listT\">"
|
|
295
|
+
"<xs:sequence>"
|
|
296
|
+
"<xs:element name=\"item\" maxOccurs=\"unbounded\"/>"
|
|
297
|
+
"</xs:sequence></xs:complexType>"
|
|
298
|
+
"<xs:element name=\"list\" type=\"listT\"/>"
|
|
299
|
+
|
|
300
|
+
"<xs:complexType name=\"looseT\">"
|
|
301
|
+
"<xs:sequence>"
|
|
302
|
+
"<xs:any namespace=\"##other\" processContents=\"skip\"/>"
|
|
303
|
+
"</xs:sequence></xs:complexType>"
|
|
304
|
+
"<xs:element name=\"loose\" type=\"looseT\"/>"
|
|
305
|
+
|
|
306
|
+
"<xs:complexType name=\"nestedT\">"
|
|
307
|
+
"<xs:sequence>"
|
|
308
|
+
"<xs:choice>"
|
|
309
|
+
"<xs:element name=\"x\"/>"
|
|
310
|
+
"<xs:element name=\"y\"/>"
|
|
311
|
+
"</xs:choice>"
|
|
312
|
+
"<xs:element name=\"c\"/>"
|
|
313
|
+
"</xs:sequence></xs:complexType>"
|
|
314
|
+
"<xs:element name=\"nested\" type=\"nestedT\"/>"
|
|
315
|
+
|
|
316
|
+
"<xs:element name=\"text\" type=\"xs:string\"/>"
|
|
317
|
+
"</xs:schema>";
|
|
318
|
+
|
|
319
|
+
LeptrisXsdSchema compile_cm() {
|
|
320
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
321
|
+
LeptrisXsdSchema s =
|
|
322
|
+
leptris_xsd_compile(k_cm_schema, strlen(k_cm_schema), &st);
|
|
323
|
+
EXPECT_EQ(st, LEPTRIS_OK);
|
|
324
|
+
return s;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
TEST(XsdContent, SequenceInOrder) {
|
|
328
|
+
LeptrisXsdSchema s = compile_cm();
|
|
329
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
330
|
+
const char* ab[] = {"a", "b"};
|
|
331
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "pair", ab, NULL, 2), 1);
|
|
332
|
+
const char* ba[] = {"b", "a"};
|
|
333
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "pair", ba, NULL, 2), 0);
|
|
334
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "pair", ab, NULL, 1), 0);
|
|
335
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "pair", NULL, NULL, 0), 0);
|
|
336
|
+
leptris_xsd_free(s);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
TEST(XsdContent, ChoicePicksExactlyOne) {
|
|
340
|
+
LeptrisXsdSchema s = compile_cm();
|
|
341
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
342
|
+
const char* x[] = {"x"};
|
|
343
|
+
const char* y[] = {"y"};
|
|
344
|
+
const char* xy[] = {"x", "y"};
|
|
345
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "pick", x, NULL, 1), 1);
|
|
346
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "pick", y, NULL, 1), 1);
|
|
347
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "pick", xy, NULL, 2), 0);
|
|
348
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "pick", NULL, NULL, 0), 0);
|
|
349
|
+
leptris_xsd_free(s);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
TEST(XsdContent, OccurrenceBoundsHold) {
|
|
353
|
+
LeptrisXsdSchema s = compile_cm();
|
|
354
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
355
|
+
const char* a1[] = {"a"};
|
|
356
|
+
const char* a2[] = {"a", "a"};
|
|
357
|
+
const char* a3[] = {"a", "a", "a"};
|
|
358
|
+
const char* a4[] = {"a", "a", "a", "a"};
|
|
359
|
+
SCOPED_TRACE("a1");
|
|
360
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "twoToThree", a1, NULL, 1), 0);
|
|
361
|
+
SCOPED_TRACE("a2");
|
|
362
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "twoToThree", a2, NULL, 2), 1);
|
|
363
|
+
SCOPED_TRACE("a3");
|
|
364
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "twoToThree", a3, NULL, 3), 1);
|
|
365
|
+
SCOPED_TRACE("a4");
|
|
366
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "twoToThree", a4, NULL, 4), 0);
|
|
367
|
+
leptris_xsd_free(s);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
TEST(XsdContent, UnboundedRepeats) {
|
|
371
|
+
LeptrisXsdSchema s = compile_cm();
|
|
372
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
373
|
+
const char* i3[] = {"item", "item", "item"};
|
|
374
|
+
const char* i30[30];
|
|
375
|
+
for (int i = 0; i < 30; i++) i30[i] = "item";
|
|
376
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "list", NULL, NULL, 0), 0);
|
|
377
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "list", i3, NULL, 3), 1);
|
|
378
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "list", i30, NULL, 30), 1);
|
|
379
|
+
leptris_xsd_free(s);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
TEST(XsdContent, WildcardNamespaceFilter) {
|
|
383
|
+
LeptrisXsdSchema s = compile_cm();
|
|
384
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
385
|
+
/* ##other: anything qualified OUTSIDE urn:t */
|
|
386
|
+
const char* w[] = {"widget"};
|
|
387
|
+
const char* tns[] = {"urn:t"};
|
|
388
|
+
const char* other[] = {"urn:elsewhere"};
|
|
389
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "loose", w, other, 1), 1);
|
|
390
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "loose", w, tns, 1), 0);
|
|
391
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "loose", w, NULL, 1), 0);
|
|
392
|
+
leptris_xsd_free(s);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
TEST(XsdContent, NestedGroupsCompose) {
|
|
396
|
+
LeptrisXsdSchema s = compile_cm();
|
|
397
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
398
|
+
const char* xc[] = {"x", "c"};
|
|
399
|
+
const char* yc[] = {"y", "c"};
|
|
400
|
+
const char* cc[] = {"c", "c"};
|
|
401
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "nested", xc, NULL, 2), 1);
|
|
402
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "nested", yc, NULL, 2), 1);
|
|
403
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "nested", cc, NULL, 2), 0);
|
|
404
|
+
leptris_xsd_free(s);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
TEST(XsdContent, SimpleTypedElementTakesNoChildren) {
|
|
408
|
+
LeptrisXsdSchema s = compile_cm();
|
|
409
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
410
|
+
const char* x[] = {"x"};
|
|
411
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "text", NULL, NULL, 0), 1);
|
|
412
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "text", x, NULL, 1), 0);
|
|
413
|
+
EXPECT_EQ(leptris_xsd_content_valid(s, "noSuchElement", x, NULL, 1),
|
|
414
|
+
-1);
|
|
415
|
+
leptris_xsd_free(s);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
} // namespace
|
|
419
|
+
|
|
420
|
+
// ---- slice 4: instance validation ----------------------------------
|
|
421
|
+
namespace {
|
|
422
|
+
|
|
423
|
+
const char* k_v_schema =
|
|
424
|
+
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
|
|
425
|
+
"<xs:complexType name=\"rowT\">"
|
|
426
|
+
"<xs:sequence>"
|
|
427
|
+
"<xs:element name=\"id\" type=\"xs:integer\"/>"
|
|
428
|
+
"<xs:element name=\"name\" type=\"xs:string\"/>"
|
|
429
|
+
"</xs:sequence>"
|
|
430
|
+
"<xs:attribute name=\"status\" type=\"xs:string\"/>"
|
|
431
|
+
"<xs:attribute name=\"version\" type=\"xs:integer\""
|
|
432
|
+
" use=\"required\"/>"
|
|
433
|
+
"</xs:complexType>"
|
|
434
|
+
"<xs:element name=\"rows\" type=\"rowT\"/>"
|
|
435
|
+
"<xs:element name=\"count\" type=\"xs:positiveInteger\"/>"
|
|
436
|
+
"</xs:schema>";
|
|
437
|
+
|
|
438
|
+
int validate_doc(const char* schema, const char* xml) {
|
|
439
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
440
|
+
LeptrisXsdSchema s =
|
|
441
|
+
leptris_xsd_compile(schema, strlen(schema), &st);
|
|
442
|
+
if (!s) return -2;
|
|
443
|
+
LeptrisDocument d = leptris_parse_string(xml, strlen(xml), &st);
|
|
444
|
+
if (!d) {
|
|
445
|
+
leptris_xsd_free(s);
|
|
446
|
+
return -3;
|
|
447
|
+
}
|
|
448
|
+
int r = leptris_xsd_validate(s, d);
|
|
449
|
+
leptris_document_free(d);
|
|
450
|
+
leptris_xsd_free(s);
|
|
451
|
+
return r;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
TEST(XsdValidate, ValidDocumentPasses) {
|
|
455
|
+
EXPECT_EQ(validate_doc(k_v_schema,
|
|
456
|
+
"<rows version=\"2\" status=\"ok\">"
|
|
457
|
+
"<id>7</id><name>abc</name></rows>"), 1);
|
|
458
|
+
EXPECT_EQ(validate_doc(k_v_schema, "<count>3</count>"), 1);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
TEST(XsdValidate, ContentModelViolationReports) {
|
|
462
|
+
EXPECT_EQ(validate_doc(k_v_schema,
|
|
463
|
+
"<rows version=\"1\">"
|
|
464
|
+
"<name>abc</name><id>7</id></rows>"), 0);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
TEST(XsdValidate, RequiredAttributeAbsentReports) {
|
|
468
|
+
int r = validate_doc(k_v_schema, "<rows><id>7</id><name>a</name></rows>");
|
|
469
|
+
EXPECT_EQ(r, 0);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
TEST(XsdValidate, AttributeTypeViolationReports) {
|
|
473
|
+
EXPECT_EQ(validate_doc(k_v_schema,
|
|
474
|
+
"<rows version=\"x\"><id>7</id>"
|
|
475
|
+
"<name>a</name></rows>"), 0);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
TEST(XsdValidate, ElementTextTypeViolationReports) {
|
|
479
|
+
EXPECT_EQ(validate_doc(k_v_schema, "<count>-2</count>"), 0);
|
|
480
|
+
EXPECT_EQ(validate_doc(k_v_schema, "<count>0</count>"), 0);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
TEST(XsdValidate, ChildElementTypeViolationReports) {
|
|
484
|
+
EXPECT_EQ(validate_doc(k_v_schema,
|
|
485
|
+
"<rows version=\"1\">"
|
|
486
|
+
"<id>nan</id><name>a</name></rows>"), 0);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
TEST(XsdValidate, ErrorsEnumerate) {
|
|
490
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
491
|
+
LeptrisXsdSchema s =
|
|
492
|
+
leptris_xsd_compile(k_v_schema, strlen(k_v_schema), &st);
|
|
493
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
494
|
+
const char* bad = "<rows><id>nan</id><name>a</name></rows>";
|
|
495
|
+
LeptrisDocument d = leptris_parse_string(bad, strlen(bad), &st);
|
|
496
|
+
ASSERT_NE(d, nullptr);
|
|
497
|
+
int r = leptris_xsd_validate(s, d);
|
|
498
|
+
EXPECT_EQ(r, 0);
|
|
499
|
+
EXPECT_GE(leptris_xsd_error_count(s), 1u);
|
|
500
|
+
const char* first = leptris_xsd_error_at(s, 0);
|
|
501
|
+
EXPECT_NE(first, nullptr);
|
|
502
|
+
EXPECT_EQ(leptris_xsd_error_at(s, 99), nullptr);
|
|
503
|
+
leptris_document_free(d);
|
|
504
|
+
leptris_xsd_free(s);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
TEST(XsdValidate, NullTolerant) {
|
|
508
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
509
|
+
LeptrisXsdSchema s =
|
|
510
|
+
leptris_xsd_compile(k_v_schema, strlen(k_v_schema), &st);
|
|
511
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
512
|
+
EXPECT_EQ(leptris_xsd_validate(NULL, NULL), -1);
|
|
513
|
+
EXPECT_EQ(leptris_xsd_validate(s, NULL), -1);
|
|
514
|
+
EXPECT_EQ(leptris_xsd_error_count(NULL), 0u);
|
|
515
|
+
EXPECT_EQ(leptris_xsd_error_at(NULL, 0), nullptr);
|
|
516
|
+
leptris_xsd_free(s);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
} // namespace
|
|
@@ -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.321",
|
|
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.321.0
|
|
5
5
|
platform: arm-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -697,7 +697,9 @@ files:
|
|
|
697
697
|
- vendor-src/libleptris/src/leptris/xpath/xpath_variables.h
|
|
698
698
|
- vendor-src/libleptris/src/leptris/xquery/xquery.c
|
|
699
699
|
- vendor-src/libleptris/src/leptris/xsd/compile.c
|
|
700
|
+
- vendor-src/libleptris/src/leptris/xsd/content_model.c
|
|
700
701
|
- vendor-src/libleptris/src/leptris/xsd/datatypes.c
|
|
702
|
+
- vendor-src/libleptris/src/leptris/xsd/validate.c
|
|
701
703
|
- vendor-src/libleptris/src/leptris/xsd/xsd_internal.h
|
|
702
704
|
- vendor-src/libleptris/src/leptris/xslt/xslt_exec.c
|
|
703
705
|
- vendor-src/libleptris/src/leptris/xslt/xslt_functions.c
|