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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use thiserror::Error;
use xsd_parser_types::misc::{Namespace, NamespacePrefix, RawByteStr};
use crate::models::{
schema::xs::{AttributeType, Facet},
TypeIdent,
};
/// error raised by the [`Interpreter`](super::Interpreter).
#[derive(Debug, Error)]
pub enum Error {
/// Type has already been defined.
///
/// Is raised if a new type with an already existing identifier is added
/// to the [`MetaTypes`](crate::models::meta::MetaTypes) structure.
#[error("Type has already been defined: {0}!")]
TypeAlreadyDefined(TypeIdent),
/// Ambiguous type definition
///
/// Is raised by the interpreter if it tries to resolve a certain type
/// identifier during interpretation of the schema, but multiple matching
/// types were found.
#[error("Ambiguous type: {0}!")]
AmbiguousType(TypeIdent),
/// Expected simple type.
///
/// Expected the specified type to be simple because it is referenced
/// in a context that requires a simple type.
#[error("Expected simple type: {0}!")]
ExpectedSimpleType(TypeIdent),
/// Expected complex type.
///
/// Expected the specified type to be complex because it is referenced
/// in a context that requires a complex type.
#[error("Expected complex type: {0}!")]
ExpectedComplexType(TypeIdent),
/// Expected dynamic element.
///
/// Expected the specified element to be dynamic because it is referenced
/// as substitution group.
#[error("Expected dynamic element: {0}!")]
ExpectedDynamicElement(TypeIdent),
/// Unknown type.
///
/// Is raised if a type identifier could not been resolved to the actual
/// type information.
#[error("Unknown type: {0}!")]
UnknownType(TypeIdent),
/// Unknown namespace.
///
/// Is raised if the namespace URI could not be resolved.
#[error("Unknown namespace: {0}!")]
UnknownNamespace(Namespace),
/// Unknown namespace prefix.
///
/// Is raised if the namespace prefix could not be resolved.
#[error("Unknown namespace prefix: {0}!")]
UnknownNamespacePrefix(NamespacePrefix),
/// Anonymous namespace is undefined.
///
/// Before resolving any type that is defined in the anonymous namespace
/// you have to add it to the [`Schemas`](crate::models::schema::Schemas)
/// by either adding a schema file that uses it (see
/// [`add_schema_from_str`](crate::pipeline::parser::Parser::add_schema_from_str)
/// or related add_schema_xxx methods) or by defining is manually (see
/// [`with_anonymous_namespace`](crate::pipeline::parser::Parser::with_anonymous_namespace)).
#[error("Anonymous namespace is undefined!")]
AnonymousNamespaceIsUndefined,
/// Invalid local name.
///
/// Is raised if conversion from a raw local name to a string has failed.
#[error("Invalid local name `{0}`!")]
InvalidLocalName(RawByteStr),
/// Group is missing the `ref` attribute
///
/// Is raised if a group reference in the XML schema is missing the `ref` attribute.
#[error("Group is missing the `ref` attribute!")]
GroupMissingRef,
/// Attribute group is missing the `ref` attribute
///
/// Is raised if a attribute group reference in the XML schema is missing the `ref` attribute.
#[error("Attribute group is missing the `ref` attribute!")]
AttributeGroupMissingRef,
/// Invalid attribute reference.
///
/// The attribute specified in the schema is missing some information.
#[error("Invalid attribute reference: {0:#?}!")]
InvalidAttributeReference(Box<AttributeType>),
/// Invalid facet.
///
/// Is raised if the content of a facet could not be interpreted correctly.
#[error("Invalid facet: {0:?}")]
InvalidFacet(Facet),
/// Unable to create type information.
///
/// Is raised if the interpreter was not able to generate a `Type` from the
/// provided schema information.
#[error("Unable to create type information!")]
NoType,
/// The interpreter expected a group type (like `xs:all`, `xs:choice` or `xs:sequence`).
#[error("Expected group type!")]
ExpectedGroupType,
/// Circular dependency.
///
/// Is raised if the interpreter detects a circular strong dependency between
/// types during type generation.
#[error("Circular dependency detected for type: {0}!")]
CircularDependency(TypeIdent),
}