zxsd 0.20.0
Embedded XML Schema validation for C
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
zxsd validation API

Validate XML documents with generated XSD descriptors. More...

Data Structures

struct  zxsd_result_t
 Structured result returned by every generated validator. More...
 
struct  zxsd_allocator_t
 Optional allocator used by validation features requiring scratch storage. More...
 
struct  zxsd_simple_ref_t
 Reference to a built-in or generated simple type. More...
 
struct  zxsd_simple
 Generated descriptor for a restricted, list or union simple type. More...
 
struct  zxsd_element_t
 Generated descriptor for an element particle. More...
 
struct  zxsd_attribute_t
 Generated descriptor for an XML attribute. More...
 
struct  zxsd_wildcard_t
 XML Schema element or attribute wildcard. More...
 
struct  zxsd_particle
 Recursive descriptor for a compiled content-model particle. More...
 
struct  zxsd_complex
 Generated descriptor for a complex XML Schema type. More...
 
struct  zxsd_xpath_step_t
 One expanded-name step in the restricted identity XPath subset. More...
 
struct  zxsd_xpath
 Compiled restricted XPath used by identity constraints. More...
 
struct  zxsd_identity_t
 Compiled xs:unique, xs:key or xs:keyref descriptor. More...
 
struct  zxsd_global_element_t
 Global element declaration available to strict/lax wildcards. More...
 
struct  zxsd_global_attribute_t
 Global attribute declaration available to strict/lax wildcards. More...
 
struct  zxsd_named_type_t
 Named type entry used to resolve runtime xsi:type values. More...
 
struct  zxsd_notation_t
 Global XML Schema notation declaration. More...
 
struct  zxsd_schema_t
 Root descriptor consumed by the generic validation runtime. More...
 
struct  zxsd_stream_model_node_t
 Internal immutable continuation or frontier entry, for static allocation only. More...
 
struct  zxsd_stream_frame_t
 Internal per-element state exposed only to permit static allocation. More...
 
struct  zxsd_stream_namespace_t
 Internal namespace binding retained by the event-driven validator. More...
 
struct  zxsd_stream_t
 Bounded state for the event-driven validator. More...
 
struct  zxsd_xml_reader_t
 Bounded raw-XML reader feeding an event-driven validator. More...
 
struct  zxsd_runtime_config_t
 Caller configuration stamp for a same-toolchain runtime boundary. More...
 

Macros

#define ZXSD_MAX_INPUT   (1024u * 1024u)
 Maximum accepted XML input size, in bytes.
 
#define ZXSD_MAX_DEPTH   32u
 Maximum nesting depth accepted by the embedded XML parser.
 
#define ZXSD_MAX_PARTICLES   32u
 Maximum number of child particles in one complex type.
 
#define ZXSD_MAX_ATTRIBUTES   32u
 Maximum number of attributes in one element.
 
#define ZXSD_MAX_NAMESPACES   16u
 Maximum number of simultaneously active namespace bindings.
 
#define ZXSD_MAX_IDENTITY_ROWS   64u
 Maximum stored tuples per identity constraint.
 
#define ZXSD_MAX_IDENTITY_VALUES   ZXSD_MAX_IDENTITY_ROWS
 Maximum identity values, retained as a compatibility alias for rows.
 
#define ZXSD_MAX_IDENTITY_TEXT   4096u
 Maximum total UTF-8 bytes retained for document ID and IDREF values.
 
#define ZXSD_MAX_IDENTITY_CONSTRAINTS   16u
 Maximum identity constraints attached to one root declaration.
 
#define ZXSD_MAX_IDENTITY_FIELDS   8u
 Maximum fields in one identity-constraint tuple.
 
#define ZXSD_MAX_XPATH_DEPTH   8u
 Maximum number of steps in a compiled identity XPath.
 
#define ZXSD_MAX_XPATH_ALTERNATIVES   8u
 Maximum union branches in one compiled identity XPath.
 
#define ZXSD_STREAM_TEXT_CAPACITY   ZXSD_MAX_TEXT_LENGTH
 Maximum decoded character data retained for one streamed element.
 
#define ZXSD_MAX_TEXT_LENGTH   1024u
 Maximum lexical length of one element or attribute value.
 
#define ZXSD_MAX_PATTERN_LENGTH   4096u
 Maximum UTF-8 byte length of one generated XSD regular expression.
 
#define ZXSD_MAX_REGEX_NODES   512u
 Maximum parsed expression nodes used by the allocation-free regex engine.
 
#define ZXSD_MAX_REGEX_DEPTH   32u
 Maximum parenthesis and character-class subtraction nesting depth.
 
#define ZXSD_MAX_SCHEMA_COMPLEXITY   4096u
 Maximum aggregate descriptor count accepted by the runtime.
 
#define ZXSD_STREAM_NAME_CAPACITY   128u
 Maximum local-name or namespace-URI length accepted by streaming calls.
 
#define ZXSD_STREAM_CHILD_CAPACITY   64u
 Maximum child tokens retained for a streamed model requiring history.
 
#define ZXSD_STREAM_MODEL_CAPACITY   128u
 Shared continuation/state slots for nested streaming content models.
 
#define ZXSD_XML_TOKEN_CAPACITY   4096u
 Maximum bytes retained for one incomplete XML tag, comment, PI, or CDATA section.
 
#define ZXSD_RUNTIME_CONFIG_INIT
 Initialize a runtime stamp using the including translation unit's configuration.
 

Typedefs

typedef void *(* zxsd_allocate_fn) (void *context, size_t size)
 Allocate runtime scratch storage.
 
typedef void(* zxsd_deallocate_fn) (void *context, void *pointer)
 Release runtime scratch storage.
 
typedef struct zxsd_simple zxsd_simple_t
 Generated descriptor for a restricted, list or union simple type.
 
typedef struct zxsd_particle zxsd_particle_t
 Recursive descriptor for a compiled content-model particle.
 
typedef struct zxsd_complex zxsd_complex_t
 Generated descriptor for a complex XML Schema type.
 
typedef struct zxsd_xpath zxsd_xpath_t
 Compiled restricted XPath used by identity constraints.
 
typedef 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.
 

Enumerations

enum  zxsd_error_t {
  ZXSD_OK = 0 , ZXSD_ERR_ARGUMENT , ZXSD_ERR_INPUT_TOO_LARGE , ZXSD_ERR_MALFORMED_XML ,
  ZXSD_ERR_EXCESSIVE_NESTING , ZXSD_ERR_WRONG_ROOT , ZXSD_ERR_MISSING_ELEMENT , ZXSD_ERR_UNEXPECTED_ELEMENT ,
  ZXSD_ERR_ELEMENT_ORDER , ZXSD_ERR_OCCURRENCE , ZXSD_ERR_MISSING_ATTRIBUTE , ZXSD_ERR_UNEXPECTED_ATTRIBUTE ,
  ZXSD_ERR_INVALID_VALUE , ZXSD_ERR_TEXT_NOT_ALLOWED , ZXSD_ERR_IDENTITY_CONSTRAINT , ZXSD_ERR_STREAM_LIMIT ,
  ZXSD_ERR_RESOURCE_LIMIT , ZXSD_ERR_OUTPUT , ZXSD_ERR_UNSUPPORTED , ZXSD_ERR_INCOMPATIBLE_ABI
}
 Validation status and error codes. More...
 
enum  zxsd_type_t {
  ZXSD_T_STRING , ZXSD_T_BOOLEAN , ZXSD_T_INT , ZXSD_T_UNSIGNED_INT ,
  ZXSD_T_INTEGER , ZXSD_T_DECIMAL , ZXSD_T_FLOAT , ZXSD_T_DOUBLE ,
  ZXSD_T_LONG , ZXSD_T_SHORT , ZXSD_T_BYTE , ZXSD_T_NON_POSITIVE_INTEGER ,
  ZXSD_T_NEGATIVE_INTEGER , ZXSD_T_NON_NEGATIVE_INTEGER , ZXSD_T_POSITIVE_INTEGER , ZXSD_T_UNSIGNED_LONG ,
  ZXSD_T_UNSIGNED_SHORT , ZXSD_T_UNSIGNED_BYTE , ZXSD_T_NORMALIZED_STRING , ZXSD_T_TOKEN ,
  ZXSD_T_LANGUAGE , ZXSD_T_NAME , ZXSD_T_NCNAME , ZXSD_T_NMTOKEN ,
  ZXSD_T_QNAME , ZXSD_T_ANY_URI , ZXSD_T_DURATION , ZXSD_T_DATE ,
  ZXSD_T_DATE_TIME , ZXSD_T_TIME , ZXSD_T_GYEAR , ZXSD_T_GYEAR_MONTH ,
  ZXSD_T_GMONTH , ZXSD_T_GMONTH_DAY , ZXSD_T_GDAY , ZXSD_T_HEX_BINARY ,
  ZXSD_T_BASE64_BINARY , ZXSD_T_ID , ZXSD_T_IDREF , ZXSD_T_ENTITY ,
  ZXSD_T_NOTATION , ZXSD_T_COMPLEX
}
 Primitive and compound value kinds understood by the runtime. More...
 
enum  zxsd_whitespace_t { ZXSD_WS_PRESERVE = 0 , ZXSD_WS_REPLACE , ZXSD_WS_COLLAPSE }
 Whitespace treatment prescribed by an XML Schema simple type. More...
 
enum  zxsd_simple_variety_t { ZXSD_SIMPLE_ATOMIC = 0 , ZXSD_SIMPLE_LIST , ZXSD_SIMPLE_UNION }
 Variety of an XML Schema simple type. More...
 
enum  zxsd_model_t { ZXSD_SEQUENCE = 0 , ZXSD_CHOICE , ZXSD_ALL }
 Complex content model kind. More...
 
enum  zxsd_process_t { ZXSD_PROCESS_STRICT = 0 , ZXSD_PROCESS_LAX , ZXSD_PROCESS_SKIP }
 Wildcard validation behavior. More...
 
enum  zxsd_particle_kind_t {
  ZXSD_PARTICLE_ELEMENT = 0 , ZXSD_PARTICLE_SEQUENCE , ZXSD_PARTICLE_CHOICE , ZXSD_PARTICLE_ALL ,
  ZXSD_PARTICLE_ANY
}
 Compiled content-model particle kind. More...
 
enum  {
  ZXSD_F_LENGTH = 1u << 0 , ZXSD_F_MIN_LENGTH = 1u << 1 , ZXSD_F_MAX_LENGTH = 1u << 2 , ZXSD_F_MIN_INCLUSIVE = 1u << 3 ,
  ZXSD_F_MAX_INCLUSIVE = 1u << 4 , ZXSD_F_MIN_EXCLUSIVE = 1u << 5 , ZXSD_F_MAX_EXCLUSIVE = 1u << 6 , ZXSD_F_PATTERN = 1u << 7 ,
  ZXSD_F_TOTAL_DIGITS = 1u << 8 , ZXSD_F_FRACTION_DIGITS = 1u << 9
}
 Simple-type facet flags used by zxsd_simple_t. More...
 
enum  {
  ZXSD_DERIVATION_EXTENSION = 1u << 0 , ZXSD_DERIVATION_RESTRICTION = 1u << 1 , ZXSD_DERIVATION_SUBSTITUTION = 1u << 2 , ZXSD_DERIVATION_LIST = 1u << 3 ,
  ZXSD_DERIVATION_UNION = 1u << 4 , ZXSD_DERIVATION_ALL = 0x1fu
}
 Type-derivation methods used by block and final. More...
 
enum  zxsd_identity_kind_t { ZXSD_ID_UNIQUE = 0 , ZXSD_ID_KEY , ZXSD_ID_KEYREF }
 Identity-constraint category. More...
 
enum  zxsd_xml_event_t { ZXSD_XML_EVENT_START_ELEMENT , ZXSD_XML_EVENT_ATTRIBUTE , ZXSD_XML_EVENT_TEXT , ZXSD_XML_EVENT_END_ELEMENT }
 Decoded XML events exposed by the incremental raw-XML reader. More...
 

Functions

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_validate (const zxsd_schema_t *schema, const char *xml)
 Validate an XML document against a generated schema descriptor.
 
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.
 
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_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.
 
void zxsd_stream_dispose (zxsd_stream_t *stream)
 Release optional streaming scratch storage.
 
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_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_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_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.
 
zxsd_result_t zxsd_start_content (zxsd_stream_t *stream)
 Close the attribute phase of the current start tag.
 
zxsd_result_t zxsd_text (zxsd_stream_t *stream, const char *text, size_t length)
 Supply decoded character data for the current element.
 
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_stream_finish (zxsd_stream_t *stream)
 Verify that exactly one complete root element was supplied.
 
zxsd_result_t zxsd_xml_reader_init (zxsd_xml_reader_t *reader, const zxsd_schema_t *schema)
 Initialize a raw, incrementally fed XML validator.
 
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.
 
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.
 
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.
 
zxsd_result_t zxsd_xml_reader_finish (zxsd_xml_reader_t *reader)
 Finish an incrementally supplied XML document.
 
void zxsd_xml_reader_dispose (zxsd_xml_reader_t *reader)
 Release optional scratch storage owned by a raw XML reader.
 
const char * zxsd_error_string (zxsd_error_t error)
 Get a stable human-readable description of an error code.
 

Detailed Description

Validate XML documents with generated XSD descriptors.

Macro Definition Documentation

◆ ZXSD_MAX_ATTRIBUTES

#define ZXSD_MAX_ATTRIBUTES   32u

Maximum number of attributes in one element.

Definition at line 47 of file zxsd.h.

◆ ZXSD_MAX_DEPTH

#define ZXSD_MAX_DEPTH   32u

Maximum nesting depth accepted by the embedded XML parser.

Definition at line 36 of file zxsd.h.

◆ ZXSD_MAX_IDENTITY_CONSTRAINTS

#define ZXSD_MAX_IDENTITY_CONSTRAINTS   16u

Maximum identity constraints attached to one root declaration.

Definition at line 67 of file zxsd.h.

◆ ZXSD_MAX_IDENTITY_FIELDS

#define ZXSD_MAX_IDENTITY_FIELDS   8u

Maximum fields in one identity-constraint tuple.

Definition at line 71 of file zxsd.h.

◆ ZXSD_MAX_IDENTITY_ROWS

#define ZXSD_MAX_IDENTITY_ROWS   64u

Maximum stored tuples per identity constraint.

Definition at line 55 of file zxsd.h.

◆ ZXSD_MAX_IDENTITY_TEXT

#define ZXSD_MAX_IDENTITY_TEXT   4096u

Maximum total UTF-8 bytes retained for document ID and IDREF values.

Definition at line 63 of file zxsd.h.

◆ ZXSD_MAX_IDENTITY_VALUES

#define ZXSD_MAX_IDENTITY_VALUES   ZXSD_MAX_IDENTITY_ROWS

Maximum identity values, retained as a compatibility alias for rows.

Definition at line 59 of file zxsd.h.

◆ ZXSD_MAX_INPUT

#define ZXSD_MAX_INPUT   (1024u * 1024u)

Maximum accepted XML input size, in bytes.

Definition at line 32 of file zxsd.h.

◆ ZXSD_MAX_NAMESPACES

#define ZXSD_MAX_NAMESPACES   16u

Maximum number of simultaneously active namespace bindings.

Definition at line 51 of file zxsd.h.

◆ ZXSD_MAX_PARTICLES

#define ZXSD_MAX_PARTICLES   32u

Maximum number of child particles in one complex type.

Definition at line 40 of file zxsd.h.

◆ ZXSD_MAX_PATTERN_LENGTH

#define ZXSD_MAX_PATTERN_LENGTH   4096u

Maximum UTF-8 byte length of one generated XSD regular expression.

Definition at line 91 of file zxsd.h.

◆ ZXSD_MAX_REGEX_DEPTH

#define ZXSD_MAX_REGEX_DEPTH   32u

Maximum parenthesis and character-class subtraction nesting depth.

Definition at line 99 of file zxsd.h.

◆ ZXSD_MAX_REGEX_NODES

#define ZXSD_MAX_REGEX_NODES   512u

Maximum parsed expression nodes used by the allocation-free regex engine.

Definition at line 95 of file zxsd.h.

◆ ZXSD_MAX_SCHEMA_COMPLEXITY

#define ZXSD_MAX_SCHEMA_COMPLEXITY   4096u

Maximum aggregate descriptor count accepted by the runtime.

Definition at line 103 of file zxsd.h.

◆ ZXSD_MAX_TEXT_LENGTH

#define ZXSD_MAX_TEXT_LENGTH   1024u

Maximum lexical length of one element or attribute value.

Definition at line 87 of file zxsd.h.

◆ ZXSD_MAX_XPATH_ALTERNATIVES

#define ZXSD_MAX_XPATH_ALTERNATIVES   8u

Maximum union branches in one compiled identity XPath.

Definition at line 79 of file zxsd.h.

◆ ZXSD_MAX_XPATH_DEPTH

#define ZXSD_MAX_XPATH_DEPTH   8u

Maximum number of steps in a compiled identity XPath.

Definition at line 75 of file zxsd.h.

◆ ZXSD_RUNTIME_CONFIG_INIT

#define ZXSD_RUNTIME_CONFIG_INIT

Initialize a runtime stamp using the including translation unit's configuration.

Definition at line 664 of file zxsd.h.

◆ ZXSD_STREAM_CHILD_CAPACITY

#define ZXSD_STREAM_CHILD_CAPACITY   64u

Maximum child tokens retained for a streamed model requiring history.

Incremental models use counters and do not consume this capacity.

Definition at line 113 of file zxsd.h.

◆ ZXSD_STREAM_MODEL_CAPACITY

#define ZXSD_STREAM_MODEL_CAPACITY   128u

Shared continuation/state slots for nested streaming content models.

Storage is shared by all open elements, not multiplied by XML depth. Exhaustion returns ZXSD_ERR_STREAM_LIMIT. Zero selects child history instead; flat models always retain their allocation-free fast path.

Definition at line 121 of file zxsd.h.

◆ ZXSD_STREAM_NAME_CAPACITY

#define ZXSD_STREAM_NAME_CAPACITY   128u

Maximum local-name or namespace-URI length accepted by streaming calls.

Definition at line 107 of file zxsd.h.

◆ ZXSD_STREAM_TEXT_CAPACITY

#define ZXSD_STREAM_TEXT_CAPACITY   ZXSD_MAX_TEXT_LENGTH

Maximum decoded character data retained for one streamed element.

Definition at line 83 of file zxsd.h.

◆ ZXSD_XML_TOKEN_CAPACITY

#define ZXSD_XML_TOKEN_CAPACITY   4096u

Maximum bytes retained for one incomplete XML tag, comment, PI, or CDATA section.

Definition at line 125 of file zxsd.h.

Typedef Documentation

◆ zxsd_allocate_fn

typedef void *(* zxsd_allocate_fn) (void *context, size_t size)

Allocate runtime scratch storage.

Parameters
[in]contextOpaque allocator context.
[in]sizeNumber of bytes to allocate.
Returns
Pointer to the allocated storage on success.
Return values
NULLIf the storage could not be allocated.

Definition at line 169 of file zxsd.h.

◆ zxsd_deallocate_fn

typedef void(* zxsd_deallocate_fn) (void *context, void *pointer)

Release runtime scratch storage.

Parameters
[in]contextOpaque allocator context.
[in]pointerStorage previously returned by zxsd_allocate_fn.

Definition at line 177 of file zxsd.h.

◆ zxsd_xml_event_fn

typedef 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.

All strings are transient and valid only for the duration of the callback. value is set only for attribute and text events. Text can contain embedded NUL bytes and must be consumed using value_length.

Parameters
[in]user_dataOpaque value supplied by the application.
[in]eventEvent category.
[in]namespace_uriNamespace URI, or an empty string.
[in]local_nameLocal element or attribute name, or NULL for text.
[in]valueAttribute value or character data, otherwise NULL.
[in]value_lengthNumber of bytes in value.

Definition at line 615 of file zxsd.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Simple-type facet flags used by zxsd_simple_t.

Enumerator
ZXSD_F_LENGTH 

Exact length is active.

ZXSD_F_MIN_LENGTH 

Minimum length is active.

ZXSD_F_MAX_LENGTH 

Maximum length is active.

ZXSD_F_MIN_INCLUSIVE 

Inclusive lower bound is active.

ZXSD_F_MAX_INCLUSIVE 

Inclusive upper bound is active.

ZXSD_F_MIN_EXCLUSIVE 

Exclusive lower bound is active.

ZXSD_F_MAX_EXCLUSIVE 

Exclusive upper bound is active.

ZXSD_F_PATTERN 

Pattern constraint is active.

ZXSD_F_TOTAL_DIGITS 

Maximum decimal digits is active.

ZXSD_F_FRACTION_DIGITS 

Maximum fractional digits is active.

Definition at line 270 of file zxsd.h.

◆ anonymous enum

anonymous enum

Type-derivation methods used by block and final.

Enumerator
ZXSD_DERIVATION_EXTENSION 

Complex extension.

ZXSD_DERIVATION_RESTRICTION 

Simple or complex restriction.

ZXSD_DERIVATION_SUBSTITUTION 

Element substitution group.

ZXSD_DERIVATION_LIST 

Simple list derivation.

ZXSD_DERIVATION_UNION 

Simple union derivation.

ZXSD_DERIVATION_ALL 

Every supported method.

Definition at line 284 of file zxsd.h.

◆ zxsd_error_t

Validation status and error codes.

Enumerator
ZXSD_OK 

Validation succeeded.

ZXSD_ERR_ARGUMENT 

A required argument is invalid.

ZXSD_ERR_INPUT_TOO_LARGE 

XML exceeds ZXSD_MAX_INPUT.

ZXSD_ERR_MALFORMED_XML 

XML syntax is malformed.

ZXSD_ERR_EXCESSIVE_NESTING 

XML nesting exceeds the limit.

ZXSD_ERR_WRONG_ROOT 

The document root does not match.

ZXSD_ERR_MISSING_ELEMENT 

A required child element is absent.

ZXSD_ERR_UNEXPECTED_ELEMENT 

A child element is not permitted.

ZXSD_ERR_ELEMENT_ORDER 

Sequence order is incorrect.

ZXSD_ERR_OCCURRENCE 

An occurrence bound was violated.

ZXSD_ERR_MISSING_ATTRIBUTE 

A required attribute is absent.

ZXSD_ERR_UNEXPECTED_ATTRIBUTE 

An attribute is not permitted.

ZXSD_ERR_INVALID_VALUE 

A primitive or restricted value is invalid.

ZXSD_ERR_TEXT_NOT_ALLOWED 

Text occurred in element-only content.

ZXSD_ERR_IDENTITY_CONSTRAINT 

A unique, key or keyref rule failed.

ZXSD_ERR_STREAM_LIMIT 

A fixed streaming buffer was exceeded.

ZXSD_ERR_RESOURCE_LIMIT 

A configured resource limit was exceeded.

ZXSD_ERR_OUTPUT 

A binding output sink or buffer failed.

ZXSD_ERR_UNSUPPORTED 

A valid document cannot be represented by a binding.

ZXSD_ERR_INCOMPATIBLE_ABI 

Runtime epochs, limits, or public layouts differ.

Definition at line 129 of file zxsd.h.

◆ zxsd_identity_kind_t

Identity-constraint category.

Enumerator
ZXSD_ID_UNIQUE 

xs:unique.

ZXSD_ID_KEY 

xs:key.

ZXSD_ID_KEYREF 

xs:keyref.

Definition at line 426 of file zxsd.h.

◆ zxsd_model_t

Complex content model kind.

Enumerator
ZXSD_SEQUENCE 

Children occur in declaration order.

ZXSD_CHOICE 

Children select from alternatives.

ZXSD_ALL 

Children may occur in any order.

Definition at line 247 of file zxsd.h.

◆ zxsd_particle_kind_t

Compiled content-model particle kind.

Enumerator
ZXSD_PARTICLE_ELEMENT 

Element declaration.

ZXSD_PARTICLE_SEQUENCE 

Ordered child particles.

ZXSD_PARTICLE_CHOICE 

One alternative.

ZXSD_PARTICLE_ALL 

Unordered child particles.

ZXSD_PARTICLE_ANY 

Element wildcard.

Definition at line 261 of file zxsd.h.

◆ zxsd_process_t

Wildcard validation behavior.

Enumerator
ZXSD_PROCESS_STRICT 

A matching declaration is required.

ZXSD_PROCESS_LAX 

Validate when a declaration is available.

ZXSD_PROCESS_SKIP 

Accept the matching subtree without validation.

Definition at line 254 of file zxsd.h.

◆ zxsd_simple_variety_t

Variety of an XML Schema simple type.

Enumerator
ZXSD_SIMPLE_ATOMIC 

One atomic value.

ZXSD_SIMPLE_LIST 

Whitespace-separated item sequence.

ZXSD_SIMPLE_UNION 

Value accepted by at least one member type.

Definition at line 240 of file zxsd.h.

◆ zxsd_type_t

Primitive and compound value kinds understood by the runtime.

Enumerator
ZXSD_T_STRING 

XML Schema string.

ZXSD_T_BOOLEAN 

XML Schema boolean.

ZXSD_T_INT 

Signed 32-bit XML Schema integer.

ZXSD_T_UNSIGNED_INT 

Unsigned 32-bit XML Schema integer.

ZXSD_T_INTEGER 

Arbitrary-width integer lexical form.

ZXSD_T_DECIMAL 

XML Schema decimal.

ZXSD_T_FLOAT 

XML Schema float.

ZXSD_T_DOUBLE 

XML Schema double.

ZXSD_T_LONG 

Signed 64-bit XML Schema integer.

ZXSD_T_SHORT 

Signed 16-bit XML Schema integer.

ZXSD_T_BYTE 

Signed 8-bit XML Schema integer.

ZXSD_T_NON_POSITIVE_INTEGER 

Integer less than or equal to zero.

ZXSD_T_NEGATIVE_INTEGER 

Integer less than zero.

ZXSD_T_NON_NEGATIVE_INTEGER 

Integer greater than or equal to zero.

ZXSD_T_POSITIVE_INTEGER 

Integer greater than zero.

ZXSD_T_UNSIGNED_LONG 

Unsigned 64-bit XML Schema integer.

ZXSD_T_UNSIGNED_SHORT 

Unsigned 16-bit XML Schema integer.

ZXSD_T_UNSIGNED_BYTE 

Unsigned 8-bit XML Schema integer.

ZXSD_T_NORMALIZED_STRING 

XML Schema normalizedString.

ZXSD_T_TOKEN 

XML Schema token.

ZXSD_T_LANGUAGE 

XML Schema language.

ZXSD_T_NAME 

XML Schema Name.

ZXSD_T_NCNAME 

XML Schema NCName.

ZXSD_T_NMTOKEN 

XML Schema NMTOKEN.

ZXSD_T_QNAME 

XML Schema QName.

ZXSD_T_ANY_URI 

XML Schema anyURI.

ZXSD_T_DURATION 

XML Schema duration.

ZXSD_T_DATE 

XML Schema date.

ZXSD_T_DATE_TIME 

XML Schema dateTime.

ZXSD_T_TIME 

XML Schema time.

ZXSD_T_GYEAR 

XML Schema gYear.

ZXSD_T_GYEAR_MONTH 

XML Schema gYearMonth.

ZXSD_T_GMONTH 

XML Schema gMonth.

ZXSD_T_GMONTH_DAY 

XML Schema gMonthDay.

ZXSD_T_GDAY 

XML Schema gDay.

ZXSD_T_HEX_BINARY 

XML Schema hexBinary.

ZXSD_T_BASE64_BINARY 

XML Schema base64Binary.

ZXSD_T_ID 

XML Schema ID.

ZXSD_T_IDREF 

XML Schema IDREF.

ZXSD_T_ENTITY 

XML Schema ENTITY.

ZXSD_T_NOTATION 

XML Schema NOTATION QName.

ZXSD_T_COMPLEX 

Element-only complex content.

Definition at line 187 of file zxsd.h.

◆ zxsd_whitespace_t

Whitespace treatment prescribed by an XML Schema simple type.

Enumerator
ZXSD_WS_PRESERVE 

Keep every character unchanged.

ZXSD_WS_REPLACE 

Replace tab, carriage return and line feed.

ZXSD_WS_COLLAPSE 

Replace, trim and collapse whitespace runs.

Definition at line 233 of file zxsd.h.

◆ zxsd_xml_event_t

Decoded XML events exposed by the incremental raw-XML reader.

Enumerator
ZXSD_XML_EVENT_START_ELEMENT 

Start element with expanded name.

ZXSD_XML_EVENT_ATTRIBUTE 

Attribute on the current element.

ZXSD_XML_EVENT_TEXT 

Decoded character data.

ZXSD_XML_EVENT_END_ELEMENT 

End element with expanded name.

Definition at line 594 of file zxsd.h.

Function Documentation

◆ zxsd_attribute()

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.

Parameters
[in,out]streamInitialized validation context.
[in]namespace_uriNamespace URI, or NULL for no namespace.
[in]local_nameAttribute local name.
[in]valueDecoded attribute value.
Returns
The sticky validation result.

◆ zxsd_check_runtime()

zxsd_result_t zxsd_check_runtime ( const zxsd_runtime_config_t *  expected)

Check application limits and layouts before using runtime-owned code.

Call once before validation or initializing caller-owned contexts when linking a separately built runtime. No context or descriptor is accessed. Matching stamps are necessary, not sufficient, for binary compatibility: architecture, calling convention, packing, and compiler ABI options must also match.

Parameters
[in]expectedApplication stamp initialized with ZXSD_RUNTIME_CONFIG_INIT.
Return values
ZXSD_OKEpochs, resource limits, and recorded layout sizes match.
ZXSD_ERR_ARGUMENTThe stamp is NULL.
ZXSD_ERR_INCOMPATIBLE_ABIThe runtime configuration differs.
Returns
A structured result.

◆ zxsd_end_element()

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.

Parameters
[in,out]streamInitialized validation context.
[in]namespace_uriNamespace URI, or NULL for no namespace.
[in]local_nameElement local name.
Returns
The sticky validation result.

◆ zxsd_error_string()

const char * zxsd_error_string ( zxsd_error_t  error)

Get a stable human-readable description of an error code.

Parameters
[in]errorError code to describe.
Returns
A pointer to a static NUL-terminated string.

◆ zxsd_namespace()

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.

Call this for bindings used by QName- or NOTATION-valued attributes/text.

Parameters
[in,out]streamInitialized validation context.
[in]prefixNamespace prefix, or an empty string for the default namespace.
[in]namespace_uriNamespace URI bound to prefix.
Returns
The sticky validation result.

◆ zxsd_start_content()

zxsd_result_t zxsd_start_content ( zxsd_stream_t *  stream)

Close the attribute phase of the current start tag.

Parameters
[in,out]streamInitialized validation context.
Returns
The sticky validation result.

◆ zxsd_start_element()

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.

Parameters
[in,out]streamInitialized validation context.
[in]namespace_uriNamespace URI, or NULL for no namespace.
[in]local_nameElement local name.
Returns
The sticky validation result.

◆ zxsd_stream_dispose()

void zxsd_stream_dispose ( zxsd_stream_t *  stream)

Release optional streaming scratch storage.

Call this after an application aborts an event sequence. Calling it on an initialized context that owns no scratch storage is safe.

Parameters
[in,out]streamValidation context to dispose.

◆ zxsd_stream_finish()

zxsd_result_t zxsd_stream_finish ( zxsd_stream_t *  stream)

Verify that exactly one complete root element was supplied.

Parameters
[in,out]streamInitialized validation context.
Returns
The final sticky validation result.

◆ zxsd_stream_init()

zxsd_result_t zxsd_stream_init ( zxsd_stream_t *  stream,
const zxsd_schema_t *  schema 
)

Initialize an event-driven validation context.

Parameters
[out]streamValidation context to initialize.
[in]schemaGenerated schema descriptor.
Return values
ZXSD_OKThe context was initialized.
ZXSD_ERR_ARGUMENTAn argument is invalid.
ZXSD_ERR_RESOURCE_LIMITThe schema requires explicit scratch storage.

◆ zxsd_stream_init_with_allocator()

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.

The allocator is used only when the schema contains identity constraints. Passing NULL is valid for schemas without them and otherwise returns ZXSD_ERR_RESOURCE_LIMIT.

Parameters
[out]streamValidation context to initialize.
[in]schemaGenerated schema descriptor.
[in]allocatorScratch allocator, or NULL.
Return values
ZXSD_OKThe context was initialized.
ZXSD_ERR_ARGUMENTAn argument is invalid.
ZXSD_ERR_RESOURCE_LIMITScratch storage could not be allocated.

◆ zxsd_text()

zxsd_result_t zxsd_text ( zxsd_stream_t *  stream,
const char *  text,
size_t  length 
)

Supply decoded character data for the current element.

Parameters
[in,out]streamInitialized validation context.
[in]textDecoded character data; it need not be NUL-terminated.
[in]lengthNumber of bytes in text.
Returns
The sticky validation result.

◆ zxsd_validate()

zxsd_result_t zxsd_validate ( const zxsd_schema_t *  schema,
const char *  xml 
)

Validate an XML document against a generated schema descriptor.

Parameters
[in]schemaGenerated schema descriptor.
[in]xmlNUL-terminated XML document.
Return values
ZXSD_OKThe document is valid.
ZXSD_ERR_ARGUMENTAn argument is invalid.
Returns
A structured validation result for all other outcomes.

◆ zxsd_validate_with_allocator()

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.

Pass NULL as allocator to select zero-heap operation. Schemas with identity constraints then return ZXSD_ERR_RESOURCE_LIMIT.

Parameters
[in]schemaGenerated schema descriptor.
[in]xmlNUL-terminated XML document.
[in]allocatorScratch allocator, or NULL.
Return values
ZXSD_OKThe document is valid.
ZXSD_ERR_ARGUMENTAn argument is invalid.
ZXSD_ERR_RESOURCE_LIMITScratch storage is required but unavailable.
Returns
A structured validation result for all other outcomes.

◆ zxsd_xml_reader_dispose()

void zxsd_xml_reader_dispose ( zxsd_xml_reader_t *  reader)

Release optional scratch storage owned by a raw XML reader.

Parameters
[in,out]readerInitialized reader to dispose.

◆ zxsd_xml_reader_feed()

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.

Fragments need not be NUL-terminated and may end inside UTF-8 sequences, entity references, tags, attributes, comments, processing instructions, or CDATA sections. Input storage may be reused as soon as this function returns.

Parameters
[in,out]readerInitialized reader.
[in]dataInput bytes; may be NULL only when length is zero.
[in]lengthNumber of bytes in data.
Returns
The sticky parsing or validation result.

◆ zxsd_xml_reader_finish()

zxsd_result_t zxsd_xml_reader_finish ( zxsd_xml_reader_t *  reader)

Finish an incrementally supplied XML document.

Parameters
[in,out]readerInitialized reader.
Return values
ZXSD_OKThe complete document is well formed and schema-valid.
ZXSD_ERR_MALFORMED_XMLThe document ends in an incomplete token.
Returns
The sticky parsing or validation result.

◆ zxsd_xml_reader_init()

zxsd_result_t zxsd_xml_reader_init ( zxsd_xml_reader_t *  reader,
const zxsd_schema_t *  schema 
)

Initialize a raw, incrementally fed XML validator.

Parameters
[out]readerReader context to initialize.
[in]schemaGenerated schema descriptor.
Returns
A structured initialization result.

◆ zxsd_xml_reader_init_with_allocator()

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.

Parameters
[out]readerReader context to initialize.
[in]schemaGenerated schema descriptor.
[in]allocatorScratch allocator, or NULL.
Returns
A structured initialization result.

◆ zxsd_xml_reader_set_event_callback()

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.

The observer runs synchronously after the validator accepts each event. It may copy selected values but must not retain the supplied string pointers.

Parameters
[in,out]readerInitialized reader.
[in]callbackObserver callback, or NULL to disable observation.
[in]user_dataOpaque value passed to callback.

◆ zxsd_xsi_type()

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.

Parameters
[in,out]streamInitialized validation context.
[in]type_namespace_uriType namespace URI, or NULL for no namespace.
[in]type_local_nameType local name.
Returns
The sticky validation result.