1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Shared `quick_xml` helper utilities for XSD validation.
//!
//! This module provides common parsing functions used across all XSD validators
//! to ensure consistent XML handling with proper whitespace management.
//!
//! # Illegal Character Validation (CRITICAL)
//!
//! **ALL XML validators MUST call `check_for_illegal_xml_characters()` BEFORE parsing.**
//!
//! This is mandatory for all validators because:
//! - It catches illegal XML 1.0 characters (NUL byte, control chars, etc.)
//! - It provides clear, actionable error messages for AI agents
//! - It enables XSD retry to converge instead of spinning with cryptic parse errors
//!
//! Required validation flow for ALL validators:
//! 1. `check_for_illegal_xml_characters()` - MUST be called first
//! 2. `create_reader()` - creates `quick_xml` reader
//! 3. XSD validation - validates structure and content
//!
//! ## XSD Retry Integration
//!
//! When illegal character validation fails:
//! 1. `check_for_illegal_xml_characters()` returns `XsdValidationError` with detailed context
//! 2. The error includes character position, surrounding text, and fix suggestions
//! 3. `format_for_ai_retry()` enhances the error with prominent illegal character warnings
//! 4. XSD retry prompt templates include character validation guidance
//! 5. Agents receive clear, actionable feedback to remove/replace illegal characters
//!
//! This design ensures agents can converge on valid XML even when the initial output
//! contains illegal characters (e.g., from typos like `\u0000` instead of `\u00A0`).
//!
//! Common mistake: Writing `\u0000` (NUL) instead of `\u00A0` (NBSP).
//! The illegal character check detects this and suggests the NBSP fix.
//!
//! # Code Block Content
//!
//! Code blocks containing special characters (`<`, `>`, `&`) MUST use CDATA sections:
//!
//! ```xml
//! <code-block language="rust"><![CDATA[
//! if a < b && c > d {
//! println!("hello");
//! }
//! ]]></code-block>
//! ```
//!
//! The parser handles CDATA correctly - content is preserved exactly as written.
//!
//! # Module Organization
//!
//! - [`validation`] - Illegal character detection and validation
//! - [`readers`] - XML reading and traversal utilities
//! - [`errors`] - Error builder functions for consistent error messages
//! - [`tolerant_parsing`] - Tolerant enum normalization and synonym tables for lenient validation
// Re-export commonly used functions for backward compatibility
pub use ;
pub use ;
pub use check_for_illegal_xml_characters;