parser

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package parser parses XSD documents into raw symbolic components. References remain unresolved at this phase.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasPlaceholders added in v0.0.23

func HasPlaceholders(schema *Schema) bool

HasPlaceholders reports whether unresolved type placeholders remain.

func ImportContextKey added in v0.0.16

func ImportContextKey(fsKey, location string) string

ImportContextKey combines a filesystem key and location into a stable lookup key.

func ImportContextLocation added in v0.0.16

func ImportContextLocation(key string) string

ImportContextLocation extracts the original location from an import context key.

Types

type Directive added in v0.0.16

type Directive struct {
	Import  ImportInfo
	Include IncludeInfo
	Kind    DirectiveKind
}

Directive preserves the document order for include/import directives.

type DirectiveKind added in v0.0.16

type DirectiveKind uint8

DirectiveKind represents an include/import directive in document order.

const (
	DirectiveInclude DirectiveKind = iota
	DirectiveImport
)

type Form added in v0.0.4

type Form int

Form represents qualified/unqualified element/attribute forms

const (
	// Unqualified indicates an unqualified element/attribute form.
	Unqualified Form = iota
	// Qualified indicates a qualified element/attribute form.
	Qualified
)

type GlobalDecl added in v0.0.16

type GlobalDecl struct {
	Name model.QName
	Kind GlobalDeclKind
}

GlobalDecl tracks a top-level declaration in document order.

type GlobalDeclKind added in v0.0.16

type GlobalDeclKind int

GlobalDeclKind identifies top-level schema declarations in document order.

const (
	// GlobalDeclElement represents a top-level element declaration.
	GlobalDeclElement GlobalDeclKind = iota
	// GlobalDeclType represents a top-level type declaration (complex or simple).
	GlobalDeclType
	// GlobalDeclAttribute represents a top-level attribute declaration.
	GlobalDeclAttribute
	// GlobalDeclAttributeGroup represents a top-level attributeGroup declaration.
	GlobalDeclAttributeGroup
	// GlobalDeclGroup represents a top-level model group declaration.
	GlobalDeclGroup
	// GlobalDeclNotation represents a top-level notation declaration.
	GlobalDeclNotation
)

type ImportContext added in v0.0.4

type ImportContext struct {
	Imports         map[model.NamespaceURI]bool
	TargetNamespace model.NamespaceURI
}

ImportContext tracks import namespaces for a specific schema document.

type ImportInfo

type ImportInfo struct {
	Namespace      string
	SchemaLocation string
}

ImportInfo represents an import directive from an XSD schema. Imports allow referencing components from a different namespace.

type IncludeInfo

type IncludeInfo struct {
	SchemaLocation string
	DeclIndex      int
	IncludeIndex   int
}

IncludeInfo represents an include directive from an XSD schema. Includes allow referencing components from the same namespace or no namespace.

type ParseError

type ParseError struct {
	Err     error
	Code    string
	Message string
}

ParseError represents a schema parsing error with an error code

func (*ParseError) Error

func (e *ParseError) Error() string

Error implements the error interface.

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

Unwrap returns the wrapped error, if any.

type ParseResult

type ParseResult struct {
	Schema     *Schema
	Directives []Directive
	Imports    []ImportInfo
	Includes   []IncludeInfo
}

ParseResult contains the parsed schema and import/include directives

func ParseWithImportsOptions added in v0.0.22

func ParseWithImportsOptions(r io.Reader, opts ...xmlstream.Option) (*ParseResult, error)

ParseWithImportsOptions parses an XSD schema with XML reader options.

func ParseWithImportsOptionsWithPool added in v0.0.24

func ParseWithImportsOptionsWithPool(r io.Reader, pool *xmltree.DocumentPool, opts ...xmlstream.Option) (*ParseResult, error)

ParseWithImportsOptionsWithPool parses an XSD schema with XML reader options and an explicit document pool.

func ParseWithOptions added in v0.0.25

func ParseWithOptions(r io.Reader, opts ...xmlstream.Option) (*ParseResult, error)

ParseWithOptions parses one schema and returns directive metadata.

func ParseWithOptionsWithPool added in v0.0.25

func ParseWithOptionsWithPool(r io.Reader, pool *xmltree.DocumentPool, opts ...xmlstream.Option) (*ParseResult, error)

ParseWithOptionsWithPool parses one schema with an explicit document pool.

type Parser added in v0.0.25

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

Parser parses schemas with reusable parse options and document pool.

func NewParser added in v0.0.25

func NewParser(opts ...xmlstream.Option) *Parser

NewParser creates a parser with optional xmlstream parse options.

func (*Parser) Parse added in v0.0.25

func (p *Parser) Parse(r io.Reader) (*ParseResult, error)

Parse parses one schema and returns directive metadata.

type Schema added in v0.0.4

type Schema struct {
	ImportContexts        map[string]ImportContext
	Groups                map[model.QName]*model.ModelGroup
	ElementOrigins        map[model.QName]string
	TypeDefs              map[model.QName]model.Type
	TypeOrigins           map[model.QName]string
	AttributeDecls        map[model.QName]*model.AttributeDecl
	SubstitutionGroups    map[model.QName][]model.QName
	AttributeGroups       map[model.QName]*model.AttributeGroup
	AttributeGroupOrigins map[model.QName]string
	ImportedNamespaces    map[model.NamespaceURI]map[model.NamespaceURI]bool
	ElementDecls          map[model.QName]*model.ElementDecl
	GroupOrigins          map[model.QName]string
	AttributeOrigins      map[model.QName]string
	NotationOrigins       map[model.QName]string
	NotationDecls         map[model.QName]*model.NotationDecl
	IDAttributes          map[string]string
	NamespaceDecls        map[string]string
	Location              string
	TargetNamespace       model.NamespaceURI
	GlobalDecls           []GlobalDecl
	FinalDefault          model.DerivationSet
	AttributeFormDefault  Form
	ElementFormDefault    Form
	BlockDefault          model.DerivationSet
}

Schema represents a compiled XSD schema

func NewSchema added in v0.0.4

func NewSchema() *Schema

NewSchema creates a new empty schema

func Parse

func Parse(r io.Reader) (*Schema, error)

Parse parses an XSD schema from a reader

Source Files

Jump to

Keyboard shortcuts

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