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
70
71
72
73
74
75
76
77
//! XML parsing and deserialization for OpenSCENARIO documents
//!
//! This module provides comprehensive parsing capabilities for OpenSCENARIO XML files,
//! including scenario definitions, parameter variations, and catalog files.
//!
//! # Features
//!
//! - **Fast XML parsing** using quick-xml with zero-copy deserialization
//! - **Type-safe validation** with comprehensive error reporting
//! - **Choice group handling** for XSD polymorphic elements
//! - **Catalog file support** for reusable components
//! - **Parameter and expression** resolution
//!
//! # Basic Usage
//!
//! ```rust,no_run
//! use openscenario_rs::parser::xml::{parse_from_file, parse_from_str};
//! use openscenario_rs::parser::validation::ScenarioValidator;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Parse a scenario file
//! let scenario = parse_from_file("scenario.xosc")?;
//!
//! // Parse from XML string
//! let xml_content = r#"<?xml version="1.0"?>
//! <OpenSCENARIO>
//! <FileHeader revMajor="1" revMinor="3" date="2024-01-01T00:00:00"
//! author="Example" description="Basic scenario"/>
//! <!-- scenario content -->
//! </OpenSCENARIO>"#;
//! let scenario = parse_from_str(xml_content)?;
//!
//! // Validate the parsed scenario
//! let mut validator = ScenarioValidator::new();
//! let result = validator.validate_scenario(&scenario);
//! if result.is_valid() {
//! println!("Scenario is valid!");
//! } else {
//! for error in result.errors {
//! println!("Error: {}", error.message);
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Advanced Features
//!
//! ## Custom Validation Configuration
//!
//! ```rust,no_run
//! use openscenario_rs::parser::validation::{ScenarioValidator, ValidationConfig};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # let scenario = openscenario_rs::parse_from_file("scenario.xosc")?;
//! let config = ValidationConfig {
//! strict_mode: true,
//! validate_references: true,
//! validate_constraints: true,
//! max_errors: 50,
//! ..Default::default()
//! };
//!
//! let mut validator = ScenarioValidator::with_config(config);
//! let result = validator.validate_scenario(&scenario);
//! # Ok(())
//! # }
//! ```
//!
//! ## Performance Considerations
//!
//! - Parsing is optimized for speed with zero-copy deserialization
//! - Enable validation caching for repeated validation operations