preprocessor

package
v0.0.28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package preprocessor loads schema documents and resolves include/import directives. It guarantees deterministic merge order and stable origin tracking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	FS                          fs.FS
	Resolver                    Resolver
	Merger                      loadmerge.SchemaMerger
	DocumentPool                *xmltree.DocumentPool
	SchemaParseOptions          []xmlstream.Option
	AllowMissingImportLocations bool
}

Config holds configuration for the schema loader

type FSResolver

type FSResolver struct {
	// contains filtered or unexported fields
}

FSResolver resolves schema documents from an fs.FS with strict path validation.

func NewFSResolver

func NewFSResolver(fsys fs.FS) *FSResolver

NewFSResolver creates a resolver backed by the provided filesystem.

func (*FSResolver) Resolve

func (r *FSResolver) Resolve(req ResolveRequest) (io.ReadCloser, string, error)

Resolve implements Resolver.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader loads XML schemas with import/include resolution. It is not safe for concurrent use.

func NewLoader

func NewLoader(cfg Config) *Loader

NewLoader creates a new schema loader with the given configuration

func (*Loader) Load

func (l *Loader) Load(location string) (*parser.Schema, error)

Load loads and merges a schema graph from location. It requires a configured resolver for root resolution and is retryable after failures.

type ResolveKind

type ResolveKind uint8

ResolveKind identifies the kind of schema resolution request.

const (
	ResolveInclude ResolveKind = iota
	ResolveImport
)

type ResolveRequest

type ResolveRequest struct {
	BaseSystemID   string
	SchemaLocation string
	ImportNS       []byte
	Kind           ResolveKind
}

ResolveRequest describes a schema resolution request.

type Resolver

type Resolver interface {
	Resolve(req ResolveRequest) (doc io.ReadCloser, systemID string, err error)
}

Resolver resolves schema documents into readers and canonical system IDs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL