/** * Schema Model * Typed representation of an XSD schema after parsing. * All XSD concepts (simple types, complex types, elements, attributes, * groups, constraints) are captured here. */ export declare const XSD_NS = "http://www.w3.org/2001/XMLSchema"; export declare const XSI_NS = "http://www.w3.org/2001/XMLSchema-instance"; export type Occurrence = { min: number; max: number | 'unbounded'; }; export type UseType = 'required' | 'optional' | 'prohibited'; export type ProcessContents = 'strict' | 'lax' | 'skip'; export type DerivationMethod = 'extension' | 'restriction'; export type CompositorType = 'sequence' | 'choice' | 'all'; export type WhitespaceAction = 'preserve' | 'replace' | 'collapse'; export type DerivationControl = 'extension' | 'restriction' | 'substitution' | '#all'; export interface Facet { kind: 'minLength' | 'maxLength' | 'length' | 'pattern' | 'enumeration' | 'minInclusive' | 'maxInclusive' | 'minExclusive' | 'maxExclusive' | 'totalDigits' | 'fractionDigits' | 'whiteSpace'; value: string; fixed?: boolean; } export interface SimpleTypeDefinition { kind: 'simple'; name: string | null; namespace: string; baseTypeName: string | null; facets: Facet[]; memberTypes: string[]; itemType: string | null; variety: 'atomic' | 'list' | 'union'; /** Derivation controls (final attribute) */ final?: DerivationControl[]; /** * G12: Inline anonymous item type definition for xs:list with an inline * xs:simpleType child (when itemType is null). */ itemTypeDef?: SimpleTypeDefinition; /** * G12: Inline anonymous member type definitions for xs:union with inline * xs:simpleType children. */ memberTypeDefs?: SimpleTypeDefinition[]; } export interface ComplexTypeDefinition { kind: 'complex'; name: string | null; namespace: string; abstract: boolean; mixed: boolean; contentType: 'empty' | 'simple' | 'elementOnly' | 'mixed'; simpleContent: SimpleTypeDefinition | null; particle: ParticleDefinition | null; attributes: AttributeDeclaration[]; anyAttribute: AnyAttributeDeclaration | null; baseTypeName: string | null; derivationMethod: DerivationMethod | null; /** Derivation controls */ final?: DerivationControl[]; block?: DerivationControl[]; /** * G24: xs:assert definitions on this complex type. * Each assertion is evaluated against each validated element of this type. */ assertions?: import('../validator/AssertionEvaluator').AssertionDefinition[]; } export type ParticleDefinition = ModelGroupParticle | ElementParticle | AnyParticle; export interface ModelGroupParticle { particleKind: 'group'; compositor: CompositorType; occurrence: Occurrence; particles: ParticleDefinition[]; } export interface ElementParticle { particleKind: 'element'; occurrence: Occurrence; elementDecl: ElementDeclaration; } export interface AnyParticle { particleKind: 'any'; occurrence: Occurrence; namespace: string; processContents: ProcessContents; } export interface ElementDeclaration { name: string; namespace: string; typeName: string | null; typeDefinition: SimpleTypeDefinition | ComplexTypeDefinition | null; nillable: boolean; abstract: boolean; defaultValue: string | null; fixedValue: string | null; substitutionGroup: string | null; minOccurs: number; maxOccurs: number | 'unbounded'; /** * ref="" attribute — when set, this particle is a reference to a top-level * element declaration rather than an inline declaration. */ ref?: string; /** block attribute controls which derivations can substitute */ block?: DerivationControl[]; /** final attribute controls which derivations are disallowed */ final?: DerivationControl[]; } export interface AttributeDeclaration { name: string; namespace: string; typeName: string | null; typeDefinition: SimpleTypeDefinition | null; use: UseType; defaultValue: string | null; fixedValue: string | null; } export interface AnyAttributeDeclaration { namespace: string; processContents: ProcessContents; } export type IdentityConstraintKind = 'key' | 'keyref' | 'unique'; export interface IdentityConstraint { kind: IdentityConstraintKind; name: string; /** XPath selector */ selector: string; /** XPath field expressions */ fields: string[]; /** Only for keyref: the referenced key/unique name */ refer?: string; } export declare class SchemaModel { targetNamespace: string; elementFormDefault: 'qualified' | 'unqualified'; attributeFormDefault: 'qualified' | 'unqualified'; version: string; elements: Map; simpleTypes: Map; complexTypes: Map; attributes: Map; /** * Substitution group head → set of member element names. * Populated by XsdParser after all elements are registered. */ substitutionGroups: Map>; /** * Identity constraints (key, keyref, unique) keyed by element name. * Used by ValidationEngine for cross-element constraint checking. */ identityConstraints: Map; constructor(); /** * Detect circular type inheritance chains. * Returns an array of { typeName, chain } for every circular reference found. * Call after all types are registered (XsdParser calls this). * * A circular type is one where following baseTypeName repeatedly leads back * to the starting type, e.g. A extends B extends A. */ detectCircularTypes(): Array<{ typeName: string; chain: string[]; }>; resolveType(qname: string): SimpleTypeDefinition | ComplexTypeDefinition | null; resolveSimpleType(qname: string): SimpleTypeDefinition | null; resolveComplexType(qname: string): ComplexTypeDefinition | null; resolveElement(qname: string): ElementDeclaration | null; /** * Collect all element declarations that can substitute for `headName` * (i.e. the head itself plus all members of its substitution group, * transitively). */ resolveSubstitutionGroup(headName: string): ElementDeclaration[]; /** * Build substitution group index from element declarations. * Call this after all elements are registered (XsdParser calls it). */ buildSubstitutionGroups(): void; /** * Serialise the compiled schema to a plain JSON-serialisable object. * Useful for schema documentation generators, IDE plugins, and form builders. * * @example * ```ts * const schema = parseXsd(xsdSource); * const json = schema.toJSON(); * console.log(JSON.stringify(json, null, 2)); * ``` */ toJSON(): Record; /** * Merge another SchemaModel into this one (used by xs:import / xs:include). * Built-ins are NOT duplicated. */ merge(other: SchemaModel): void; private _registerBuiltins; } //# sourceMappingURL=SchemaModel.d.ts.map