zxsd 0.20.0
Embedded XML Schema validation for C
Loading...
Searching...
No Matches
zxsd.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Sixtaupi
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZXSD_H
13#define ZXSD_H
14
15#include <stddef.h>
16#include <stdint.h>
17
18#include "zxsd_version.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
30#ifndef ZXSD_MAX_INPUT
32#define ZXSD_MAX_INPUT (1024u * 1024u)
33#endif
34#ifndef ZXSD_MAX_DEPTH
36#define ZXSD_MAX_DEPTH 32u
37#endif
38#ifndef ZXSD_MAX_PARTICLES
40#define ZXSD_MAX_PARTICLES 32u
41#endif
42#if ZXSD_MAX_PARTICLES > 65536u
43#error "ZXSD_MAX_PARTICLES exceeds the 16-bit streaming particle-token space"
44#endif
45#ifndef ZXSD_MAX_ATTRIBUTES
47#define ZXSD_MAX_ATTRIBUTES 32u
48#endif
49#ifndef ZXSD_MAX_NAMESPACES
51#define ZXSD_MAX_NAMESPACES 16u
52#endif
53#ifndef ZXSD_MAX_IDENTITY_ROWS
55#define ZXSD_MAX_IDENTITY_ROWS 64u
56#endif
57#ifndef ZXSD_MAX_IDENTITY_VALUES
59#define ZXSD_MAX_IDENTITY_VALUES ZXSD_MAX_IDENTITY_ROWS
60#endif
61#ifndef ZXSD_MAX_IDENTITY_TEXT
63#define ZXSD_MAX_IDENTITY_TEXT 4096u
64#endif
65#ifndef ZXSD_MAX_IDENTITY_CONSTRAINTS
67#define ZXSD_MAX_IDENTITY_CONSTRAINTS 16u
68#endif
69#ifndef ZXSD_MAX_IDENTITY_FIELDS
71#define ZXSD_MAX_IDENTITY_FIELDS 8u
72#endif
73#ifndef ZXSD_MAX_XPATH_DEPTH
75#define ZXSD_MAX_XPATH_DEPTH 8u
76#endif
77#ifndef ZXSD_MAX_XPATH_ALTERNATIVES
79#define ZXSD_MAX_XPATH_ALTERNATIVES 8u
80#endif
81#ifndef ZXSD_STREAM_TEXT_CAPACITY
83#define ZXSD_STREAM_TEXT_CAPACITY ZXSD_MAX_TEXT_LENGTH
84#endif
85#ifndef ZXSD_MAX_TEXT_LENGTH
87#define ZXSD_MAX_TEXT_LENGTH 1024u
88#endif
89#ifndef ZXSD_MAX_PATTERN_LENGTH
91#define ZXSD_MAX_PATTERN_LENGTH 4096u
92#endif
93#ifndef ZXSD_MAX_REGEX_NODES
95#define ZXSD_MAX_REGEX_NODES 512u
96#endif
97#ifndef ZXSD_MAX_REGEX_DEPTH
99#define ZXSD_MAX_REGEX_DEPTH 32u
100#endif
101#ifndef ZXSD_MAX_SCHEMA_COMPLEXITY
103#define ZXSD_MAX_SCHEMA_COMPLEXITY 4096u
104#endif
105#ifndef ZXSD_STREAM_NAME_CAPACITY
107#define ZXSD_STREAM_NAME_CAPACITY 128u
108#endif
109#ifndef ZXSD_STREAM_CHILD_CAPACITY
113#define ZXSD_STREAM_CHILD_CAPACITY 64u
114#endif
115#ifndef ZXSD_STREAM_MODEL_CAPACITY
121#define ZXSD_STREAM_MODEL_CAPACITY 128u
122#endif
123#ifndef ZXSD_XML_TOKEN_CAPACITY
125#define ZXSD_XML_TOKEN_CAPACITY 4096u
126#endif
127
151
153typedef struct {
155 size_t offset;
156 const char *path;
157 const char *message;
159
169typedef void *(*zxsd_allocate_fn)(void *context, size_t size);
170
177typedef void (*zxsd_deallocate_fn)(void *context, void *pointer);
178
185
231
238
245
252
259
268
270enum {
271 ZXSD_F_LENGTH = 1u << 0,
278 ZXSD_F_PATTERN = 1u << 7,
280 ZXSD_F_FRACTION_DIGITS = 1u << 9
282
284enum {
290 ZXSD_DERIVATION_ALL = 0x1fu
292
293struct zxsd_simple;
294
296typedef struct {
298 const struct zxsd_simple *simple;
300
332
333struct zxsd_complex;
334struct zxsd_particle;
335
337typedef struct {
338 const char *name;
341 unsigned long min_occurs;
342 unsigned long max_occurs;
344 const char *namespace_uri;
345 const char *default_value;
346 const char *fixed_value;
349 unsigned block_methods;
353
355typedef struct {
356 const char *name;
360 const char *namespace_uri;
361 const char *default_value;
362 const char *fixed_value;
364
371
382
408
410typedef struct {
411 const char *name;
412 const char *namespace_uri;
414
424
431
442
458
460typedef struct {
461 const char *name;
462 const char *namespace_uri;
465 const char *default_value;
466 const char *fixed_value;
468
470typedef struct {
471 const char *name;
472 const char *namespace_uri;
477
479typedef struct {
480 const char *name;
481 const char *namespace_uri;
482 const char *public_identifier;
483 const char *system_identifier;
485
509
511typedef struct {
512 const struct zxsd_particle *particle;
513 unsigned long count;
514 size_t index;
515 uint32_t references;
516 uint16_t parent;
517 uint16_t next;
518 unsigned char phase;
519 unsigned char started;
521
523typedef struct {
524 const char *expected_name;
525 const char *expected_namespace;
529 const char *default_value;
530 const char *fixed_value;
531 unsigned char seen_attributes[ZXSD_MAX_ATTRIBUTES];
532 unsigned long child_counts[ZXSD_MAX_PARTICLES];
535 uint16_t model_states;
536 unsigned long
539 const struct zxsd_particle *child_particle_table[ZXSD_MAX_PARTICLES];
542 uint16_t child_particle_ids[ZXSD_STREAM_CHILD_CAPACITY];
543 size_t text_length;
544 size_t child_count;
546 int nilled;
550 char local_name[ZXSD_STREAM_NAME_CAPACITY];
551 char namespace_uri[ZXSD_STREAM_NAME_CAPACITY];
554
560
592
600
615typedef void (*zxsd_xml_event_fn)(void *user_data, zxsd_xml_event_t event,
616 const char *namespace_uri, const char *local_name,
617 const char *value, size_t value_length);
618
639
641#ifdef ZXSD_NO_HEAP
642#define ZXSD_CONFIG_NO_HEAP 1u
643#else
644#define ZXSD_CONFIG_NO_HEAP 0u
645#endif
655typedef struct {
656 unsigned int runtime_abi;
657 unsigned int descriptor_abi;
658 unsigned int no_heap;
659 size_t limits[22];
660 size_t layouts[12];
662
664#define ZXSD_RUNTIME_CONFIG_INIT \
665 { \
666 ZXSD_RUNTIME_ABI_VERSION, ZXSD_DESCRIPTOR_ABI_VERSION, ZXSD_CONFIG_NO_HEAP, \
667 {ZXSD_MAX_INPUT, \
668 ZXSD_MAX_DEPTH, \
669 ZXSD_MAX_PARTICLES, \
670 ZXSD_MAX_ATTRIBUTES, \
671 ZXSD_MAX_NAMESPACES, \
672 ZXSD_MAX_IDENTITY_ROWS, \
673 ZXSD_MAX_IDENTITY_VALUES, \
674 ZXSD_MAX_IDENTITY_TEXT, \
675 ZXSD_MAX_IDENTITY_CONSTRAINTS, \
676 ZXSD_MAX_IDENTITY_FIELDS, \
677 ZXSD_MAX_XPATH_DEPTH, \
678 ZXSD_MAX_XPATH_ALTERNATIVES, \
679 ZXSD_STREAM_TEXT_CAPACITY, \
680 ZXSD_MAX_TEXT_LENGTH, \
681 ZXSD_MAX_PATTERN_LENGTH, \
682 ZXSD_MAX_REGEX_NODES, \
683 ZXSD_MAX_REGEX_DEPTH, \
684 ZXSD_MAX_SCHEMA_COMPLEXITY, \
685 ZXSD_STREAM_NAME_CAPACITY, \
686 ZXSD_STREAM_CHILD_CAPACITY, \
687 ZXSD_STREAM_MODEL_CAPACITY, \
688 ZXSD_XML_TOKEN_CAPACITY}, \
689 { \
690 sizeof(zxsd_stream_t), sizeof(zxsd_stream_frame_t), \
691 sizeof(zxsd_xml_reader_t), sizeof(zxsd_schema_t), \
692 sizeof(zxsd_particle_t), sizeof(zxsd_complex_t), \
693 sizeof(zxsd_simple_t), sizeof(zxsd_result_t), \
694 sizeof(zxsd_allocator_t), sizeof(void *), sizeof(size_t), \
695 sizeof(unsigned long) \
696 } \
697 }
698
714
725zxsd_result_t zxsd_validate(const zxsd_schema_t *schema, const char *xml);
726
743 const zxsd_allocator_t *allocator);
744
756
773 const zxsd_allocator_t *allocator);
774
784
794zxsd_result_t zxsd_start_element(zxsd_stream_t *stream, const char *namespace_uri,
795 const char *local_name);
796
808zxsd_result_t zxsd_namespace(zxsd_stream_t *stream, const char *prefix, const char *namespace_uri);
809
820zxsd_result_t zxsd_attribute(zxsd_stream_t *stream, const char *namespace_uri,
821 const char *local_name, const char *value);
822
832zxsd_result_t zxsd_xsi_type(zxsd_stream_t *stream, const char *type_namespace_uri,
833 const char *type_local_name);
834
843
853zxsd_result_t zxsd_text(zxsd_stream_t *stream, const char *text, size_t length);
854
864zxsd_result_t zxsd_end_element(zxsd_stream_t *stream, const char *namespace_uri,
865 const char *local_name);
866
875
885
896 const zxsd_schema_t *schema,
897 const zxsd_allocator_t *allocator);
898
910 void *user_data);
911
925zxsd_result_t zxsd_xml_reader_feed(zxsd_xml_reader_t *reader, const void *data, size_t length);
926
937
944
953
956#ifdef __cplusplus
957}
958#endif
959#endif
zxsd_result_t zxsd_stream_finish(zxsd_stream_t *stream)
Verify that exactly one complete root element was supplied.
zxsd_result_t zxsd_end_element(zxsd_stream_t *stream, const char *namespace_uri, const char *local_name)
End the current element and check its expanded name and content.
zxsd_result_t zxsd_attribute(zxsd_stream_t *stream, const char *namespace_uri, const char *local_name, const char *value)
Add an attribute to the current start tag using its expanded name.
zxsd_result_t zxsd_stream_init_with_allocator(zxsd_stream_t *stream, const zxsd_schema_t *schema, const zxsd_allocator_t *allocator)
Initialize streaming validation with identity-constraint scratch allocation.
zxsd_identity_kind_t
Identity-constraint category.
Definition zxsd.h:426
#define ZXSD_STREAM_TEXT_CAPACITY
Maximum decoded character data retained for one streamed element.
Definition zxsd.h:83
zxsd_result_t zxsd_xml_reader_init_with_allocator(zxsd_xml_reader_t *reader, const zxsd_schema_t *schema, const zxsd_allocator_t *allocator)
Initialize a raw XML reader with identity-constraint scratch allocation.
struct zxsd_complex zxsd_complex_t
Generated descriptor for a complex XML Schema type.
zxsd_result_t zxsd_xml_reader_feed(zxsd_xml_reader_t *reader, const void *data, size_t length)
Feed one arbitrary fragment of an XML document.
void(* zxsd_deallocate_fn)(void *context, void *pointer)
Release runtime scratch storage.
Definition zxsd.h:177
struct zxsd_simple zxsd_simple_t
Generated descriptor for a restricted, list or union simple type.
zxsd_result_t zxsd_start_element(zxsd_stream_t *stream, const char *namespace_uri, const char *local_name)
Begin an element identified by its expanded name.
zxsd_error_t
Validation status and error codes.
Definition zxsd.h:129
void *(* zxsd_allocate_fn)(void *context, size_t size)
Allocate runtime scratch storage.
Definition zxsd.h:169
zxsd_whitespace_t
Whitespace treatment prescribed by an XML Schema simple type.
Definition zxsd.h:233
zxsd_simple_variety_t
Variety of an XML Schema simple type.
Definition zxsd.h:240
zxsd_particle_kind_t
Compiled content-model particle kind.
Definition zxsd.h:261
struct zxsd_xpath zxsd_xpath_t
Compiled restricted XPath used by identity constraints.
zxsd_model_t
Complex content model kind.
Definition zxsd.h:247
const char * zxsd_error_string(zxsd_error_t error)
Get a stable human-readable description of an error code.
void(* zxsd_xml_event_fn)(void *user_data, zxsd_xml_event_t event, const char *namespace_uri, const char *local_name, const char *value, size_t value_length)
Observe one decoded event accepted by the incremental validator.
Definition zxsd.h:615
struct zxsd_particle zxsd_particle_t
Recursive descriptor for a compiled content-model particle.
zxsd_process_t
Wildcard validation behavior.
Definition zxsd.h:254
#define ZXSD_MAX_NAMESPACES
Maximum number of simultaneously active namespace bindings.
Definition zxsd.h:51
void zxsd_xml_reader_set_event_callback(zxsd_xml_reader_t *reader, zxsd_xml_event_fn callback, void *user_data)
Install an optional decoded-event observer.
#define ZXSD_MAX_DEPTH
Maximum nesting depth accepted by the embedded XML parser.
Definition zxsd.h:36
#define ZXSD_MAX_ATTRIBUTES
Maximum number of attributes in one element.
Definition zxsd.h:47
#define ZXSD_STREAM_CHILD_CAPACITY
Maximum child tokens retained for a streamed model requiring history.
Definition zxsd.h:113
#define ZXSD_STREAM_MODEL_CAPACITY
Shared continuation/state slots for nested streaming content models.
Definition zxsd.h:121
zxsd_xml_event_t
Decoded XML events exposed by the incremental raw-XML reader.
Definition zxsd.h:594
zxsd_result_t zxsd_stream_init(zxsd_stream_t *stream, const zxsd_schema_t *schema)
Initialize an event-driven validation context.
zxsd_result_t zxsd_xml_reader_init(zxsd_xml_reader_t *reader, const zxsd_schema_t *schema)
Initialize a raw, incrementally fed XML validator.
void zxsd_stream_dispose(zxsd_stream_t *stream)
Release optional streaming scratch storage.
zxsd_result_t zxsd_xml_reader_finish(zxsd_xml_reader_t *reader)
Finish an incrementally supplied XML document.
zxsd_result_t zxsd_namespace(zxsd_stream_t *stream, const char *prefix, const char *namespace_uri)
Add an in-scope namespace declaration to the current start tag.
zxsd_result_t zxsd_xsi_type(zxsd_stream_t *stream, const char *type_namespace_uri, const char *type_local_name)
Apply a namespace-resolved xsi:type to the current element.
#define ZXSD_STREAM_NAME_CAPACITY
Maximum local-name or namespace-URI length accepted by streaming calls.
Definition zxsd.h:107
zxsd_result_t zxsd_start_content(zxsd_stream_t *stream)
Close the attribute phase of the current start tag.
zxsd_result_t zxsd_validate_with_allocator(const zxsd_schema_t *schema, const char *xml, const zxsd_allocator_t *allocator)
Validate using an application-provided scratch allocator.
#define ZXSD_MAX_TEXT_LENGTH
Maximum lexical length of one element or attribute value.
Definition zxsd.h:87
zxsd_result_t zxsd_validate(const zxsd_schema_t *schema, const char *xml)
Validate an XML document against a generated schema descriptor.
#define ZXSD_MAX_PARTICLES
Maximum number of child particles in one complex type.
Definition zxsd.h:40
void zxsd_xml_reader_dispose(zxsd_xml_reader_t *reader)
Release optional scratch storage owned by a raw XML reader.
zxsd_result_t zxsd_check_runtime(const zxsd_runtime_config_t *expected)
Check application limits and layouts before using runtime-owned code.
zxsd_result_t zxsd_text(zxsd_stream_t *stream, const char *text, size_t length)
Supply decoded character data for the current element.
#define ZXSD_XML_TOKEN_CAPACITY
Maximum bytes retained for one incomplete XML tag, comment, PI, or CDATA section.
Definition zxsd.h:125
zxsd_type_t
Primitive and compound value kinds understood by the runtime.
Definition zxsd.h:187
@ ZXSD_F_MAX_INCLUSIVE
Inclusive upper bound is active.
Definition zxsd.h:275
@ ZXSD_F_MAX_LENGTH
Maximum length is active.
Definition zxsd.h:273
@ ZXSD_F_MIN_EXCLUSIVE
Exclusive lower bound is active.
Definition zxsd.h:276
@ ZXSD_F_PATTERN
Pattern constraint is active.
Definition zxsd.h:278
@ ZXSD_F_LENGTH
Exact length is active.
Definition zxsd.h:271
@ ZXSD_F_FRACTION_DIGITS
Maximum fractional digits is active.
Definition zxsd.h:280
@ ZXSD_F_MAX_EXCLUSIVE
Exclusive upper bound is active.
Definition zxsd.h:277
@ ZXSD_F_TOTAL_DIGITS
Maximum decimal digits is active.
Definition zxsd.h:279
@ ZXSD_F_MIN_LENGTH
Minimum length is active.
Definition zxsd.h:272
@ ZXSD_F_MIN_INCLUSIVE
Inclusive lower bound is active.
Definition zxsd.h:274
@ ZXSD_ID_KEYREF
xs:keyref.
Definition zxsd.h:429
@ ZXSD_ID_UNIQUE
xs:unique.
Definition zxsd.h:427
@ ZXSD_ID_KEY
xs:key.
Definition zxsd.h:428
@ ZXSD_ERR_MISSING_ATTRIBUTE
A required attribute is absent.
Definition zxsd.h:140
@ ZXSD_ERR_IDENTITY_CONSTRAINT
A unique, key or keyref rule failed.
Definition zxsd.h:144
@ ZXSD_ERR_INPUT_TOO_LARGE
XML exceeds ZXSD_MAX_INPUT.
Definition zxsd.h:132
@ ZXSD_ERR_MALFORMED_XML
XML syntax is malformed.
Definition zxsd.h:133
@ ZXSD_ERR_UNSUPPORTED
A valid document cannot be represented by a binding.
Definition zxsd.h:148
@ ZXSD_ERR_OCCURRENCE
An occurrence bound was violated.
Definition zxsd.h:139
@ ZXSD_ERR_MISSING_ELEMENT
A required child element is absent.
Definition zxsd.h:136
@ ZXSD_ERR_INCOMPATIBLE_ABI
Runtime epochs, limits, or public layouts differ.
Definition zxsd.h:149
@ ZXSD_ERR_ELEMENT_ORDER
Sequence order is incorrect.
Definition zxsd.h:138
@ ZXSD_ERR_INVALID_VALUE
A primitive or restricted value is invalid.
Definition zxsd.h:142
@ ZXSD_ERR_UNEXPECTED_ATTRIBUTE
An attribute is not permitted.
Definition zxsd.h:141
@ ZXSD_ERR_EXCESSIVE_NESTING
XML nesting exceeds the limit.
Definition zxsd.h:134
@ ZXSD_ERR_UNEXPECTED_ELEMENT
A child element is not permitted.
Definition zxsd.h:137
@ ZXSD_ERR_WRONG_ROOT
The document root does not match.
Definition zxsd.h:135
@ ZXSD_ERR_TEXT_NOT_ALLOWED
Text occurred in element-only content.
Definition zxsd.h:143
@ ZXSD_ERR_STREAM_LIMIT
A fixed streaming buffer was exceeded.
Definition zxsd.h:145
@ ZXSD_ERR_ARGUMENT
A required argument is invalid.
Definition zxsd.h:131
@ ZXSD_ERR_RESOURCE_LIMIT
A configured resource limit was exceeded.
Definition zxsd.h:146
@ ZXSD_OK
Validation succeeded.
Definition zxsd.h:130
@ ZXSD_ERR_OUTPUT
A binding output sink or buffer failed.
Definition zxsd.h:147
@ ZXSD_WS_COLLAPSE
Replace, trim and collapse whitespace runs.
Definition zxsd.h:236
@ ZXSD_WS_PRESERVE
Keep every character unchanged.
Definition zxsd.h:234
@ ZXSD_WS_REPLACE
Replace tab, carriage return and line feed.
Definition zxsd.h:235
@ ZXSD_SIMPLE_UNION
Value accepted by at least one member type.
Definition zxsd.h:243
@ ZXSD_SIMPLE_ATOMIC
One atomic value.
Definition zxsd.h:241
@ ZXSD_SIMPLE_LIST
Whitespace-separated item sequence.
Definition zxsd.h:242
@ ZXSD_PARTICLE_ALL
Unordered child particles.
Definition zxsd.h:265
@ ZXSD_PARTICLE_SEQUENCE
Ordered child particles.
Definition zxsd.h:263
@ ZXSD_PARTICLE_ANY
Element wildcard.
Definition zxsd.h:266
@ ZXSD_PARTICLE_CHOICE
One alternative.
Definition zxsd.h:264
@ ZXSD_PARTICLE_ELEMENT
Element declaration.
Definition zxsd.h:262
@ ZXSD_SEQUENCE
Children occur in declaration order.
Definition zxsd.h:248
@ ZXSD_ALL
Children may occur in any order.
Definition zxsd.h:250
@ ZXSD_CHOICE
Children select from alternatives.
Definition zxsd.h:249
@ ZXSD_PROCESS_LAX
Validate when a declaration is available.
Definition zxsd.h:256
@ ZXSD_PROCESS_STRICT
A matching declaration is required.
Definition zxsd.h:255
@ ZXSD_PROCESS_SKIP
Accept the matching subtree without validation.
Definition zxsd.h:257
@ ZXSD_XML_EVENT_END_ELEMENT
End element with expanded name.
Definition zxsd.h:598
@ ZXSD_XML_EVENT_TEXT
Decoded character data.
Definition zxsd.h:597
@ ZXSD_XML_EVENT_START_ELEMENT
Start element with expanded name.
Definition zxsd.h:595
@ ZXSD_XML_EVENT_ATTRIBUTE
Attribute on the current element.
Definition zxsd.h:596
@ ZXSD_DERIVATION_EXTENSION
Complex extension.
Definition zxsd.h:285
@ ZXSD_DERIVATION_ALL
Every supported method.
Definition zxsd.h:290
@ ZXSD_DERIVATION_RESTRICTION
Simple or complex restriction.
Definition zxsd.h:286
@ ZXSD_DERIVATION_UNION
Simple union derivation.
Definition zxsd.h:289
@ ZXSD_DERIVATION_SUBSTITUTION
Element substitution group.
Definition zxsd.h:287
@ ZXSD_DERIVATION_LIST
Simple list derivation.
Definition zxsd.h:288
@ ZXSD_T_COMPLEX
Element-only complex content.
Definition zxsd.h:229
@ ZXSD_T_DATE_TIME
XML Schema dateTime.
Definition zxsd.h:216
@ ZXSD_T_NON_NEGATIVE_INTEGER
Integer greater than or equal to zero.
Definition zxsd.h:201
@ ZXSD_T_NON_POSITIVE_INTEGER
Integer less than or equal to zero.
Definition zxsd.h:199
@ ZXSD_T_QNAME
XML Schema QName.
Definition zxsd.h:212
@ ZXSD_T_IDREF
XML Schema IDREF.
Definition zxsd.h:226
@ ZXSD_T_POSITIVE_INTEGER
Integer greater than zero.
Definition zxsd.h:202
@ ZXSD_T_ID
XML Schema ID.
Definition zxsd.h:225
@ ZXSD_T_DATE
XML Schema date.
Definition zxsd.h:215
@ ZXSD_T_BOOLEAN
XML Schema boolean.
Definition zxsd.h:189
@ ZXSD_T_NEGATIVE_INTEGER
Integer less than zero.
Definition zxsd.h:200
@ ZXSD_T_UNSIGNED_SHORT
Unsigned 16-bit XML Schema integer.
Definition zxsd.h:204
@ ZXSD_T_GMONTH_DAY
XML Schema gMonthDay.
Definition zxsd.h:221
@ ZXSD_T_DURATION
XML Schema duration.
Definition zxsd.h:214
@ ZXSD_T_NOTATION
XML Schema NOTATION QName.
Definition zxsd.h:228
@ ZXSD_T_BASE64_BINARY
XML Schema base64Binary.
Definition zxsd.h:224
@ ZXSD_T_HEX_BINARY
XML Schema hexBinary.
Definition zxsd.h:223
@ ZXSD_T_BYTE
Signed 8-bit XML Schema integer.
Definition zxsd.h:198
@ ZXSD_T_DECIMAL
XML Schema decimal.
Definition zxsd.h:193
@ ZXSD_T_LANGUAGE
XML Schema language.
Definition zxsd.h:208
@ ZXSD_T_GDAY
XML Schema gDay.
Definition zxsd.h:222
@ ZXSD_T_STRING
XML Schema string.
Definition zxsd.h:188
@ ZXSD_T_INTEGER
Arbitrary-width integer lexical form.
Definition zxsd.h:192
@ ZXSD_T_NORMALIZED_STRING
XML Schema normalizedString.
Definition zxsd.h:206
@ ZXSD_T_INT
Signed 32-bit XML Schema integer.
Definition zxsd.h:190
@ ZXSD_T_NCNAME
XML Schema NCName.
Definition zxsd.h:210
@ ZXSD_T_GYEAR
XML Schema gYear.
Definition zxsd.h:218
@ ZXSD_T_NMTOKEN
XML Schema NMTOKEN.
Definition zxsd.h:211
@ ZXSD_T_UNSIGNED_BYTE
Unsigned 8-bit XML Schema integer.
Definition zxsd.h:205
@ ZXSD_T_GYEAR_MONTH
XML Schema gYearMonth.
Definition zxsd.h:219
@ ZXSD_T_UNSIGNED_INT
Unsigned 32-bit XML Schema integer.
Definition zxsd.h:191
@ ZXSD_T_FLOAT
XML Schema float.
Definition zxsd.h:194
@ ZXSD_T_UNSIGNED_LONG
Unsigned 64-bit XML Schema integer.
Definition zxsd.h:203
@ ZXSD_T_DOUBLE
XML Schema double.
Definition zxsd.h:195
@ ZXSD_T_ANY_URI
XML Schema anyURI.
Definition zxsd.h:213
@ ZXSD_T_SHORT
Signed 16-bit XML Schema integer.
Definition zxsd.h:197
@ ZXSD_T_TIME
XML Schema time.
Definition zxsd.h:217
@ ZXSD_T_LONG
Signed 64-bit XML Schema integer.
Definition zxsd.h:196
@ ZXSD_T_ENTITY
XML Schema ENTITY.
Definition zxsd.h:227
@ ZXSD_T_GMONTH
XML Schema gMonth.
Definition zxsd.h:220
@ ZXSD_T_TOKEN
XML Schema token.
Definition zxsd.h:207
@ ZXSD_T_NAME
XML Schema Name.
Definition zxsd.h:209
Optional allocator used by validation features requiring scratch storage.
Definition zxsd.h:180
void * context
Opaque callback context.
Definition zxsd.h:183
zxsd_deallocate_fn deallocate
Matching release callback.
Definition zxsd.h:182
zxsd_allocate_fn allocate
Allocation callback.
Definition zxsd.h:181
Generated descriptor for an XML attribute.
Definition zxsd.h:355
const zxsd_simple_t * simple_type
Simple restriction, if any.
Definition zxsd.h:359
const char * fixed_value
Required value when present.
Definition zxsd.h:362
const char * default_value
Value used when absent, or NULL.
Definition zxsd.h:361
const char * name
Local attribute name.
Definition zxsd.h:356
const char * namespace_uri
Required namespace, or NULL.
Definition zxsd.h:360
zxsd_type_t type
Primitive value kind.
Definition zxsd.h:357
int required
Non-zero when required.
Definition zxsd.h:358
Generated descriptor for a complex XML Schema type.
Definition zxsd.h:384
int any_type
Non-zero for the built-in xs:anyType.
Definition zxsd.h:404
unsigned long min_occurs
Minimum model occurrences.
Definition zxsd.h:390
const zxsd_simple_t * simple_content
Text type for simpleContent.
Definition zxsd.h:392
size_t element_count
Number of child descriptors.
Definition zxsd.h:386
unsigned derivation_method
Extension or restriction.
Definition zxsd.h:399
const zxsd_particle_t * particle
Recursive v0.7 content model.
Definition zxsd.h:396
const char * type_namespace
Named type namespace, or NULL.
Definition zxsd.h:402
zxsd_model_t model
Child content model.
Definition zxsd.h:389
const zxsd_attribute_t * attributes
Attribute descriptors.
Definition zxsd.h:387
int mixed_content
Non-zero when character data is allowed.
Definition zxsd.h:403
size_t attribute_count
Number of attribute descriptors.
Definition zxsd.h:388
const char * type_name
Named type local name, or NULL.
Definition zxsd.h:401
unsigned final_methods
Methods forbidden to descendants.
Definition zxsd.h:400
const struct zxsd_complex * base_definition
Named base complex type.
Definition zxsd.h:398
zxsd_type_t simple_content_type
Built-in simpleContent kind.
Definition zxsd.h:393
const zxsd_wildcard_t * any_attribute
Attribute wildcard, or NULL.
Definition zxsd.h:397
int has_simple_content
Non-zero for simpleContent.
Definition zxsd.h:394
const zxsd_element_t * elements
Child particle descriptors.
Definition zxsd.h:385
unsigned long max_occurs
Maximum model occurrences.
Definition zxsd.h:391
unsigned block_methods
Derivations forbidden when this type is used through xsi:type.
Definition zxsd.h:405
int abstract_type
Non-zero if direct use is forbidden.
Definition zxsd.h:395
Generated descriptor for an element particle.
Definition zxsd.h:337
const char * default_value
Schema default, or NULL.
Definition zxsd.h:345
const char * substitution_head_name
Head local name, or NULL.
Definition zxsd.h:350
const zxsd_simple_t * simple_type
Simple restriction, if any.
Definition zxsd.h:343
const char * fixed_value
Required fixed value, or NULL.
Definition zxsd.h:346
zxsd_type_t type
Value kind.
Definition zxsd.h:339
unsigned long min_occurs
Minimum occurrences.
Definition zxsd.h:341
const char * name
Local element name.
Definition zxsd.h:338
unsigned long max_occurs
Maximum, or ULONG_MAX.
Definition zxsd.h:342
int nillable
Non-zero when xsi:nil is allowed.
Definition zxsd.h:347
const char * substitution_head_namespace
Head namespace, or NULL.
Definition zxsd.h:351
const char * namespace_uri
Required namespace, or NULL.
Definition zxsd.h:344
unsigned block_methods
Prohibited runtime substitutions.
Definition zxsd.h:349
const struct zxsd_complex * complex_type
Complex descriptor, if any.
Definition zxsd.h:340
int abstract_element
Non-zero when substitution is required.
Definition zxsd.h:348
Global attribute declaration available to strict/lax wildcards.
Definition zxsd.h:460
const char * default_value
Schema default, or NULL.
Definition zxsd.h:465
const char * namespace_uri
Namespace URI, or NULL.
Definition zxsd.h:462
const zxsd_simple_t * simple_type
Restricted type, or NULL.
Definition zxsd.h:464
const char * fixed_value
Required fixed value, or NULL.
Definition zxsd.h:466
zxsd_type_t type
Simple value kind.
Definition zxsd.h:463
const char * name
Local attribute name.
Definition zxsd.h:461
Global element declaration available to strict/lax wildcards.
Definition zxsd.h:444
const char * substitution_head_name
Head local name, or NULL.
Definition zxsd.h:455
unsigned block_methods
Prohibited substitutions.
Definition zxsd.h:454
const char * namespace_uri
Namespace URI, or NULL.
Definition zxsd.h:446
const char * default_value
Schema default, or NULL.
Definition zxsd.h:450
const zxsd_simple_t * simple_type
Simple descriptor, if any.
Definition zxsd.h:449
const char * name
Local element name.
Definition zxsd.h:445
const char * substitution_head_namespace
Head namespace, or NULL.
Definition zxsd.h:456
zxsd_type_t type
Value kind.
Definition zxsd.h:447
int nillable
Non-zero when xsi:nil is allowed.
Definition zxsd.h:452
const char * fixed_value
Required fixed value, or NULL.
Definition zxsd.h:451
const struct zxsd_complex * complex_type
Complex descriptor, if any.
Definition zxsd.h:448
int abstract_element
Non-zero for an abstract declaration.
Definition zxsd.h:453
Compiled xs:unique, xs:key or xs:keyref descriptor.
Definition zxsd.h:433
size_t refer_index
Referenced key index for keyref.
Definition zxsd.h:440
zxsd_xpath_t selector
Selected element path.
Definition zxsd.h:437
zxsd_identity_kind_t kind
Constraint category.
Definition zxsd.h:435
zxsd_xpath_t scope
Element path that owns each constraint scope.
Definition zxsd.h:436
const zxsd_xpath_t * fields
Tuple fields.
Definition zxsd.h:438
const char * name
Constraint name.
Definition zxsd.h:434
size_t field_count
Number of tuple fields.
Definition zxsd.h:439
Named type entry used to resolve runtime xsi:type values.
Definition zxsd.h:470
const char * name
Type local name.
Definition zxsd.h:471
zxsd_type_t type
Value kind.
Definition zxsd.h:473
const char * namespace_uri
Type namespace, or NULL.
Definition zxsd.h:472
const struct zxsd_complex * complex_type
Complex descriptor.
Definition zxsd.h:474
const zxsd_simple_t * simple_type
Simple descriptor.
Definition zxsd.h:475
Global XML Schema notation declaration.
Definition zxsd.h:479
const char * name
Notation local name.
Definition zxsd.h:480
const char * namespace_uri
Target namespace URI, or NULL.
Definition zxsd.h:481
const char * public_identifier
Public identifier, or NULL.
Definition zxsd.h:482
const char * system_identifier
System URI, or NULL.
Definition zxsd.h:483
Recursive descriptor for a compiled content-model particle.
Definition zxsd.h:373
size_t child_count
Number of group children.
Definition zxsd.h:379
zxsd_particle_kind_t kind
Particle kind.
Definition zxsd.h:374
const zxsd_element_t * element
Element for element particles.
Definition zxsd.h:377
unsigned long max_occurs
Maximum, or ULONG_MAX.
Definition zxsd.h:376
const zxsd_wildcard_t * wildcard
Wildcard configuration.
Definition zxsd.h:380
unsigned long min_occurs
Minimum repetitions.
Definition zxsd.h:375
const struct zxsd_particle * children
Group child particles.
Definition zxsd.h:378
Structured result returned by every generated validator.
Definition zxsd.h:153
const char * path
Schema item involved, or NULL.
Definition zxsd.h:156
size_t offset
Byte offset associated with the result.
Definition zxsd.h:155
const char * message
Static, human-readable status text.
Definition zxsd.h:157
zxsd_error_t code
Validation status.
Definition zxsd.h:154
Caller configuration stamp for a same-toolchain runtime boundary.
Definition zxsd.h:655
unsigned int no_heap
Whether ZXSD_NO_HEAP was defined.
Definition zxsd.h:658
unsigned int runtime_abi
Public API/layout epoch.
Definition zxsd.h:656
unsigned int descriptor_abi
Descriptor interpretation epoch.
Definition zxsd.h:657
Root descriptor consumed by the generic validation runtime.
Definition zxsd.h:487
unsigned block_methods
Root block constraints.
Definition zxsd.h:505
const zxsd_identity_t * identities
Root identity constraints.
Definition zxsd.h:493
size_t notation_count
Number of notation declarations.
Definition zxsd.h:507
size_t global_element_count
Number of global declarations.
Definition zxsd.h:496
const zxsd_simple_t * root_simple
Root simple restriction.
Definition zxsd.h:491
const zxsd_global_attribute_t * global_attributes
Attribute registry.
Definition zxsd.h:497
size_t global_attribute_count
Number of global attributes.
Definition zxsd.h:498
const zxsd_global_element_t * global_elements
Wildcard declaration registry.
Definition zxsd.h:495
const zxsd_complex_t * root_complex
Root complex descriptor.
Definition zxsd.h:490
zxsd_type_t root_type
Root value kind.
Definition zxsd.h:489
const zxsd_notation_t * notations
Global notation declaration registry.
Definition zxsd.h:506
size_t named_type_count
Number of named type entries.
Definition zxsd.h:500
int abstract_element
Non-zero when root is abstract.
Definition zxsd.h:504
int nillable
Non-zero when root permits xsi:nil.
Definition zxsd.h:503
const zxsd_named_type_t * named_types
Runtime xsi:type registry.
Definition zxsd.h:499
const char * root_namespace_uri
Root namespace, or NULL.
Definition zxsd.h:492
const char * default_value
Root default, or NULL.
Definition zxsd.h:501
size_t identity_count
Number of identity constraints.
Definition zxsd.h:494
const char * fixed_value
Root fixed value, or NULL.
Definition zxsd.h:502
const char * root_name
Root local name.
Definition zxsd.h:488
Reference to a built-in or generated simple type.
Definition zxsd.h:296
const struct zxsd_simple * simple
Generated descriptor, or NULL.
Definition zxsd.h:298
zxsd_type_t type
Built-in primitive or derived kind.
Definition zxsd.h:297
Generated descriptor for a restricted, list or union simple type.
Definition zxsd.h:302
const char *const * patterns
Pattern constraints from each restriction.
Definition zxsd.h:325
size_t max_length
Maximum character length.
Definition zxsd.h:307
unsigned facets
Bitwise combination of ZXSD_F_*.
Definition zxsd.h:304
zxsd_whitespace_t whitespace
Normalization applied before validation.
Definition zxsd.h:315
const char * max_exclusive
Exclusive upper-bound text.
Definition zxsd.h:311
zxsd_type_t base
Primitive base type.
Definition zxsd.h:303
size_t member_type_count
Number of union member types.
Definition zxsd.h:319
size_t total_digits
Maximum significant decimal digits.
Definition zxsd.h:329
size_t fraction_digits
Maximum fractional decimal digits.
Definition zxsd.h:330
const char * min_exclusive
Exclusive lower-bound text.
Definition zxsd.h:310
const char * type_namespace
Named type namespace, or NULL.
Definition zxsd.h:324
const char *const * enumeration_namespaces
Namespace URI for each QName/NOTATION enumeration, or NULL.
Definition zxsd.h:328
size_t min_length
Minimum character length.
Definition zxsd.h:306
const char * max_inclusive
Inclusive upper-bound text.
Definition zxsd.h:309
const char * type_name
Named type local name, or NULL.
Definition zxsd.h:323
const zxsd_simple_ref_t * member_types
Union member types.
Definition zxsd.h:318
size_t length
Exact character length.
Definition zxsd.h:305
const char * min_inclusive
Inclusive lower-bound text.
Definition zxsd.h:308
unsigned final_methods
Methods forbidden to descendants.
Definition zxsd.h:322
size_t enumeration_count
Number of enumeration values.
Definition zxsd.h:314
const struct zxsd_simple * base_definition
Named base definition.
Definition zxsd.h:320
size_t pattern_count
Number of conjunctive pattern constraints.
Definition zxsd.h:326
zxsd_simple_variety_t variety
Atomic, list or union variety.
Definition zxsd.h:316
const char *const * enumeration
Permitted lexical values.
Definition zxsd.h:313
unsigned derivation_method
Method used to derive this type.
Definition zxsd.h:321
zxsd_simple_ref_t item_type
Item type for ZXSD_SIMPLE_LIST.
Definition zxsd.h:317
const char * pattern
Embedded pattern expression.
Definition zxsd.h:312
Internal per-element state exposed only to permit static allocation.
Definition zxsd.h:523
int skip_validation
Wildcard skip/lax unknown subtree.
Definition zxsd.h:548
const zxsd_simple_t * simple_type
Effective simple type.
Definition zxsd.h:528
size_t namespace_base
Namespace stack base for this element.
Definition zxsd.h:549
size_t child_count
Number of child events received.
Definition zxsd.h:544
unsigned long model_occurrences
Non-empty sequence iterations consumed by the cursor.
Definition zxsd.h:537
const char * expected_name
Schema-owned expected local name.
Definition zxsd.h:524
const zxsd_complex_t * complex_type
Effective complex type.
Definition zxsd.h:527
size_t text_length
Bytes currently in text.
Definition zxsd.h:543
size_t sequence_index
Current sequence position.
Definition zxsd.h:533
int content_started
Whether attributes are closed.
Definition zxsd.h:547
const char * default_value
Element default.
Definition zxsd.h:529
uint16_t model_states
Head of the nested-model frontier in the shared pool.
Definition zxsd.h:535
zxsd_type_t type
Effective value type.
Definition zxsd.h:526
size_t child_particle_table_count
Number of entries in the particle table.
Definition zxsd.h:540
int incremental_model
Internal content-model cursor mode, or zero for history.
Definition zxsd.h:534
int nilled
Whether xsi:nil was true.
Definition zxsd.h:546
const char * expected_namespace
Schema-owned expected namespace.
Definition zxsd.h:525
const char * fixed_value
Element fixed value.
Definition zxsd.h:530
int nillable
Whether xsi:nil is permitted.
Definition zxsd.h:545
Internal immutable continuation or frontier entry, for static allocation only.
Definition zxsd.h:511
uint32_t references
Owning references to this shared entry.
Definition zxsd.h:515
uint16_t next
Frontier/free-list link, or zero.
Definition zxsd.h:517
unsigned char phase
Internal interpreter instruction.
Definition zxsd.h:518
size_t index
Next sequence term.
Definition zxsd.h:514
unsigned long count
Completed non-empty occurrences.
Definition zxsd.h:513
const struct zxsd_particle * particle
Particle interpreted by this continuation.
Definition zxsd.h:512
uint16_t parent
Continuation after this particle, or zero.
Definition zxsd.h:516
unsigned char started
Current group iteration consumed a token.
Definition zxsd.h:519
Internal namespace binding retained by the event-driven validator.
Definition zxsd.h:556
Bounded state for the event-driven validator.
Definition zxsd.h:571
zxsd_result_t result
Sticky result of the first failed event.
Definition zxsd.h:573
size_t identity_xml_length
Bytes used in identity_xml.
Definition zxsd.h:579
char * identity_xml
Internal reconstructed XML buffer.
Definition zxsd.h:578
size_t depth
Number of currently open elements.
Definition zxsd.h:574
size_t event_offset
Monotonic event index used in diagnostics.
Definition zxsd.h:575
size_t namespace_count
Number of active entries in namespaces.
Definition zxsd.h:582
uint16_t model_high_water
Highest slot ever allocated; bounds interning scans.
Definition zxsd.h:587
const zxsd_schema_t * schema
Generated schema being validated.
Definition zxsd.h:572
size_t identity_xml_capacity
Allocated reconstructed XML bytes.
Definition zxsd.h:580
int model_pool_initialized
Whether the lazy free list has been initialized.
Definition zxsd.h:588
uint16_t model_free
First free pool slot, or zero.
Definition zxsd.h:586
int finished
Non-zero after a complete root element.
Definition zxsd.h:576
zxsd_allocator_t identity_allocator
Allocator for streamed identity validation.
Definition zxsd.h:577
XML Schema element or attribute wildcard.
Definition zxsd.h:366
zxsd_process_t process_contents
strict, lax or skip behavior.
Definition zxsd.h:369
const char * target_namespace
Schema target namespace, or NULL.
Definition zxsd.h:368
const char * namespace_constraint
Original namespace constraint.
Definition zxsd.h:367
Bounded raw-XML reader feeding an event-driven validator.
Definition zxsd.h:626
zxsd_xml_event_fn event_callback
Optional decoded-event observer.
Definition zxsd.h:634
unsigned char quote
Active attribute quote, or zero.
Definition zxsd.h:633
unsigned char markup
Non-zero while retaining markup beginning with <.
Definition zxsd.h:632
size_t token_length
Bytes currently retained in token.
Definition zxsd.h:631
zxsd_result_t result
Sticky result of the first parser or validator error.
Definition zxsd.h:628
size_t token_offset
Absolute offset of the retained token.
Definition zxsd.h:630
zxsd_stream_t validator
Event-driven validator receiving decoded XML events.
Definition zxsd.h:627
size_t offset
Total number of input bytes accepted.
Definition zxsd.h:629
void * event_user_data
Opaque observer context.
Definition zxsd.h:635
One expanded-name step in the restricted identity XPath subset.
Definition zxsd.h:410
const char * namespace_uri
Required namespace, or NULL.
Definition zxsd.h:412
const char * name
Local name, or NULL for a wildcard step.
Definition zxsd.h:411
Compiled restricted XPath used by identity constraints.
Definition zxsd.h:416
int descendant
Non-zero for a leading .
Definition zxsd.h:419
size_t alternative_count
Number of union branches.
Definition zxsd.h:422
size_t step_count
Number of steps.
Definition zxsd.h:418
const struct zxsd_xpath * alternatives
Union branches, or NULL.
Definition zxsd.h:421
int attribute
Non-zero when the final step is an attribute.
Definition zxsd.h:420
const zxsd_xpath_step_t * steps
Path steps.
Definition zxsd.h:417
Release identifiers and generated-code compatibility epochs.