/** * SchemaCompilerLite (G27-lite — Partial Schema Compilation) * ───────────────────────────────────────────────────────────── * Compiles a raw SchemaModel into a CompiledSchema — a normalized, * pre-resolved representation optimised for fast validation. * * v1.4 scope (lite) * ────────────────── * ✔ Resolve all named type references → inline definitions * ✔ Normalize minOccurs/maxOccurs defaults (1/1 when omitted) * ✔ Flatten single-level extension chains (attributes + particles) * ✔ Detect circular type references * ✔ Build prefix→element and prefix→type lookup maps * ✔ Pre-validate schema consistency (duplicate names, unknown base types) * ✔ Compile identity constraints into fast lookup structures * ✔ Immutable result (frozen maps) * * v2.0 will add: * • Full DFA construction per compositor * • Streaming-mode compiled schemas * • Full multi-level restriction derivation * * Usage * ───── * const compiled = compileSchema(schemaModel); * // compiled is cached — reuse across validations */ import { SchemaModel, ElementDeclaration, ComplexTypeDefinition, SimpleTypeDefinition, ParticleDefinition, IdentityConstraint } from '../schema/SchemaModel'; import { DfaModel } from '../validator/DfaEngine'; export interface CompiledSchema { /** Original source model */ readonly source: SchemaModel; /** * Flat map of all resolved element declarations. * Keys: both `{ns}local` and `local` forms for maximum lookup coverage. */ readonly elements: ReadonlyMap; /** * Flat map of all resolved complex types with inherited attributes/particles * already merged into the definition. */ readonly complexTypes: ReadonlyMap; /** * Flat map of all simple types. */ readonly simpleTypes: ReadonlyMap; /** * Pre-built map from element name → identity constraints. */ readonly identityConstraints: ReadonlyMap; /** * Set of element names that are abstract (must not appear directly). */ readonly abstractElements: ReadonlySet; /** * Substitution group map: head element name -> set of substitutable member names. * (mirrors SchemaModel.substitutionGroups) */ readonly substitutionGroups: ReadonlyMap>; /** * Pre-compiled DFA per complex type name (G27). * Key: complex type name (same as complexTypes map key). * Value: DfaModel ready for runDfa() — no rebuild per validation call. */ readonly compiledDfas: ReadonlyMap; /** * Compilation diagnostics (warnings; errors throw during compile). */ readonly warnings: string[]; /** * Timestamp of compilation (for cache invalidation). */ readonly compiledAt: number; } /** * Compile a SchemaModel into an optimised CompiledSchema ready for validation. * Used internally by ValidationPipeline and ValidationEngine. * @internal */ export declare function compileSchema(model: SchemaModel): CompiledSchema; /** * T-09: Flatten group-reference particles so the DFA sees element/any particles * directly rather than synthetic `__group_X` names that never appear in documents. * * Rules (matching XSD semantics): * • occurrence {min:1, max:1} → inline the group's inner particles directly * • occurrence {min:0, max:1} → inline inner particles but mark each as optional * (minOccurs=0) when the original minOccurs was 1 * • other occurrences (e.g. min:0 max:unbounded) → keep the group wrapper so * validation still works; occurrence on individual elements may be imprecise * but the structure is preserved (known limitation documented as T-09) * * The function is recursive so nested group refs are also resolved. * Exported for use by StreamingValidator (inline DFA build for anonymous types). */ export declare function flattenGroupParticles(particles: ParticleDefinition[]): ParticleDefinition[]; //# sourceMappingURL=SchemaCompilerLite.d.ts.map